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

 

shortenedIDs


To reduce complexity, a company wants to generate the smallest number of least-significant digits from IDs (customer ID, order ID, staff ID, etc.).

For example, if the original order IDs are {101, 128, 107, 105}, the shortened IDs are {1, 8, 7, 5}, and if the original order IDs are {10183, 27, 21183, 127}, the shortened IDs are {183, 27, 1183, 127}. Define a function that when passed an array containing n IDs (all different), returns an array containing the minimum number of least-significant digits to distinctively distinguish them.


shortenedIDs([101, 128, 107, 105]) → [1, 8, 7, 5]
shortenedIDs([25183, 10183]) → [5183, 183]
shortenedIDs([10183, 27, 25183, 127]) → [183, 27, 5183, 127]

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

int[] shortenedIDs(int[] ids) { }

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

Copyright Nick Parlante 2017 - privacy