We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In this code
if(lvl==0 && c=='U')
++v;
this will count the uphill steps
but in this question they are asking for the down hill steps when level ==0
so instead of that if you can write
if(lvl==0 && c=='U')
for downhill steps
Cookie support is required to access HackerRank
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 →
In this code if(lvl==0 && c=='U') ++v; this will count the uphill steps but in this question they are asking for the down hill steps when level ==0 so instead of that if you can write if(lvl==0 && c=='U') for downhill steps