Tip 1: Be clear about the basics of data structures and learn how to build the logic for a problem. Then, try to find the solution, starting from a brute force approach and progressing to an optimized solution.
Tip 2: As a fresher, it's important to have at least two good projects. You should definitely have clarity about your projects and be able to answer questions about them during the interview.
Tip 3: The number of DSA questions you solve doesn’t matter; what matters your understanding of is how to approach a certain question, which data structures to use, and how to find a better solution.
Tip 1: Have a good understanding of at least one programming language.
Tip 2: Have at least two projects about which you possess thorough knowledge.
It was conducted during the evening shift. The interview went really smoothly.
Step 1: Initialize the ans variable to 0.
Step 2: Initialize the currentSum of our initially empty window to 0.
Step 3: Initialize the pointers of our sliding window: begin = 0, end = 0.
Step 4: Instantiate the hash map numToIndex to store the index of the last occurrence of numbers seen so far in nums.
Step 5: Start the sliding window process. While end < nums.length:
Step 6: Get the current number we are adding to our window: currNum = nums[end].
Step 7: Get its last occurrence: lastOccurrence = numToIndex.getOrDefault(currNum, -1).
Step 8: While the window still contains this current number (begin <= lastOccurrence) or our window size is too large (end - begin + 1 > k):
Step 10: Update the current sum: currentSum += nums[end].
Step 11: If our window is of size k, update ans if currentSum is larger: ans = max(ans, currentSum).
Step 12: Increment end to add the next element for the next iteration: end++.
Step 13: Return ans.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How many times will the loop execute? for(int i = 0; i < 5; i++)