Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
|
||
You task is to find the longest common prefix from a set of strings. | ||
You task is to find the length of the longest common prefix from a set of strings. | ||
There are two variations: | ||
|
||
Variation 1. | ||
Find the longest common prefix across ALL strings in the set. | ||
Find the length of longest common prefix across ALL strings in the set. | ||
For example: | ||
|
||
{ "new", "next" } ==> "ne" | ||
{ "new", "next" } ==> 2 | ||
|
||
{ "newest", "new", "newly" } ==> "new" | ||
{ "newest", "new", "newly" } ==> 3 | ||
|
||
{ "pond", "pod", "new", "newest" } ==> "" | ||
{ "pond", "pod", "new", "newest" } ==> 0 | ||
|
||
|
||
Variation 2. | ||
Find the longest common prefix across ANY two or more strings in the set. | ||
Find the length of longest common prefix across ANY two or more strings in the set. | ||
For example: | ||
|
||
{ "pond", "newest" } ==> "" | ||
{ "pond", "newest" } ==> 0 | ||
|
||
{ "new", "night" } ==> "n" | ||
{ "new", "night" } ==> 1 | ||
|
||
{ "newest", "new", "newly" } ==> "new" | ||
{ "newest", "new", "newly" } ==> 3 | ||
|
||
{ "pond", "pod", "new", "newest" } ==> 3 | ||
|
||
{ "pond", "pod", "new", "newest" } ==> "new" | ||
|