Sort by

recency

|

4136 Discussions

|

  • + 0 comments

    Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-counting-valleys-problem-solution.html

  • + 0 comments

    This is my javascript solution, cheers!

    let countUpDown: number = 0; let countValley: number = 0;

    for( let step of path ){
        step === "U" ? countUpDown += 1 : countUpDown -= 1;
    
        if( countUpDown === 0 ){
            if( step === "U" ){
                countValley += 1;
            }
        } 
    }
    return countValley;
    
  • + 1 comment

    Can you help me to solve the interesting algorithm on my website Insta Pro APK?

    • + 0 comments

      https://instaproa.com/

  • + 0 comments

    def countingValleys(steps, path): elevation = 0 valleys = 0

    for step in path:
        if step == "D":
            elevation -= 1
    
        elif step == "U":
            elevation += 1
            if elevation == 0:
                valleys += 1
    
    return valleys
    
  • + 0 comments

    Here is problem solution in Python, Java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-counting-valleys-problem-solution.html