Showing 20 of 107 from page 1

## [Solution] Matrix-num-paths | Facebook Interview Question

This problem was asked by Facebook. There is an N by M matrix of zeroes. Given N and M, write a function to count the number of ways of starting at the top left corner and getting to the bottom right

## [Solution] Division-without-divide | Interview Question

Implement division of two positive integers without using the division, multiplication, or modulus operators. Return the quotient as an integer, ignoring the remainder. Idea behind the solution The id

## [Solution] Words-per-line | Amazon Interview Question

This problem was asked by Amazon. Given a string s and an integer k, break up the string into multiple lines such that each line has a length of k or less. You must break it up so that words don t bre

## [Solution] Implementing an LRU (Least Recently Used) cache | Google Interview Question

This problem was asked by Google. Implement an LRU Least Recently Used cache. It should be able to be initialized with a cache size n, and contain the following methods set key, value sets key to valu

## Solution for Knights Tour problem | Google Interview Question

This problem was asked by Google. A knight s tour is a sequence of moves by a knight on a chessboard such that all squares are visited once. Given N, write a function to return the number of knight s

## [Solution] max-subarray-contiguous-sum | Twitter Interview Question

This problem was recently asked by Twitter You are given an array of integers. Find the maximum sum of all possible contiguous subarrays of the array. Example 34, 50, 42, 14, 5, 86 Given this input ar

## [Solution] read7 | Microsoft Interview Question

This problem was asked Microsoft. Using a read7  method that returns 7 characters from a file, implement readN n  which reads n characters. For example, given a file with the content “Hello world”, th

## [Solution] Finding word in the matrix | Microsoft Interview Question

This problem was asked by Microsoft. Given a 2D matrix of characters and a target word, write a function that returns whether the word can be found in the matrix by going left to right, or up to down.

## [Solution] Implement a URL shortener | Microsoft Interview Question

This problem was asked by Microsoft. Implement a URL shortener with the following methods shorten url , which shortens the url into a six character alphanumeric string, such as zLg6wl. restore short ,

## [Solution] Operation Tree | Microsoft Interview Question

This problem was asked by Microsoft. Suppose an arithmetic expression is given as a binary tree. Each leaf is an integer and each internal node is one of + , − , ∗ , or . Given the root to such a tree

## [Solution] Finding perfect number (digits-sum-10) | Microsoft Interview Question

This problem was asked by Microsoft. A number is considered perfect if its digits sum up to exactly 10. Given a positive integer n, return the n th perfect number. For example, given 1, you should ret

## [Solution] Finding deepest node of a binary tree | Google Interview Question

This problem was asked by Google. Given the root of a binary tree, return a deepest node. For example, in the following tree, return d. a b c d Idea behind the solution For this problem we just need t

## [Solution] constant-time-sort | Google Interview Question

This problem was recently asked by Google Given a list of numbers with only 3 unique numbers  1, 2, 3 , sort the list in O n  time. Example 1 Input   3, 3, 2, 1, 3, 2, 1  Output   1, 1, 2, 2, 3, 3, 3

## [Solution] Best-Multiply-In-Array | Facebook Interview Question

This problem was asked by Facebook. Given a list of integers, return the largest product that can be made by multiplying any three integers. For example, if the list is  10, 10, 5, 2 , we should retur

This problem was asked by Facebook. Given a array of numbers representing the stock prices of a company in chronological order, write a function that calculates the maximum profit you could have made

## [Solution] Espiral matrix print | Amazon Interview Question

Here s your coding interview problem for today. This problem was asked by Amazon. Given a N by M matrix of numbers, print out the matrix in a clockwise spiral. For example, given the following matrix

## Flipping An Image - Javascript Solution

Flipping An Image is an example of Array problems In this post we will see how we can solve it in Javascript Problem Description Given a binary matrix A we want to flip the image horizontally then inv

## First Missing Positive - Javascript Solution

First Missing Positive is an example of Array problems In this post we will see how we can solve it in Javascript Problem Description Given an unsorted integer array find the smallest missing positive

## Find The Celebrity - Javascript Solution

Find The Celebrity is an example of Array problems In this post we will see how we can solve it in Javascript Problem Description Suppose you are at a party with n people labeled from 0 to n 1 and amo

## Find Peak Element - Javascript Solution

Find Peak Element is an example of Array problems In this post we will see how we can solve it in Javascript Problem Description A peak element is an element that is greater than its neighbors Given a