Apple Phone Screen

apple logo
apple
Ongoing
October 21, 20258 reads

Summary

I recently had a phone screen with Apple where I was asked to convert a sorted linked list into a balanced binary search tree.

Full Experience

During my phone screen with Apple, the interviewer presented me with a classic data structure problem. I was given a sorted linked list of integers and tasked with implementing a method to transform it into a balanced binary search tree. The problem statement included a clear example to illustrate the expected output from a given linked list input.

Interview Questions (1)

Q1
Convert Sorted Linked List to Balanced BST
Data Structures & AlgorithmsMedium

Given a sorted linked list of integers, write a method(s) to create a balanced binary search tree from the list.

Example:
1 -> 2 -> 5 -> 6 -> 8 -> 10 -> 19

Expected Output:

         6
/   
2 10 / \ /
1 5 8 19

Input : LinkedList head
Output : TreeNode root

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!