Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
Implement square root function,
sqrt(x), that returns an integer result. The algorithm should run in O(log x).
In data structure Hash, hash function is used to convert a string(or any other type) into an integer smaller than hash size and bigger or equal to zero. The objective of designing a hash function is to “hash” the key as unreasonable as possible. A good hash function can avoid collision as less as possible. A widely used hash function algorithm is using a magic number 33, consider any string as a 33 based big integer like follow:
You are climbing a stair case. It takes
n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Using O(1) time to check whether an integer n is a power of 2.
Implement an algorithm to determine if a string has all unique characters.
Write a method
anagram(s,t) to decide if two strings are anagrams. Two strings are anagrams if they have the same letters in different order.
Given an array and a value, remove all occurrences of that value in place and return the new length.
Find the nth to last element of a singly linked list.
Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the two lists and sorted in ascending order.