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

 

diceStats


Given an array of integers containing values in the range 1 to 6, inclusive, return an array of size 6 containing a count of the number of times each of the six values occur. For example, in the array {3, 1, 1, 2, 4, 4, 4, 6} the number 1 occurs 2 times, the number 2 occurs 1 time, the number 3 occurs 1 time, the number 4 occurs 3 times, the number 5 occurs 0 times, and the number 6 occurs 1 time. SUGGESTION: This can be solved with a single "for each" loop and no if statements.


diceStats([3, 1, 1, 2, 4, 4, 4, 6]) → [2, 1, 1, 3, 0, 1]
diceStats([3, 3, 3, 5]) → [0, 0, 3, 0, 1, 0]
diceStats([6, 6, 6, 6, 6]) → [0, 0, 0, 0, 0, 5]

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

int[] diceStats(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: 215

Copyright Nick Parlante 2017 - privacy