Tag: recursion
You are given an immutable linked list, print out all values of each node in reverse with the help of the following interface: ImmutableListNode: An interface of immutable linked …
Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->->->2->1->NULL Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? Reversing a linked …
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the depth of the two …
A Stepping Number is an integer such that all of its adjacent digits have an absolute difference of exactly 1. For example, 321 is a Stepping Number while 421 …
Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate …