Posts

Showing posts from February, 2016

Searching number in the circular array [reviewed]

Problem Given the circular array of sorted values, search the specified value. For example, A = { 4,5,6, 1,2,3}, target = 1; output  = true Your algorithm should be better than O(N).

Finding H-index

Problem Find h-index given array of numbers. For more information about h-index, check out the following link. https://en.wikipedia.org/wiki/H-index The idea is that you need to find the last value in the array where the value is larger than its index. For example,  Say Scientist A has 5 publications with the following citation count.   Publications = {10, 8, 5, 4, 3}. In this case, the h-index is 4 since 4 whose index is 3 is the last value which value is larger than its index.

Find Celebrity [reviewed]

Image
Question: You are given the 2x2 array showing who is following and who is followed. Example) If array[0][1] = true, this means Person 0 follows person 1. Celebrity is one that everyone follows him/her but he/she does not follow anyone. Your algorithm should print out who is celebrity, given the 2X2 Array with followee-follower relationship.

Calculating the sum of each level in the tree

Question: Given a binary tree with nodes containing integer values. Your algorithm should calculate the sum of values in each depth and returns sums. Example:           1          /   \        2     3       /  \   /  \     4   5 1    2 Output:  1, 5, 12

Anagram Problem - Grouping all anagrams [reviewed]

 Question  Given a list of strings, return a list of lists of strings that groups all anagrams.   Ex. given {trees, bike, cars, steer, arcs}   return {{cars, arcs}, {bike}, {tree, steer}}   m = # of words   n = length of longest word

Palindrome problem

Problem The palindrome problem is another classic algorithm question. Given the sentence, write the code checking if the sentence is a palindrome. Any non-alphabet characters should be ignored. Examples: A car, a man, a maraca. A dog, a plan, a canal: pagoda. A dog! A panic in a pagoda! A lad named E. Mandala A man, a plan, a canal: Panama.

Local MinMax problem [reviewed]

Image
Problem Given the list of numbers, find the local min or local max Local max or min is the number that exists between the first and last number. For example, 1 , 2 , 3 , 4 , 3 , 2  => local max exists, which is 4 1 , 2 , 3 , 4 , 5 , 6 , 7  => No local max or local min exists   5 , 4 , 3 , 2 , 1  => No local max or local min exists   9 , 8 , 7 , 6 , 5 , 6 , 7 , 8 , 9 => local min exists, which is 5. Challenging part is that your problem should run faster than O(N).

Two sum problem

Problem Given N digits, find two numbers whose sum is equal to the given number T.