You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution you can find the video here : https://youtu.be/fgJ-i8RJ1Qw
int countingValleys(int steps, string path) { int res = 0, level = 0; for(char c : path){ if(c == 'U'){ level++; if(level == 0) res ++; } else level--; } return res; }
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 →
Here is my c++ solution you can find the video here : https://youtu.be/fgJ-i8RJ1Qw