From dbb2b1bc714a1183007f9d1f8d1a1d64ffe7356d Mon Sep 17 00:00:00 2001 From: Jon Jagger Date: Thu, 10 Nov 2022 21:43:33 +0100 Subject: [PATCH] Update Longest Common Prefix --- start-points/Longest_Common_Prefix/readme.txt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/start-points/Longest_Common_Prefix/readme.txt b/start-points/Longest_Common_Prefix/readme.txt index 0c1c971..5deba16 100644 --- a/start-points/Longest_Common_Prefix/readme.txt +++ b/start-points/Longest_Common_Prefix/readme.txt @@ -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"