You are viewing a single comment's thread. Return to all comments →
Can anyone please tell me what is wrong in my code. only 2 test cases are passing.
if(n==1) { return 1; } List out = new ArrayList (); int counter =1; out.add(counter); for(int i=0 ; i arr.get(i)) { counter++; out.add(counter); } else{ counter=1; out.add(counter); } } // System.out.println(out); return out.stream().mapToInt(Integer::intValue).sum();
Seems like cookies are disabled on this browser, please enable them to open this website
Candies
You are viewing a single comment's thread. Return to all comments →
Can anyone please tell me what is wrong in my code. only 2 test cases are passing.
if(n==1) { return 1; } List out = new ArrayList (); int counter =1; out.add(counter); for(int i=0 ; i arr.get(i)) { counter++; out.add(counter); } else{ counter=1; out.add(counter); } } // System.out.println(out); return out.stream().mapToInt(Integer::intValue).sum();