Showing 6 questions
Find the longest string that is a prefix of all strings in a given array. If no common prefix exists, return an empty string.
#1. Longest Common Prefix
You're given an array containing only 0s, 1s, and 2s. Sort the array in place so that elements of the same value are grouped together.
#2. Sort Colors
Find the longest palindromic substring within a given string. A palindromic substring reads the same forwards and backward.
#3. Longest Palindromic Substring
Find the contiguous subarray within a given array of numbers which has the largest sum. Return the sum of this subarray.
#4. Maximum Subarray
Design a class to efficiently calculate the product of the last k numbers added to a stream. You need to support adding new numbers and querying the product of the last k numbers at any time.
#5. Product of the Last K Numbers
Find the longest path in a tree where no two adjacent nodes on the path have the same character. The tree is defined by parent-child relationships and each node has an associated character.
#6. Longest Path With Different Adjacent Characters