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

 

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

Write a method that compares the first few digits of 'original' to the entire 'target'. If the first few digits of 'original' exactly match all of the 'target' digits, in the same order, return the total number of digits in 'target'. Otherwise return -1 as a special value to indicate failure to find the 'target' digits at the start of 'original'. Both 'original' and 'target' will be positive integers. If 'target' has more digits than 'original' return -1 since 'target' cannot fit in 'original'. You may NOT use ANY strings or string methods. Look at the test data for examples.


may25_2018_APSL_FirstFind(12425, 1242) → 4
may25_2018_APSL_FirstFind(82471, 82) → 2
may25_2018_APSL_FirstFind(1924, 42) → -1

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

public int may25_2018_APSL_FirstFind(int original, int target) { }

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

Copyright Nick Parlante 2017 - privacy