1. Engineering
  2. Computer Science
  3. java 8...

Question: java 8...

Question details

Java 8

Braces You are designing a compiler for a C++ program and need to check that braces in any given file are balanced Braces in a string are considered to be balanced if the following criteria are met: All braces must be closed. Braces come in pairs of the form 0.0andl1. The left brace opens the pair, and the right one closes it In any set of nested braces, the braces between any pair must be closed For example, [0l is a valid groupingofbraces but [)IC is not. Function Description Complete the function braces in the editor below. The function must return an array of strings where the string at each index i denotes whether or not the braces were balanced in a values The array should consist of strings YES or NO aligned with their indexes in values. braces has the following parameter(s) valuesfvalues.. valueso-1): an array of strings to analyze Constraints 1sns 15 1 s length of values,s 100 It is guaranteed that each values, consists of (), L. I. L, and ]only

Input Format For Custom Testing Input from stdin will be processed as follows and passed to the function: The first line contains an integer n, the number of elements in values. Each of the next n lines contains a string describing values,where 0 si<n ▼ Sample Case。 Sample Input For Custom Testing IN Sample Output YES NO Explanation valueso: IHK) meets the criteria for a balanced string, so index 0 in our return array should contain the string YES values: contains unmatched braces between a matched pair in the substrings [.I), and [)l. so index 1 in our return array should contain the string NO

YOUR ANSWER Draft saved 02:10 pm Original Code Java 8 1 import java.io.; 12 13 /I Complete the braces function below 14 static String[1 braces(String1 values) 15 16 17 18 19private static final Scanner scanner new Scanner (System.in);

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution