Given two strings s1 and s2, return their longest common prefix
Example 1:
Input: s1 = "hello", s2 = "help" Output: "hel"
Example 2:
Input: s1 = "Andy", s2 = "Mircea" Output: ""
Example 3:
Input: s1 = "AlgoCademy", s2 = "Algo" Output: "Algo"
Walkthroughs of the solution. Try the steps first, then watch to compare approaches.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check