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

 

amjadm@miamioh.edu project5 > countTotalsByFirstOccurrence
prev  |  next  |  chance

Given an array of non-empty strings, return an int array containing the total number of occurrences for each unique string, in the order they first appear in the array. You must solve this using a HashMap to ensure Θ(n) amortized time.


countTotalsByFirstOccurrence(["w", "W"]) → [1, 1]
countTotalsByFirstOccurrence(["one"]) → [1]
countTotalsByFirstOccurrence(["a", "b", "a", "a", "b"]) → [3, 2]

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

public int[] countTotalsByFirstOccurrence(String[] strings) { }

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

Copyright Nick Parlante 2017 - privacy