Tip 1: Focus on strong fundamentals and revise core concepts regularly instead of solving random questions only.
Tip 2: Practice coding problems consistently and analyze mistakes to avoid repeating them.
Tip 3: Work on real projects or improve existing ones to better understand how concepts are used in production.
Tip 1: Highlight real projects with clear explanations of your role, tech stack, and impact.
Tip 2: Keep the resume concise and focused on relevant skills instead of listing everything.
Tip 3: Mention problem-solving experience and production work, not just academic projects.
Timing: 1 Dec 2025 • 10:30 AM – 12:30 PM


Input: ‘n’ = 7 ‘k’ = 3
‘a’ = [1, 2, 3, 1, 1, 1, 1]
Output: 3
Explanation: Subarrays whose sum = ‘3’ are:
[1, 2], [3], [1, 1, 1] and [1, 1, 1]
Here, the length of the longest subarray is 3, which is our final answer.
Step 1: First, I considered checking all possible subarrays using two loops and calculating their sums to see if any equaled K. This approach works but has a time complexity of O(n²), which is not efficient for large inputs.
Step 2: Then, I recalled that this can be optimized using prefix sums and a hash map. I calculated cumulative sums while traversing the array and stored the first occurrence of each prefix sum.
Step 3: At each index, I checked whether (currentSum − K) already existed in the map. If it did, it meant that the subarray between those two indices had a sum of K, and I updated the maximum length accordingly.
Step 4: This reduced the time complexity to O(n) with extra space for the hash map, which the interviewer accepted as the optimal solution.



Step 1: First, I understood that this problem is related to the sliding window technique since we are dealing with subarrays and a condition on distinct elements.
Step 2: I started implementing a sliding window using two pointers and a frequency map to track how many times each element appears in the current window.
Step 3: While expanding the right pointer, I updated the sum and the frequency map. When the number of distinct elements exceeded K, I attempted to shrink the window from the left.
Step 4: I was able to maintain the window and the distinct count, but I faced difficulty in correctly updating the maximum sum in some edge cases, especially when duplicate elements were involved and when shrinking the window multiple times was required.
Step 5: Due to time constraints, I could not fully debug and finalize the optimal solution. However, the interviewer discussed the correct approach and explained how careful window adjustments and sum updates would solve the issue efficiently.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is the purpose of the return keyword?