Workday Interview Question

Given a node n on a binary tree, find the longest distance to a leaf node

Interview Answers

Anonymous

Nov 6, 2020

public int heightOfTree() { return heightUtil(getRoot()); } private int heightUtil(Node root) { if (root == null) { return -1; } int left = heightUtil(root.getLeft()); int right = heightUtil(root.getRight()); return Math.max(left, right) + 1; }

1

Anonymous

Jan 17, 2021

There's a lot of elements to typically cover in these questions, clarifications, scoping, making sure you're answering the actual question the interviewer is looking for you to answer, etc. Could be worth doing a mock interview with one of the Prepfully Workday Software Applications Engineer experts... they've worked in the role so they clearly know how to get through the interview. prepfully.com/practice-interviews