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

 

countOccur


Given an array of integers with at least one element, return an integer array such that there is an index that represents each number found in the source array and at the index is stored how many times a each number was found.


For example, the source array:
{1,3,5,3,5,5}
would generate an array:
{0,1,0,2,0,3}
because there are no 0's in the source array, there is a single 1, no 2's, but two 3's, no 4's, and three 5's.

countOccur([1, 3, 5, 3, 5, 5]) → [0, 1, 0, 2, 0, 3]
countOccur([0]) → [1]
countOccur([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) → [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]

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

public int[] countOccur(int[] arr) { }

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: 300 Post-solution available

Copyright Nick Parlante 2017 - privacy