Java mini project
public class Main {
public static int levelCount(String json) {
int maxDepth = 0;
int currentDepth = 0;
for (int i = 0; i < json.length(); i++) {
char c = json.charAt(i);
if (c == '{' || c == '[') {
currentDepth++;
maxDepth = Math.max(maxDepth, currentDepth);
} else if (c == '}' || c == ']') {
currentDepth--;
}
}
return maxDepth;
}
public static void main(String[] args) {
System.out.println(levelCount(args[0]));
}
}