随笔分类 -  Great Questions

摘要:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled 阅读全文
posted @ 2016-12-13 08:38 北叶青藤 阅读(195) 评论(0) 推荐(0)
摘要:Design a data structure that supports all following operations in O(1) time. insert(val): Inserts an item val to the set if not already present.remove 阅读全文
posted @ 2016-12-08 10:51 北叶青藤 阅读(254) 评论(0) 推荐(0)
摘要:Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algor 阅读全文
posted @ 2016-11-17 14:17 北叶青藤 阅读(282) 评论(0) 推荐(0)
摘要:Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place. You can think of the left and right pointers as synonymous to the prede 阅读全文
posted @ 2016-11-11 07:54 北叶青藤 阅读(587) 评论(0) 推荐(0)
摘要:A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i 阅读全文
posted @ 2016-11-04 22:09 北叶青藤 阅读(452) 评论(0) 推荐(0)
摘要:Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right, up or do 阅读全文
posted @ 2016-10-29 06:27 北叶青藤 阅读(244) 评论(0) 推荐(0)
摘要:Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may cont 阅读全文
posted @ 2016-10-23 10:06 北叶青藤 阅读(271) 评论(0) 推荐(0)
摘要:Closest Binary Search Tree Value Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Not 阅读全文
posted @ 2016-10-18 11:24 北叶青藤 阅读(232) 评论(0) 推荐(0)
摘要:There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have t 阅读全文
posted @ 2016-10-11 11:48 北叶青藤 阅读(390) 评论(0) 推荐(0)
摘要:You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle. 0 - A gate. INF - Infinity means an empty room 阅读全文
posted @ 2016-10-10 07:37 北叶青藤 阅读(194) 评论(0) 推荐(0)
摘要:Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it. Not 阅读全文
posted @ 2016-08-09 10:18 北叶青藤 阅读(271) 评论(0) 推荐(0)
摘要:For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible roote 阅读全文
posted @ 2016-08-09 09:17 北叶青藤 阅读(220) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2016-08-09 03:59 北叶青藤 阅读(293) 评论(0) 推荐(0)
摘要:According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John 阅读全文
posted @ 2016-08-08 22:13 北叶青藤 阅读(402) 评论(0) 推荐(0)
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating 阅读全文
posted @ 2016-08-08 11:39 北叶青藤 阅读(331) 评论(0) 推荐(0)
摘要:The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number of characters read. For example, it retu 阅读全文
posted @ 2016-08-08 10:11 北叶青藤 阅读(267) 评论(0) 推荐(0)
摘要:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a conca 阅读全文
posted @ 2016-08-08 02:47 北叶青藤 阅读(214) 评论(0) 推荐(0)
摘要:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. For example:Given n = 13,Return 阅读全文
posted @ 2016-08-07 11:48 北叶青藤 阅读(233) 评论(0) 推荐(0)
摘要:Given a binary search tree and a node in it, find the in-order successor of that node in the BST. 1 public class Solution { 2 3 public TreeNode inorde 阅读全文
posted @ 2016-08-07 00:05 北叶青藤 阅读(204) 评论(0) 推荐(0)
摘要:Range Sum Query 2D - Mutable Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) 阅读全文
posted @ 2016-08-06 23:13 北叶青藤 阅读(222) 评论(0) 推荐(0)