
Learn core concepts, essential formulas, and attempt practice questions designed on the latest TCS NQT testing patterns.
What is the maximum subarray sum in array: [-2, 1, -3, 4, -1, 2, 1]?
Correct Answer: A) 6
Step-by-step Solution: Subarray [4, -1, 2, 1] yields maximum sum = 4 - 1 + 2 + 1 = 6.
What does Kadane's algorithm reset current sum to if it drops below zero?
Correct Answer: A) 0
Step-by-step Solution: If the running sum becomes negative, adding it to next elements decreases their sum. Kadane's resets it to 0.
Kadane's algorithm runs in linear O(N) time complexity, whereas brute-force search takes O(N^2).