Toggle navigation
Marcy Blog
Home
About
Prepare Code Interview
Tags
Marcy Blog
Failed to be a geek
Problem: Max Stack
Question Design a max stack that supports push, pop, top, peekMax and popMax. push(x) – Push element x onto stack. pop() – Remove the element on top of the stack and return it. top() – Get...
Problem: Implement Queue using Stacks
Question Implement the following operations of a queue using stacks. push(x) – Push element x to the back of queue. pop() – Removes the element from in front of queue. peek() – Get the fro...
Problem: Robot Room Cleaner
Question Given a robot cleaner in a room modeled as a grid. Each cell in the grid can be empty or blocked. The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each tur...
Problem: Sudoku Solver
Question Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character ‘.’. You may assume that there will be only one unique solution. Solutio...
Problem: Number of Islands II
Question A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand operation which turns the water at position (row, col) into a land. Given a list of positio...
Problem: Number of Connected Components in an Undirected Graph
Question Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph. E...
Problem: Matchsticks to Square
Question Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchstic...
Problem: Graph Valid Tree
Question Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. Example 1: Input: n...
Problem: All Nodes Distance K in Binary Tree
Question We are given a binary tree (with root node root), a target node, and an integer value K. Return a list of the values of all nodes that have a distance K from the target node. The answer...
Problem: Restore IP Addresses
Question Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Input: "25525511135" Output: ["255.255.11.135", "255.255.111.35"...
← Newer Posts
Older Posts →
FEATURED TAGS
Life
Ruby on Rails
Project Management
Agile
Ruby
OOP
Design Patterns
ABOUT ME
To be a top coder, a proud father, and a better man