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

 

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

Write a method that finds the product with the greatest number of digits that match 'digit'. The product comes from selecting two different elements in the array 'nums'. If there is a tie for the same number of times 'digit' appears in the results, use the first combination that produces that result. You will return the result as a string that shows the two numbers being multiplied together to produce the appropriate product. Note that the order the two numbers appear is important. In other words, if the test data shows "57*46=2622" your result must be exactly that and not "46*57=2622". So, you must determine how the order is established from the test data (I am not going to explain that part as I want you to figure it out from the test data). If NONE of the product combinations produce any numbers that contain 'digit', return "not found". Obviously, look at the test data for help! I suggest using a helper method, but you do not have to.


test2022_11_17_HL_mostMatchDigits([40, 100, 77, 18], 0) → "40*100=4000"
test2022_11_17_HL_mostMatchDigits([21, 37, 51, 97], 2) → "21*97=2037"
test2022_11_17_HL_mostMatchDigits([42, 54, 643, 81], 4) → "54*81=4374"

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

public String test2022_11_17_HL_mostMatchDigits(int[] nums, int digit) { }

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

Copyright Nick Parlante 2017 - privacy