An exposition of coding problems and solutions. For each problem listed here, you can follow the link to find my solutions. Credit due to Leet code, Code Wars, and Cracking the Coding Interview for providing great algorithms to work through.
"Given a binary tree, return the level order traversal of its nodes' values."
"Given an array where elements are sorted in ascending order, convert it to a height balanced BST."
"Given a binary tree and two unique values, check if two nodes with those values are cousins (same level with different parents)."
"Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST."
"Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants."
"Given a binary tree return the tilt of the tree, which is the absolute value of the difference between left and right values."
"Given a binary tree, determine if it is height-balanced, where the left and right subtrees of every node differ in height by no more than 1."
"Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center)."
Write a function that solves the Towers of Hanoi problem using three stacks.
Create a Stack class which also has a function min that returns the minimum element. Functions push, pop, and min should all operate in O(1) time.
Write a function that add two linked lists together, where each node contains a single digit stored in reverse order.
"Given a linked list, determine if it has a cycle in it."
"Reverse a singly linked list."
"Find the midpoint of a singly linked list."
"Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x."
"Implement an algorithm to find the kth to last element of a singly linked list."
"Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node."
"Write code to remove duplicated from an unsorted, singly linked list."
"Determine if a 9x9 Sudoku board is valid."
"Given two strings, write a mentod to decide if one is a permutation of the other."
"Given an array of integers, return indices of the two numbers such that they add up to a specific target."
"Implement a method to perform basic string compression using the counts of repeated characters."
"Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?"
"A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. This is only applicable to the natural numbers."
"In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants?"