newszine

Find All Anagrams in a String | String Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given two strings S and T, find out all the start indices of S anagrams in T. Note :- Strings consists of only lowercase English letters. Example  Input :- S = "abc" T = "cbaebabacd" Output :- Input :- S = "ab" T = "abab" Output :- Read More

Valid Anagram | String Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given two strings S and T, find out if T is an anagram of S. Example  Input :- S = "anagram" T = "nagaram" Output :- true Input :- S = "sun" T = "car" Output :- false Solution This problem can be solved in following steps :- Create the character Read More

Detect Capital in String | String Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a word, find out if the usage of capital letters in the given word is correct or not. Correct Usage of capital letters are defined as:- Word contains all capital letters like, “HELLO” Word contains no capital letters like, “hello” Only the first letter of the word is a capital, Read More

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