Subarrays Whose Sum Is a Power of Two
Updated
Problem statement
Return every zero-based inclusive interval [left, right] whose contiguous-subarray sum is a positive power of two.
Order the intervals by increasing left, then increasing right. Negative values may appear.
Function
powerOfTwoSubarrays(nums: int[]) → int[][]Examples
Example 1
nums = [1,1,3]return = [[0,0],[0,1],[1,1],[1,2]]The qualifying interval sums are 1, 2, 1, and 4.
Example 2
nums = [-1,3]return = [[0,1]]The full subarray sums to 2.
Constraints
0 <= nums.length <= 2000.-10^9 <= nums[i] <= 10^9.
Source note: Author-written prompt excerpt retained for source fidelity.
More Kotak Mahindra Bank Onsite Interview questions
- Longest Common PrefixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
- Best Time to Buy and Sell Stock IIONSITE INTERVIEW · Seen Nov 2026
- Maximum Non-Adjacent Coins in Two RowsONSITE INTERVIEW · Seen Oct 2026
- Search in Rotated Sorted ArrayONSITE INTERVIEW · Seen Oct 2026
- Find the Index of the First Occurrence in a StringONSITE INTERVIEW · Seen Oct 2026
- Roman to IntegerPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Remove Duplicates From Sorted Array In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Course ScheduleONSITE INTERVIEW · Seen Sep 2026
- House Robber IIONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Subarray Sum Equals KServiceNow · ONSITE INTERVIEWServiceNow interview questions
- Count Subarrays with Equal Even and Odd CountsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Range Booking TotalsGoogle · ONSITE INTERVIEWGoogle interview questions
- Product of Array Except SelfWalmart Labs · ONSITE INTERVIEW
- Maximize Compatible Car RidersUber Freight · PHONE SCREEN · ONSITE INTERVIEWUber Freight interview questions
- Count Subarrays with Sum KMakeMyTrip.com · ONSITE INTERVIEWMakeMyTrip.com interview questions
- Product Of Array Except SelfInfosys · ONSITE INTERVIEWInfosys interview questions
- Centered K-by-K Submatrix SumsCitadel · ONSITE INTERVIEWCitadel interview questions
- Farthest Affordable Shop per QueryAdobe · ONSITE INTERVIEWAdobe interview questions
- Product of Array Except SelfSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions