I gave coderpad round for goldman sachs on october'20, 2 questions were asked
Time duration : 1hr
Q1. Min length of subarray exceeding the target sum
example:
[1,2,3,4], target = 6,
then answer = 2 since sum of all elements of subarray [3,4] has sum>=6 and its length is minimum
and if [1,2,3,4], target = 12, then return **-1 **, since no subarray has sum>=12
Solution:
Intially I gave O(n^2) approach , then explained 2 pointer approach
However faced some issue while coding it in coderpad.
Q2.optimal path to collect all rocks
Given a 2D array, with arr[i][j] representing the number of rock at that location.
Find optimal path from location A to location B in a multi dimensional array such that a person can collect maximum amount of rocks
Solution:
I used recursive approach using a list to keep track of the visited nodes.
Since I got stuck in 1st problem for 40 min, had only 20 mins to code 2nd solution, didn't complete this problem also.
I don't know whether they give some points for the approach , or they want the exact results to be returned.
Anyways good experience, and I would advise all other people to manage their time efficiently here.