id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > test2022_10_06_SLHL_diffs
prev  |  next  |  chance

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)

public int[] test2022_10_06_SLHL_diffs(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 230

Copyright Nick Parlante 2017 - privacy