DoorDash | SDE | Tech Phone Interview | 2021

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2021-09-24Added By Anonymous
Source: Link
Company: DoorDash
Role: SDE
Stage: Tech Phone Interview
Year: 2021

Original Experience:
Q. Compute the total number of operations required to convert one N-ary tree to another.
class TreeNode {
 String key;
 int value;
 List<TreeNode> children;
 }
Tree-1
 a(1)
 / \
 b(2) c(3)
 / \ \
 d(4) e(5) f(6)
Tree-2
 a(1)
 \
 c(3)
 \
 f(66)
Operations: 1. b(2) was removed from Tree-1 (Count = 1) 2. Childrens of b(2) are removed, i.e. d(4) & e(5) (Count += 2) 3. f(6) was updated to f(66) in Tree-2 (Count += 1) Total Operations done (Count = 4)
Comments