CHARGEBEE Hiring Off-Campus OA (2021) | Problem Longest Common Prefix
Chargebee · Question · Posted Jun 2026
Problem Statement Write a function to find the longest common prefix string among an array of strings. If there is no common prefix among the strings, return an empty string "". A prefix is a substring that starts from the beginning of a string. Example 1 Input strs = ["flower","flow","flight"] Output "fl" Explanation Common prefixes: flower flow flight The longest prefix shared by all strings is: fl Example 2 Input strs = ["dog","racecar","car"] Output "" Explanation There is no common ...
The full answer & interview discussion are available to premium members.
Log in Create a free account