Find the longest substring of a string containing distinct characters
Given a string, find the longest substring containing distinct characters using sliding window technique in linear time.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a string, find the longest substring containing distinct characters using sliding window technique in linear time.
Find all substrings of a string that contains all characters of another string. In other words, find all substrings of the first string that are anagrams of the second string.
Given a string, find all palindromic permutations of it… We know that the left and right half of a palindrome contains the same set of characters, so any palindromic permutations of a string are only possible if each character’s frequency in the string is even.
Given a string and a positive number k, find the longest substring of the string containing k distinct characters. If k is more than the total number of distinct characters in the string, return the whole string.
Run–length encoding (RLE) is a simple form of lossless data compression that runs on sequences with the same value occurring many consecutive times. It encodes the sequence to store only a single value and its count.
Given a line of text, reverse the text without reversing the individual words.
Given a string and an integer k, print the string in k rows in the zigzag form.
Find the length of the longest contiguous substring of a given string, such that the length of the substring is 2×n digits and the sum of the leftmost n digits is equal to the sum of the rightmost n digits.
Given a string, in-place remove all occurrences of AB and C from it. For example, for the input string is ‘CBAABCAB’, the string after removal of ‘AB’ and ‘C’ is ‘BA’.
Given a text, find all occurrences of a given pattern in it. The goal is to find all occurrences of pattern P[1…m] of length m in the given text T[1…n] of length n.
Given a list of words, efficiently group all anagrams. The two strings, X and Y, are anagrams if by rearranging X’s letters, we can get Y using all the original letters of X exactly once.
Given a string, find first k non-repeating characters in it by doing only a single traversal of it.