Tech
Code and approach to so solve Longest common prefix
class Solution :
def longestCommonPrefix ( self , strs : List [ str ]) -> str :
Longest_sum = ""
for i in range ( len ( strs [ 0 ])):
for j in strs :
if i >= len ( j ) or j [ i ] != strs [ 0 ][ i ]:
return Longest_sum
Longest_sum += strs [ 0 ][ i ]
return Longest_sum
PROBLEM
so i...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to