# Coding Interviews: Simple Data Structures

Given the head of a singly linked list, reverse the list, and return *the reversed list*.

Given the head of a linked list, remove the nth node from the end of the list and return its head.

You are given the heads of two sorted linked lists list1 and list2.

Merge the two lists into one **sorted** list. The list should be made by splicing together the nodes of the first two lists.

Return *the head of the merged linked list*.

Given an integer array nums where the elements are sorted in **ascending order**, convert *it to a ***height-balanced ***binary search tree*.

Given the root of a binary tree, return *the postorder traversal of its nodes' values*.

Given the root of a binary tree, invert the tree, and return *its root*.

You are given two binary trees root1 and root2.

Imagine the trees are layed ontop of each other. The merged nodes will have the sum of the values of the original nodes. If one or the other is null, treat the null node as if it had a value of 0.

Return *the merged tree*.

Given head, the head of a linked list, determine if the linked list has a cycle in it.

There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. **Note that ****pos**** is not passed as a parameter**.

Return true* if there is a cycle in the linked list*. Otherwise, return false.

You are given two **non-empty** linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.

Given the roots of two binary trees p and q, write a function to check if they are the same or not.

Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.

Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise.

A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The tree tree could also be considered as a subtree of itself.

Given the root of a binary tree, return *the inorder traversal of its nodes' values*.

Given the root of a binary tree, *check whether it is a mirror of itself* (i.e., symmetric around its center).

Given a binary tree, determine if it is **height-balanced**.

Given the root of a binary tree, return *the length of the ***diameter*** of the tree*.

The **diameter** of a binary tree is the **length** of the longest path between any two nodes in a tree. This path may or may not pass through the root.

The **length** of a path between two nodes is represented by the number of edges between them.

Given the head of a singly linked list, return true* if it is a palindrome or *false* otherwise*.

Given the root of a binary tree, return *its maximum depth*.

A binary tree's **maximum depth** is the number of nodes along the longest path from the root node down to the farthest leaf node.