newszine

Positions of Large Groups | String Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a string S of lowercase letters, these letters form consecutive groups of the same character. For example, a string like S = “abbcccczyyy” has the groups “a”, “bb”, “cccc”, “z” and “yyy”. If a group has 3 or more characters, then this group is called as large group. Write a program to find Read More

Single Row Keyboard | String Problem | LeetCode 1165

4 years ago Lalit Bhagtani 0
Problem Statement There is a special keyboard with all keys in a single row. You have given a string keyboard of length 26 indicating the layout of the keyboard (indexed from 0 to 25), initially your finger is at index 0. To type a character, you have to move your finger to the index of Read More

Alphabet Board Path | String Problem | LeetCode 1138

4 years ago Lalit Bhagtani 0
Problem Statement You have given an alphabet board, board = , as shown in the diagram below. On an alphabet board, you start at a position (0, 0), corresponding to character board and you can take only the following moves: ‘U’ moves your position up one row, if the position Read More

Convert Roman Number to Decimal | String Problem

4 years ago Lalit Bhagtani 0
Problem Statement Roman numerals are represented by seven different symbols: I, V, X, L, C, D, and M. Symbol  --> Value I  --> 1 V  --> 5 X  --> 10 L  --> 50 C  --> 100 D  --> 500 M  --> 1000 For example, Two is written as II in Roman numeral, just two one’s added Read More

Ransom Note | String Problem | LeetCode 383

4 years ago Lalit Bhagtani 0
Problem Statement You have given a ransom note string and a string consists of all of the letters of the magazine. Write a program to find out if a ransom note can be constructed from the magazine. Each letter in the magazine string can only be used once in the ransom note. Note:- Both strings Read More

Rotated Digits | String Problem | LeetCode 788

4 years ago Lalit Bhagtani 0
Problem Statement A number N is a good number if after rotating each digit individually by 180 degrees, we get a valid number which is different from N. A number is valid if each digit remains a digit after rotation. following is the list of digits and its rotated state. 0  --> 0 1  -->  Read More

Robot Return to Origin | String Problem | LeetCode 657

4 years ago Lalit Bhagtani 0
Problem Statement There is a robot starting at position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, check if the robot ends up at the origin (0, 0) after it completes its all the moves. The sequence of moves is represented by a string, and the character at i Read More

Split String into Balanced Strings | String Problem

4 years ago Lalit Bhagtani 0
Problem Statement You have given a balanced string S, split it into the maximum amount of balanced strings. Note :- Balanced strings are the strings, which have an equal number of “A” and “B” characters. Example  Input :- S = "ABAABBABAB" Output :- 4 Input :- S = "ABAABBABABBBAAAB" Output :- 6 Solution Traverse the Read More

Group Anagrams | String Problem | LeetCode 49

4 years ago Lalit Bhagtani 1
Problem Statement You have given an array of strings, write a program to group all the anagrams. Note :- Strings consists of only lowercase English letters. Example  Input :- Output :- , , ] Input :- , Output :- , , Read More