Table of Contents
Problems and Solutions
Data Structures
Array
- Find the Smallest Number
Given an array, find the smallest number in the array.
- Find Missing Numbers
In an array, 1-100 numbers are stored. One number is missing. How do you find
it?
- Find Duplicate Numbers
In an array of 1-100, exactly one number is duplicate. How do you find it?
- Compare Arrays
Given two arrays, find which number(s) is not present in the second array.
- Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
- Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
- Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
- Pascal Triangle
Given an integer x
, generate the first x
number of rows of Pascal’s triangle.
- Powerset
Given an array or set of objects, return a set of all possible subsets.
String
- Remove Character
Remove all instances of a specific character from the given String.
- String Palindrome Check
Given a String, check if the String is a valid palindrome.
- Multiply String
Given two numbers represented as strings, return multiplication of the numbers as a string. Do not use BigInteger.
- Merge and Order String Characters
Given an array of strings, return a single string containing all the characters in alphabetical order.
Stack
- Array Implementation
Includes the following methods: push(), pop(), peek(), size(), isEmpty() and isFull().
- Balanced Parentheses
Given a String, determine if the parentheses have pairs and are in order.
Linked List
Tree
- Binary Tree
Includes methods for inserting, removing, traversing (in order, pre-order, post-order)
and searching (find by value, smallest, nth smallest element).
Algorithms
Sort
Search
Math
- Is Prime
Given an integer, determine whether the integer is a prime number.
- Fibonacci Sequence
Given an integer x
, print x
number of elements in the sequence.
Given an integer, return the value of the element in that position of the sequence.
- Integer Palindrome Check
Given an integer, determine whether the integer is a valid palindrome.
- Prime Sum
Given an even number (greater than 2), return two prime numbers whose sum will be equal to given number.
- Find Factors
Return a list of all factors of a given integer.