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

 

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

Write a method that returns the "interlace" of two input parameter strings. The "interlace" of two strings is a string equal in length to the shorter of the two strings, where characters that match in the same position are kept while non-matching characters are replaced with a "-". So if the input strings are "abcd" and "acbdxyz" you would return "a--d". Look at the test data for additional examples. The only string methods you are allowed to use are .equals, .charAt, .substring, and .length.


nov20_2015_SLHL_interlaceStrings("a man a plan a canal panama", "amanap lanac a nalp a nam a") → "a---------a- a -a---------a"
nov20_2015_SLHL_interlaceStrings("dad", "dad") → "dad"
nov20_2015_SLHL_interlaceStrings("jump", "down") → "----"

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

public String nov20_2015_SLHL_interlaceStrings(String a, String b) { }

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