Meta Interview Question

(Phone screen questions) 1. For a given binary tree, print paths from root to all leaf nodes, one path per line. 2. Given a sequence of positive integers "seq" and an integer "total", return whether a contiguous sequence of "seq" sums up to "total". (Onsite interview questions are covered by NDA therefore can't post, but it can be said that the knowledge of data structures and handling edge cases are important for the coding interviews)

Interview Answers

Anonymous

Apr 1, 2019

1. Use recursive function from the root of binary tree (print at leaf, else recurse to left and right) 2. Use hashset/hashmap to record running sum of "seq", and check if there are two elements having difference of "total"

4

Anonymous

Jul 19, 2019

Yes, the sliding window works just as well - it's just that I used hashmap at that time (more straightforward as I used Java for that interview)

1

Anonymous

Jul 24, 2019

Sliding window works only with non negative values

Anonymous

Jul 24, 2019

the question says "positive integer" therefore it works - otherwise the hashmap method is still better as there was a short question at the end about "how would your solution handles negative integers on the sequence" (and how to change/optimize the solution if it doesn't do well)

Anonymous

Jul 19, 2019

2. No, you don't need any hashmap. Just use a sliding window...