You are viewing a single comment's thread. Return to all comments →
java 8
int l = 0; int count = 0; boolean check = false; for(char c : path.toCharArray()){ if(c == 'U'){ l++; if(l > 0){ check =true; } else { check = false; } } else { l--; } if(l == 0 && !check){ count++; }
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Valleys
You are viewing a single comment's thread. Return to all comments →
java 8