about | help | code help+videos | done | prefs |
Write a method that returns how many "Halloween Paths" exist based on the house numbers in the input parameter array. A "Halloween Path" is any CONTIGUOUS listing of house numbers in increasing order. For example, {1500,1600,1700,1200,1900}, has the following possible "Halloween Paths": (1500, 1600); (1500, 1600, 1700); (1600, 1700}; and (1200, 1900) for a total of 4 "Halloween Paths". Contiguous means that they must be adjacent to each other in the array. That is why (1500,1600,1700,1900} did not count as a path. There is an easy way to do this, but there are also many, many difficult ways! It might help to do some work on paper first! oct31_2019_HL_halloweenPaths([50, 60, 70, 30, 20, 25, 60, 90, 40, 30, 70, 80, 100, 110, 70, 50, 30]) → 19 oct31_2019_HL_halloweenPaths([500, 600, 700, 900, 1200, 1400, 1500, 1600, 1800, 2000, 2020, 2500, 4000, 5000, 9000, 10000]) → 120 oct31_2019_HL_halloweenPaths([]) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy