Link to home
Start Free TrialLog in
Avatar of robdijo
robdijoFlag for United States of America

asked on

Java Programming Question

Given 2 strings, a and b, return the number of the positions where they
contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3,
since the "xx", "aa" and "az" substring appear in the same place in
strings.

stringMatch("xxcaazz","xxbaaz") -> 3

stringMatch("abc", "abc") -> 2

stringMatch("abc", "axc") -> 0

public int stringMatch(String a, String b)
{
     write code???
}
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Post the code you've written and we'll help with it. We don't write classwork for people
Avatar of robdijo

ASKER

I do not know where to start.  I have no code.
Break down the task into parts, starting with

a. obtain all length 2 substrings from the source string by iteration [and print them out]

(the part in brackets can be removed later)


Is this your class assignment ?
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
write the code in this sense - post it we will correct
>>write the code

No need - you did it for him. Homework done then...