Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys
Problem: The words "listen", "silent", "enlist", "google", "gogole", "cat", "act", "tac", "dog" are grouped by anagram class (words with identical letter multisets). How many groups contain more than one word?
- A. 4
- B. 3
- C. 2
- D. 5
Correct answer: B. 3
Sort each word's letters to form a canonical key, then group by it. Grouping by length alone merges unrelated words such as 'dog' with 'cat'.
More Coding Interview Problems questions
- Problem: In the binary string "1101001110100110", what is the length of the longest contiguous substring containing equal numbers of 0s…
- Problem: For the string "abcab", count the subsequences of length 3 that are palindromes (choose 3 indices i < j < k with s[i] = s[k]; the…
- Problem: What is the minimum number of characters that must be inserted anywhere in "leetcode" to make it a palindrome?
- Problem: What is the length of the longest valid (well-formed) parentheses substring of ")()())(()" ?
- Problem: How many strings of length 8 made of matched parentheses ( and ) are valid (well-formed)?
- Problem: A robot is on a 4×4 torus (moving off one edge reappears on the opposite edge) starting at (0,0), using row, column coordinates…