Tag: string algorithm
Given a list of lowercase alphabet strings words, return the length of the longest contiguous sublist where all words share the same first letter. Example 1 Input words = …
You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the …
Given a string s containing balanced parentheses “(” and “)”, split them into the maximum number of balanced groups. Constraints n ≤ 100,000 where n is length of s. …
Given a lowercase alphabet string s, partition s into as many pieces as possible such that each letter appears in at most one piece and return the sizes of …
Given a string s , find the length of the longest substring t that contains at most 2 distinct characters. Example 1: Input: “eceba” Output: 3 Explanation: t is …