<commit_before><commit_msg>Nesting completed<commit_after>package Codility;

import java.util.Stack;

/*
 * Author : <NAME>.
 * Link : https://codility.com/programmers/task/nesting
 */

public class _L0405StacksAndQueuesNesting {
	public static void main(String[] args) {
		System.out.println("(()(())())"+solution("(()(())())"));
		System.out.println(""+solution(""));
		System.out.println("(U)"+solution("(U)"));
		System.out.println("VW"+solution("VW"));
		System.out.println("())"+solution("())"));
		
	}
	public static int solution(String str){
		Stack<Character> charStack=new Stack<Character>();
		for (int i = 0; i < str.length(); i++) {
			char c=str.charAt(i);
			if(c=='(' || c=='{'|| c=='[')
			{
				charStack.push(c);
			}
			else if(c==')' || c=='}'|| c==']')
			{
				if(charStack.isEmpty())
					return 0;
				else
				{
					char poppedChar=charStack.pop();
					if(!(c==')' && poppedChar=='(')||
							(c==']' && poppedChar=='[')||
							(c=='}' && poppedChar=='{'))
						return 0;
				}
			}
		}
		return 1;
	}
}
{'fraction_non_alphanumeric': 0.2608695652173913, 'fraction_numerical': 0.007729468599033816, 'mean_word_length': 3.6666666666666665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7581162', 'n_tokens_mistral': 468, 'n_tokens_neox': 377, 'n_words': 63}