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

 

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

Retail companies often "push" items based on how many they have in stock. It makes sense to try to sell the items you have the most of. Write a method that returns the index of the item to "push". The 'quantities' array will indicate how many of each item is on-hand. For example, if index 2 of this array has a 30 in it, that means there are 30 of item #2 in stock. Return an integer indicating the index of the item to push. If there are the same exact quantities of multiple items, the one that is first in the original array should be the one indicated. All of the input parameters will be non-negative. You may assume that the 'quantities' array will have at least one item.


orderSystemItemsToPushAdvanced1([50, 70, 20, 10, 15, 80, 2]) → 5
orderSystemItemsToPushAdvanced1([30, 40, 2, 0, 30, 6]) → 1
orderSystemItemsToPushAdvanced1([3, 7, 2, 1, 50, 80]) → 5

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

public int orderSystemItemsToPushAdvanced1(int[] quantities) { }

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: 290

Copyright Nick Parlante 2017 - privacy