Custom Order Sorting of String | String Problem | LeetCode 791

4 years ago Lalit Bhagtani 0
Problem Statement You have given two strings CustomSorted and Test, both strings contain only lowercase characters. CustomSorted string is sorted in some custom order and does not contain any duplicates. Sort the input string Test in the same order as CustomSorted string is sorted. For example, if X occurs before Y in CustomSorted string, then Read More

Shifting Letters of a String | String Problem | LeetCode 848

4 years ago Lalit Bhagtani 2
Problem Statement You have given an input string of lowercase characters and an integer array shifts, perform the shift operation on each and every character of input string and return the modified string after all the shift operations are executed. Shift operation of a letter, results the next letter of the alphabet ( wrapping applied Read More

Reverse only Letters of a String | String Problem | LeetCode 917

4 years ago Lalit Bhagtani 0
Problem Statement You have given a String, write a program to reverse all the letters (a-z and A-Z) of the input string. Characters that are not a letter stays at their place in the string. Example  Input :- "ab-cd" Output :- "dc-ba" Input :- "sun-rise-in-the-morning" Output :- "gni-nrom-eh-tni-esirnus" Solution This problem can be solved in Read More

Count and Say | String Problem | LeetCode 38

4 years ago Lalit Bhagtani 0
Problem Statement Count and Say sequence is the sequence of integers as following :- 1   (one times 1, so next integer in sequence is 11) 11 (two times 1, so next integer in sequence is 21) 21 (one times 2 and one times 1, so next integer in sequence is 1211) 1211  You have given an Read More

Reverse Vowels of a String | String Problem | LeetCode 345

4 years ago Lalit Bhagtani 0
Problem Statement You have given a String, write a program to reverse only the vowels of an input string. Implement the problem in O(1) extra memory. Example  Input :- "hello" Output :- "holle" Input :- "morning" Output :- "mirnong" Solution This problem can be solved in following steps :- Create the character array from the Read More

First Unique Character in a String | String Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a String, find the first non-repeating character in the given String and return it’s index. Example  Input :- "hello" Output :- 0 Input :- "google" Output :- 4 Solution This problem can be solved in following steps :- Create an array of characters from the input string. Create an integer Read More

Reverse Words in a String | String Problem | LeetCode 151

4 years ago Lalit Bhagtani 0
Problem Statement You have given a String (containing multiple words), reverse the string word by word. Example  Input :- "the sky is blue" Output :- "blue is sky the" Input :- " hello world! " Output :- "world! hello" Input :- "sun rise in the morning" Output :- "morning the in rise sun" Solution This Read More