[go: up one dir, main page]

0% found this document useful (0 votes)
2 views4 pages

Arrays

Arrays module important questions for students preparing

Uploaded by

girishv94498863
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Arrays

Arrays module important questions for students preparing

Uploaded by

girishv94498863
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ARRAYS & STRINGS

BY SPOORTHI
1. For compressing a string, if result length is not smaller, return?
A) Original string
B) Compressed always
C) Null
D) Length only

2. Kadane’s Algorithm helps to find?


A) Pivot index
B) Min subarray

C) Max subarray sum


D) Product subarray

3. Compress 'aabcccccaaa' into?


A) abc5a3
B) a2bc5a3
C) a2b1c5a3
D) aabcccccaaa

4. Sliding window max for [1,3,-1,-3,5,3,6,7], k=3


A) [3, 3, 5, 5, 6, 7]
B) [1, 3, -1, -3]
C) [1, 1, 1, 1]
D) [7, 6, 5, 3]

5. Find missing number in range 0 to n (length = n)?


A) XOR or Summation formula
B) HashMap
C) Stack
D) Sorting

6. Space complexity of Boyer-Moore Majority Algorithm?


A) O(n)
B) O(1)
C) O(log n)
D) O(n log n)

7. How many passes required in Dutch National Flag algorithm?


A) One
B) Single pass (O(n))
C) Two
D) Depends on input

8. Finding all pairs in array with sum = target efficiently?


A) Two loops
B) Hash Map
C) Sorting only
D) Binary Search

9. Finding smallest subarray with sum ≥ target?


A) Two Pointers
ARRAYS & STRINGS
BY SPOORTHI
B) Sliding Window
C) Sorting
D) Stack

10. Kadane’s Algorithm fails for which of the following?


A) Empty arrays
B) All negative elements (needs slight modification)
C) Arrays with duplicates
D) Sorted arrays

11. Maximum product subarray technique?


A) BFS
B) Track max & min at each position
C) Divide and conquer
D) Prefix sums

12. efficient approach for Two Sum?


A) Brute force
B) Sorting
C) Hash Map
D) Binary Search
13. In grouping anagrams, key used in hashmap is:
A) Frequency map
B) Sorted version of word
C) Index of word
D) Length of word

14. Dutch National Flag problem idea?


A) Merge Sort
B) Three pointers
C) Insertion sort
D) Two stacks

15. Algorithm for majority element (>n/2 times)?


A) Binary Search
B) Kadane's
C) Boyer-Moore
D) Merge Sort

16. Technique for longest substring without repeating chars?


A) Stack
B) Sliding Window
C) Recursion
D) Heap

17. Group anagrams efficiently using?


A) Bubble Sort
B) HashMap of sorted
C) Brute-force
D) Tree
ARRAYS & STRINGS
BY SPOORTHI
18. Check if two strings are rotations?
A) Reverse and compare
B) Concatenate & substring
C) Sort and compare
D) Count chars

19. Best time complexity for finding Two Sum?


A) O(n²)
B) O(n)
C) O(n log n)
D) O(log n)

20. Kadane’s Algorithm ignores which elements while traversing?


A) Positive numbers
B) Negative prefix sums
C) Zeroes
D) Large numbers

21. To track repeating characters in sliding window, we use?


A) Queue
B) HashSet
C) Stack
D) Heap

22. Group anagrams using sorted strings in HashMap. Why?


A) Easy to implement
B) Sorted strings are identical for anagrams
C) Uses less memory
D) Faster than hashing

23. Check string rotation: "abcd" and "cdab" -> True or False?
A) True
B) False
C) Depends
D) Only works for palindromes

24. Data structure to solve Sliding Window Maximum efficiently?


A) Stack
B) Heap
C) Deque (Double-ended queue)
D) Set

25. Minimum Window Substring problem uses which technique?


A) Sliding Window
B) Recursion
C) BFS
D) Greedy

26. Two arrays: find intersection efficiently?


A) Brute-force
B) HashMap / HashSet
ARRAYS & STRINGS
BY SPOORTHI
C) Merge Sort
D) Recursion

27. Longest Palindromic Substring technique?


A) Expand Around Center
B) Binary Search
C) Recursion only
D) KMP Algorithm

28. When using sliding window, we usually need:


A) Two pointers (start, end)
B) Recursion depth
C) Extra stacks
D) Dynamic programming

29. Efficiently counting character frequency in a string?


A) HashMap
B) Stack
C) Heap
D) Recursion

30. To find repeated DNA sequences (10-letter substrings):


A) Brute force
B) HashSet for seen substrings
C) Sorting
D) Tree

You might also like