Longest common prefix · 最長共通接頭辞
Longest common prefix
Return the longest string that starts every word in the array. For flower, flow, flight it's fl; if there's nothing in common, return "". Start with the first word as a guess and shrink it against each next word until it fits them all.
最長共通接頭辞
配列内のすべての単語を始める最長の文字列を返します。flower, flow, flightの場合、答えはflです。共通するものがなければ""を返します。最初の単語を推測として始め、次の単語ごとに縮めていき、全てに当てはまるまで進めます。
Complete longestCommonPrefix(String[] strs) returning the longest prefix shared by every string. Return an empty string if there is none or the array is empty. · longestCommonPrefix(String[] strs) を完成させて、すべての文字列に共通する最長の接頭辞を返してください。ない場合や配列が空の場合は空文字列を返してください。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。