Status: New grad, MS CS University of Maryland, Baltimore County
Position: Software Engineer, New Grad
Location: Multiple Locations
Coding Round
Technical Phone Screen - I
Experience
The coding round was easy, Leetcode Explore with Premium helped mostly.
The interviewer for the phone round was very nice and made sure I was at ease. She was constantly discussing my approach. The only hiccup in the interview was for the Path sum problem, where the interviewer said my code won't work, and made me change it. Later, I checked out both codes on Leetcode, mine ran faster (1ms) than the one she suggested (3ms). Otherwise, the experience was pleasant.
\\ My code :
class Solution {
public static boolean subfunc(TreeNode root, int sum) {
if(root == null) {
return false;
}
if(root.left==null && root.right==null) {
return root.val == sum;
}
int remainingSum = sum - root.val;
return subfunc(root.left,remainingSum)|| subfunc(root.right,remainingSum);
}
public boolean hasPathSum(TreeNode root, int sum) {
return subfunc(root,sum);
}
}
\\---------------------------------------------------
\\Her code :
class Solution {
boolean subfunc(TreeNode root, int sum) {
if(root == null) {
return false;
}
if(root.left==null && root.right==null) {
return root.val == sum;
}
int remainingSum = sum - root.val;
boolean temp = false;
temp = temp || subfunc(root.left,remainingSum);
temp = temp || subfunc(root.right,remainingSum);
return temp;
}
public boolean hasPathSum(TreeNode root, int sum) {
return subfunc(root,sum);
}
}