×

# Compiler and Parsers

 0 Why my code says WA i cannot get. Please Help import java.io.*; class Compiler { static String a[]; static int pos; public static void main(String args[])throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); for(int z=0;z0) { String k=pop()+">"; l=Math.max(l,k.length()); if(pos>0)a[pos-1]=a[pos-1]+k; } } } System.out.println(l); } } static void push(String s) { a[pos++]=s; } static String pop() { String k=a[pos-1]; a[pos-1]=null; pos--; return k; } }  This question is marked "community wiki". asked 21 May '14, 17:16 3★bradley 656●2●3●21 accept rate: 20% 0★admin ♦♦ 19.8k●350●498●541

 0 When ever you get pos<0  shouldn't you end the loop? so i think you have to keep (i=0)  that might help.. i think so. (i don't know java, so i am not sure of the boolean condition) answered 21 May '14, 17:46 152●2●4●15 accept rate: 0% bro there is nothing called "pos<0" and this is working in all the test cases i have made and of the question. (22 May '14, 14:49) bradley3★ then try these cases:: <><>>< <<<><<>>> i checked your code in ideone.com, which gave wrong responses for these cases (22 May '14, 19:55) @eightnoteight for your first testcase the ans should be 2 or anything else?? and for the second it must be 8? what is the problem? (13 Jun '14, 11:12) bradley3★ the first case should give 4, but your code gives 2 the second case should give 0, but your code gives 8 (14 Jun '14, 18:41)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×100
×4

question asked: 21 May '14, 17:16

question was seen: 938 times

last updated: 14 Jun '14, 18:41