# Category: Strings

## All N Length Strings from Given String of Length K

Objec­tive: Print All N Length Strings from Given String of Length K where char­ac­ters can appear mul­ti­ple time. Exam­ple: String k = “ALGO” N=2 Result: AA LA GA OA AL LL GL OL AG LG

## Print All N Length Strings from Given Number K

Objec­tive: Given Num­ber K, Print all the strings of N length. Exam­ple: N = 2, K = 3 [1, 1] [2, 1] [3, 1] [1, 2] [2, 2] [3, 2] [1, 3] [2, 3]…

## The Word Break Problem

Objec­tive : Given an string and a dic­tio­nary of words, find out if the input string can be bro­ken into a space-separated sequence of one or more dic­tio­nary words. Exam­ple: dic­tio­nary = [“I” , “have”,…

## Find All the Well Ordered Permutations of a Given String.

Objec­tive: Write an algo­rithm to Print All the Well Ordered Per­mu­ta­tions of a Given String. What is Well Ordered String: When all the alpha­bets in a string occur in the increas­ing order irre­spec­tive of…

## Print All Possible Valid Combinations Of Parenthesis of Given ‘N’

Objec­tive: — Given “n”, gen­er­ate all valid paren­the­sis strings of length “2n”. Exam­ple: Given n=2 Out­put: (()) ()() Approach:

## Print All The Permutations Of a String

Objec­tive: Given a String, print all the per­mu­ta­tions of it. Input: A String Out­put: Print all the per­mu­ta­tions of a string Exam­ple: Input : abc Out­put: abc acb bac bca cba cab Approach:

## Check if one string is Rotation of another string

Objec­tive: Write an algo­rithm to check if one string is Rota­tion of another string. This ques­tion has been asked in the Ama­zon inter­view. Exam­ple: Input Strings : ‘sum­it­jain’ and ‘tjain­sumi’ Out­put : true Input…

## String Compression using count of repeated characters — Run Length Encoding

Objec­tive: Write an algo­rithm to com­press the given string by using the count of repeated char­ac­ters and if new com­pressed string length is not smaller than the orig­i­nal string then return the orig­i­nal string.…

## Replace all spaces in a String with ‘%20′

Objec­tive: Write an algo­rithm to replace all spaces in a given string with ‘%20′. You can con­sider that string has enough space at the end of the string to hold the extra char­ac­ters. Input:…

## Find Whether Two Strings are Permutation of each other

Objec­tive: Given Two Strings, check whether one string is per­mu­ta­tion of other Input: Two Strings Out­put: True or false based on whether strings are per­mu­ta­tion of other or not. Exam­ple: “sumit” and “tiums” are per­mu­ta­tions of…

## Find The Longest Sequence Of Prefix Shared By All The Words In A String

Objec­tive: Write an algo­rithm to find The Longest Sequence Of Pre­fix Shared By All The Words In A String. This inter­est­ing prob­lem was asked in the Google inter­view for soft­ware engi­neer. This prob­lem is…

## Check If String has All Unique Characters

Objec­tive: Write an algo­rithm to find out whether in a given string con­tains all the unique char­ac­ters. This ques­tion has been asked in the Ama­zon and Microsoft inter­views. Input:  A String Out­put: True or…

## Find Whether Given Sequence of parentheses are well formed.

Objec­tive: You have been asked to Write an algo­rithm to find Whether Given the Sequence of paren­the­ses are well formed. This ques­tion was asked in the Ama­zon Inter­view. Input: A String con­tains a sequence…