Solve Leetcode Problems and Get Offers From Your Dream Companies

LeetCode 14 | Longest Common Prefix (Easy)

Nil Madhab
Javarevisited

--

In this series, I am going to solve Leetcode medium problems live with my friend, which you can see on our youtube channel, Today we will do Problem Problem 1429. First Unique Number.

A little bit about me, I have offers from Uber India and Amazon India in the past, and I am currently working for Booking.com in Amsterdam.

This story was originally published at simplecoding.dev

Motivation to Learn Algorithms

Problem Statement

Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string.

Sample Input

Example 1:

Input: strs = ["flower","flow","flight"]
Output: "fl"

Example 2:

Input: strs =…

--

--

Nil Madhab
Javarevisited

Developer @Booking.com | ex: Samsung, OYO | IIT Kharagpur | Entrepreneur, founder of simplecoding.dev | JOIN Medium, https://nilmadhab.medium.com/membership