Input: S = “Dad”
Characters “D” and “a” are present in the same row of qwerty keypad. That is second Row.
Input: S = “Mom”
Characters “M” and “o” are not present in the same row of qwerty keypad.
Approach: The idea is to store the characters of the same row of the qwerty keypad into different hash-maps to check that all the characters of the string are from the same row.
Below is the implementation of the above approach:
Time Complexity: O(N)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Mobile Numeric Keypad Problem
- Count of buttons pressed in a keypad mobile
- Convert a sentence into its equivalent mobile numeric keypad sequence
- String slicing in Python to check if a string can become empty by recursive deletion
- Check if a string can be converted to another string by replacing vowels and consonants
- Check if a string can be formed from another string by at most X circular clockwise shifts
- Check if given string is a substring of string formed by repeated concatenation of z to a
- Check if a string can become empty by recursively deleting a given sub-string
- Queries to check if string B exists as substring in string A
- Check if left and right shift of any string results into given string
- Check if a string can be obtained by rotating another string d places
- Check if any permutation of string is a K times repeated string
- Check if a string can be obtained by rotating another string 2 places
- Python | Check if a given string is binary string or not
- Check if a given string is a Reverse Bitonic String or not
- Check if a string is a scrambled form of another string
- Check if a string can be repeated to make another string
- Check if a string contains a palindromic sub-string of even length
- Check if the given string is shuffled substring of another string
- Check if a string can be formed from another string using given constraints
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : offbeat