You are viewing a single comment's thread. Return to all comments →
func countingValleys(steps int32, path string) int32 { stepsCount := 0 valleys := 0 seaLevel := 0 for _, char := range path { if char == 'U' { stepsCount++ } else if char == 'D' { if stepsCount == seaLevel { valleys++ } stepsCount-- } } return int32(valleys) }
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 →