HackerRank Counting Valleys - Solution Walkthrough (JavaScript)

HackerRank Counting Valleys - Solution Walkthrough (JavaScript)

Digital Horizon

3 года назад

9,394 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@ChrisHodge1978
@ChrisHodge1978 - 13.12.2022 20:12

I did almost the same code in c++, however I check for sea level = 0 after processing each step. If SL==0 and our previous step was UP, we must have been in a valley.

Ответить
@talhaaman6928
@talhaaman6928 - 27.09.2022 22:15

wrong solution ... need improvement

Ответить
@CarlosMontiDev
@CarlosMontiDev - 01.03.2022 20:02

Hey but if I have [UUUUDDUD] then I won't be able to check -1. I'm confused. Thanks for the video btw.

Ответить
@ayoubbougroune4050
@ayoubbougroune4050 - 11.11.2021 17:59

thank you

Ответить
@hollyjo161821
@hollyjo161821 - 20.10.2021 22:35

2 hours later.... Thank you. Didn't think about the only previous direction to count will be going up to 0 by 1 step so track if value == -1. Thank yoU!

Ответить
@manvirchoudhary107
@manvirchoudhary107 - 06.07.2021 08:56

Thanks nice solution

Ответить
@ivorpad
@ivorpad - 27.04.2021 12:04

I'd do the check of elevation === -1 after I decrease the elevation. The reason for this is that every time the elevation goes down from 0 to -1 it'll count as a valley. If you step with the debugger you'll see that I mean. Either way, it was a great explanation.

Ответить
@pascalegordon1641
@pascalegordon1641 - 06.02.2021 05:54

I tried this problem using Regex but it only passed some of the test cases

Ответить
@franciscojorge7625
@franciscojorge7625 - 05.10.2020 18:53

Hope I do good in today's job interview. I'm sharing this everywhere man, thanks

Ответить
@spraveenitpro
@spraveenitpro - 26.09.2020 07:42

Very nicely explained.

Ответить