Completed phone screen recently, waiting to hear back (most employees are on holiday break so turnarounds seem slower). Locations on the job posting are NYC, Seattle, Menlo Park. Phone screens are supposed to be identical between SWE and RS positions at the E4-5 level, maybe also E6.
Edit: recruiter just reached out, advancing to the next round!
Got two questions, both LC Mediums:
true if there exists a subarray that sums to k, and return false otherwise (i.e., you don't have to say how many subarrays exists, just if there is one). Otherwise unchanged, array can include negatives. Clarified that an empty array does not have a sum, so [] returns false for all k (including k=0), and that I was allowed to modify the input array.Used C, got optimal solutions to both , forgot that you could use a sorting based approach for 560 because nerves. Interviewer said using uthash.h was fine. No followup questions on either.
Interview was through coderpad, running any code was disabled (standard for all meta phone screens). Interviewer provided some test cases and I was expected to come up with some additional ones. Walked through test cases by hand.
If people are interested in code, iirc my code was something like this (it's been a little while, and I haven't tested this code so it may not run). 560 can be done in a single pass, I just didn't want to overcomplicate things.
int minInsertions(char *s){
int num_opening = 0, num_to_add = 0;
while(*s){
if(*s == '(') {
num_opening++;
} else {
if(num_opening) num_opening--;
else num_to_add++;
}
s++;
}
return num_to_add + num_opening;
}typedef struct hash {
int key;
UT_hash_handle hh;
} hash;
hash *hashtable;
bool hasSubarraySum(int *arr, int len, int k){
if(!len) return false;
int cumul_sum = 0;
for(int i=0; i<len; i++){
cumul_sum += arr[i]
if(arr[i] == k || cumul_sum == k) return true;
arr[i] = cumul_sum;
}
hashtable = NULL;
hash *tmp;
bool retval = false;
int diff;
// could definitely fold this loop into the previous loop
// I was just running out of time and wanted to be extra careful
for(int i=0; i<len; i++){
diff = k - arr[i];
HASH_FIND_INT(hashtable, &diff, tmp);
if(tmp){
retval = true;
break;
}
diff = arr[i];
HASH_FIND_INT(hashtable, &diff, tmp);
if(!tmp){
tmp = malloc(sizeof(hash));
tmp->key = diff;
HASH_ADD_INT(hashtable, key, tmp);
}
}
HASH_CLEAR(hh, hashtable);
return retval;
}