Data Structures & AlgorithmsModerateFlipkart/Uber OA · placement
A fixed window of length 3 slides over s = "baacbbbcbcabab" with a character-count array. At how many starting positions is the window an anagram (permutation) of "cbb"?
- A. 3
- B. 2
- C. 4
- D. 1
Correct answer: A. 3
Compare the window's letter counts with those of "cbb" at each of the 12 positions, updating the counts in O(1) per slide. Matching windows: 3; exact copies of the pattern: only 1.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Keys are inserted into a hash table of size 10 with h(k) = k mod 10 and quadratic probing (h(k) + i²) mod 10. Which statement is correct?
- What does this loop-counting code print? (Python) python n, c = 64, 0 i = n while i > 0: for j in range(i): c += 1 i //= 2 print(c)
- A 2-D prefix-sum table answers rectangle queries in O(1). For the 4 × 4 matrix (rows separated by ';', 0-based) 4 8 2 1; 4 3 1 4; 7 6 2 4…
- Which sorting algorithms are stable in their standard array implementations: insertion sort, selection sort, merge sort, heap sort, quick…
- For each element of [23, 12, 7, 21, 25, 8, 13, 1], find the next greater element to its RIGHT (−1 if none), using a monotonic stack. What…
- Reverse the order of words, collapsing multiple spaces. What is printed? python s = " oil is data new " w = s.split() print("|" + "…