about | help | code help+videos | done | prefs |
Write a method that accepts an array on integers called 'nums', then returns a new array made up of the differences between consecutive elements in 'nums'. For example, if 'nums' equals {5,10,13,11} you would return (5,3,-2} because the difference between 5 and 10 is 5, the difference between 10 and 13 is 3, etc. Note that the array being returned has one less element than 'nums'. As a precondition, you may assume that 'nums' has at least two elements. test2022_10_06_SLHL_diffs([5, 50]) → [45] test2022_10_06_SLHL_diffs([11, 11]) → [0] test2022_10_06_SLHL_diffs([121, 1331]) → [1210] ...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: 230
Copyright Nick Parlante 2017 - privacy