Questions related to strings

## Find the longest substring with k unique characters in a given string

Given a string you need to print longest possible substring that has exactly M unique characters. If there are more than one substring of longest… Read More »

## Function to find Number of customers who could not get a computer

Write a function “runCustomerSimulation” that takes following two inputs a) An integer ‘n’: total number of computers in a cafe and a string: b) A… Read More »

## VMWare Interview Experience | Set 2 (On-Campus)

First round was Online Test. There were totally 32 Questions divided into 3 categories with no negative marking. 1) Aptitude & Logical Questions (10 Questions)… Read More »

## Find maximum depth of nested parenthesis in a string

We are given a string having parenthesis like below      “( ((X)) (((Y))) )” We need to find the maximum depth of balanced parenthesis, like… Read More »

## Find all distinct palindromic sub-strings of a given string

Given a string of lowercase ASCII characters, find all distinct continuous palindromic sub-strings of it. Examples: Input: str = “abaaa” Output: Below are 5 palindrome… Read More »

## Snapdeal Interview Experience | Set 8 (On Campus)

Snapdeal conducted placement drive at my campus in January last week for Software Developer. Eligibility- All CSE (no pointer criteria) Online Test- 21 (MCQ) +2… Read More »

## Factorial of a large number

Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is… Read More »

## Find if a given string can be represented from a substring by iterating the substring “n” times

Given a string ‘str’, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. Examples:… Read More »

## Amazon Interview Experience | Set 167 (SDE I for 1 year 6 months experience)

Round1: Online Coding Round There were 4 coding question. Was asked to answer 2 out of 4. 1) Given a list of N coins, their… Read More »

## Given a binary string, count number of substrings that start and end with 1.

Given a binary string, count number of substrings that start and end with 1. For example, if the input string is “00100101”, then there are… Read More »

## Print all possible strings that can be made by placing spaces

Given a string you need to print all possible strings that can be made by placing spaces (zero or one) in between them. Input: str[]… Read More »

## Manacher’s Algorithm – Linear Time Longest Palindromic Substring – Part 4

In Manacher’s Algorithm Part 1 and Part 2, we gone through some of the basics, understood LPS length array and how to calculate it efficiently… Read More »

## Longest Even Length Substring such that Sum of First and Second Half is same

Given a string ‘str’ of digits, find the length of the longest substring of ‘str’, such that the length of the substring is 2k digits… Read More »

## Manacher’s Algorithm – Linear Time Longest Palindromic Substring – Part 3

In Manacher’s Algorithm Part 1 and Part 2, we gone through some of the basics, understood LPS length array and how to calculate it efficiently… Read More »

## Manacher’s Algorithm – Linear Time Longest Palindromic Substring – Part 2

In Manacher’s Algorithm – Part 1, we gone through some of the basics and LPS length array. Here we will see how to calculate LPS… Read More »