07 2017 档案

摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array nums = [1,1,1,2,2,3], Your function sho 阅读全文
posted @ 2017-07-30 05:33 Jimmy_Cheng 阅读(169) 评论(0) 推荐(0)
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文
posted @ 2017-07-28 04:30 Jimmy_Cheng 阅读(2288) 评论(0) 推荐(0)
摘要:Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example,If nums =  阅读全文
posted @ 2017-07-25 10:56 Jimmy_Cheng 阅读(274) 评论(0) 推荐(0)
摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, 阅读全文
posted @ 2017-07-25 06:04 Jimmy_Cheng 阅读(2664) 评论(0) 推荐(0)
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2017-07-24 09:26 Jimmy_Cheng 阅读(284) 评论(0) 推荐(0)
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra sp 阅读全文
posted @ 2017-07-24 06:05 Jimmy_Cheng 阅读(321) 评论(0) 推荐(0)
摘要:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leadin 阅读全文
posted @ 2017-07-23 03:04 Jimmy_Cheng 阅读(735) 评论(0) 推荐(0)
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2017-07-23 02:44 Jimmy_Cheng 阅读(294) 评论(0) 推荐(0)
摘要:Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space 阅读全文
posted @ 2017-07-22 07:35 Jimmy_Cheng 阅读(1850) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2017-07-21 06:35 Jimmy_Cheng 阅读(361) 评论(0) 推荐(0)
摘要:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3, You should return the followi 阅读全文
posted @ 2017-07-21 04:20 Jimmy_Cheng 阅读(1987) 评论(0) 推荐(0)
摘要:Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]. 题目标签:Array 阅读全文
posted @ 2017-07-21 03:10 Jimmy_Cheng 阅读(2667) 评论(0) 推荐(0)
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2017-07-20 05:47 Jimmy_Cheng 阅读(411) 评论(0) 推荐(0)
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix: You s 阅读全文
posted @ 2017-07-19 10:59 Jimmy_Cheng 阅读(317) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2, 阅读全文
posted @ 2017-07-19 09:34 Jimmy_Cheng 阅读(5361) 评论(0) 推荐(0)
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place? 题目标签:Array 这 阅读全文
posted @ 2017-07-18 11:36 Jimmy_Cheng 阅读(1882) 评论(0) 推荐(0)
摘要:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each num 阅读全文
posted @ 2017-07-18 01:01 Jimmy_Cheng 阅读(288) 评论(0) 推荐(0)
摘要:Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums 阅读全文
posted @ 2017-07-18 00:00 Jimmy_Cheng 阅读(4399) 评论(1) 推荐(0)
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2017-07-15 04:35 Jimmy_Cheng 阅读(175) 评论(0) 推荐(0)
摘要:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexi 阅读全文
posted @ 2017-07-15 03:54 Jimmy_Cheng 阅读(289) 评论(0) 推荐(0)
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You a 阅读全文
posted @ 2017-07-14 23:43 Jimmy_Cheng 阅读(260) 评论(0) 推荐(0)
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文
posted @ 2017-07-14 11:25 Jimmy_Cheng 阅读(269) 评论(0) 推荐(0)
摘要:Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-07-14 00:52 Jimmy_Cheng 阅读(215) 评论(0) 推荐(0)
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2017-07-14 00:28 Jimmy_Cheng 阅读(296) 评论(0) 推荐(0)
摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic 阅读全文
posted @ 2017-07-13 23:37 Jimmy_Cheng 阅读(350) 评论(0) 推荐(0)
摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文
posted @ 2017-07-13 11:24 Jimmy_Cheng 阅读(4966) 评论(1) 推荐(2)
摘要:Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of 阅读全文
posted @ 2017-07-12 07:47 Jimmy_Cheng 阅读(335) 评论(0) 推荐(0)
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo 阅读全文
posted @ 2017-07-11 21:27 Jimmy_Cheng 阅读(305) 评论(0) 推荐(0)
摘要:Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2017-07-11 20:24 Jimmy_Cheng 阅读(298) 评论(0) 推荐(0)
摘要:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston 阅读全文
posted @ 2017-07-11 07:15 Jimmy_Cheng 阅读(318) 评论(0) 推荐(0)
摘要:Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: Input: 1 \ 3 / 2 O 阅读全文
posted @ 2017-07-11 05:06 Jimmy_Cheng 阅读(555) 评论(0) 推荐(0)
摘要:Design and implement a data structure for a compressed string iterator. It should support the following operations: next and hasNext. The given compre 阅读全文
posted @ 2017-07-10 23:31 Jimmy_Cheng 阅读(546) 评论(0) 推荐(0)
摘要:Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example, MovingAverage m = new M 阅读全文
posted @ 2017-07-10 05:34 Jimmy_Cheng 阅读(679) 评论(0) 推荐(0)
摘要:Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- w 阅读全文
posted @ 2017-07-10 01:27 Jimmy_Cheng 阅读(322) 评论(0) 推荐(0)
摘要:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all 阅读全文
posted @ 2017-07-08 05:37 Jimmy_Cheng 阅读(325) 评论(0) 推荐(0)
摘要:Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is define 阅读全文
posted @ 2017-07-08 03:07 Jimmy_Cheng 阅读(541) 评论(0) 推荐(0)
摘要:You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need t 阅读全文
posted @ 2017-07-07 00:59 Jimmy_Cheng 阅读(300) 评论(0) 推荐(0)
摘要:Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 1 阅读全文
posted @ 2017-07-06 23:51 Jimmy_Cheng 阅读(283) 评论(0) 推荐(0)
摘要:Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 题目标签:Tree 这道题目给了我们一个二叉树, 阅读全文
posted @ 2017-07-05 19:33 Jimmy_Cheng 阅读(209) 评论(0) 推荐(0)
摘要:因为在开始写这个博客之前,已经刷了100题了,所以现在还是有很多题目没有加进来,为了方便查找哪些没加进来,先列一个表可以比较清楚的查看,也方便给大家查找。如果有哪些题目的链接有错误,请大家留言和谅解,链多了会眼花。 # Title Category Difficulty 1528 Shuffle S 阅读全文
posted @ 2017-07-05 06:47 Jimmy_Cheng 阅读(2505) 评论(0) 推荐(0)
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of 阅读全文
posted @ 2017-07-05 04:14 Jimmy_Cheng 阅读(2106) 评论(0) 推荐(1)
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文
posted @ 2017-07-05 01:02 Jimmy_Cheng 阅读(281) 评论(0) 推荐(0)
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia:This problem was inspired by this original tweet by Max Howell: Go 阅读全文
posted @ 2017-07-04 23:18 Jimmy_Cheng 阅读(219) 评论(0) 推荐(0)
摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. 阅读全文
posted @ 2017-07-04 06:42 Jimmy_Cheng 阅读(655) 评论(0) 推荐(0)
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. F 阅读全文
posted @ 2017-07-04 06:17 Jimmy_Cheng 阅读(287) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2017-07-04 05:28 Jimmy_Cheng 阅读(303) 评论(0) 推荐(0)
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
posted @ 2017-07-04 00:36 Jimmy_Cheng 阅读(362) 评论(0) 推荐(0)
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目标签:Tree 这道题目给了我们一个有序数组,从小到大。让我们把这个数组转化为height bala 阅读全文
posted @ 2017-07-03 02:41 Jimmy_Cheng 阅读(404) 评论(0) 推荐(0)
摘要:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2017-07-03 00:41 Jimmy_Cheng 阅读(428) 评论(0) 推荐(0)
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2017-07-02 06:32 Jimmy_Cheng 阅读(310) 评论(0) 推荐(0)
摘要:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-07-02 00:43 Jimmy_Cheng 阅读(1410) 评论(0) 推荐(0)
摘要:Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2017-07-01 21:49 Jimmy_Cheng 阅读(415) 评论(0) 推荐(0)
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath betwee 阅读全文
posted @ 2017-07-01 08:35 Jimmy_Cheng 阅读(839) 评论(0) 推荐(0)
摘要:Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt 阅读全文
posted @ 2017-07-01 03:50 Jimmy_Cheng 阅读(1258) 评论(0) 推荐(0)