| about | help | done | prefs | create account |
Java > AP-1 > commonTwo
prev | next | chance
| Start with two arrays of strings, a and b, each in alphabetical order, possibly with duplicates. Return the count of the number of strings which appear in both arrays. The best "linear" solution makes a single pass over both arrays, taking advantage of the fact that they are in alphabetical order.
commonTwo({"a", "c", "x"}, {"b", "c", "d", "x"}) → 2 commonTwo({"a", "c", "x"}, {"a", "b", "c", "x", "z"}) → 3 commonTwo({"a", "b", "c"}, {"a", "b", "c"}) → 3 ...Save, Compile, Run See also Java Example Code. Java help docs: If Boolean Logic | Strings | While and For Loops | Arrays and Loops |
Forget It! -- delete my code for this problem
New just for fun
Random User Progress Graphs
Random Epic Graphs
254.0
Copyright Nick Parlante 2006-11 - privacy