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

 

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

Write a method that accepts an array 'nums'. Return a new array with one less element than 'nums' and containing the products of all the adjacent elements in 'nums'. For example, if 'nums' contained {4,3,100} you would return {12,300} because 4*3=12 and 3*100=300. Note that 'nums' will have at least one element in it. If 'nums' only has one element, you will return an empty array. Look at the test data for examples. You may use one or more helper methods. Remember to make sure each method has only one return statement.


test2024_03_12_APP1SLHL_products([5, 2, 7, 1, -3, 0, 2]) → [10, 14, 7, -3, 0, 0]
test2024_03_12_APP1SLHL_products([1, 2, 3, 4, 5, 6]) → [2, 6, 12, 20, 30]
test2024_03_12_APP1SLHL_products([20, -2, 6, -1, 100, 40]) → [-40, -12, -6, -100, 4000]

...Save, Compile, Run (ctrl-enter)

public int[] test2024_03_12_APP1SLHL_products(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: 280

Copyright Nick Parlante 2017 - privacy