作业
文章平均质量分 60
Sealhomemull
这个作者很懒,什么都没留下…
展开
-
【Leetcode】526. Beautiful Arrangement
Description:Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith positi原创 2017-02-24 19:19:00 · 1476 阅读 · 0 评论 -
【Leetcode】486. Predict the Winner
Description:Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a pla原创 2017-05-14 22:22:27 · 216 阅读 · 0 评论 -
【Leetcode】523. Continuous Subarray Sum
Description:Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is,原创 2017-05-08 11:05:21 · 230 阅读 · 0 评论 -
【Leetcode】389. Find the Difference
Description:Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter th原创 2017-05-30 22:26:26 · 177 阅读 · 0 评论 -
【Leetcode】283. Move Zeroes
Description:Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.Example:Given nums = [0, 1, 0, 3, 12], after calling you原创 2017-06-04 23:55:16 · 168 阅读 · 0 评论 -
【Leetcode】191. Number of 1 Bits
Description:Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).Example:the 32-bit integer ’11’ has binary representation 000000原创 2017-06-05 11:36:37 · 173 阅读 · 0 评论 -
【Leetcode】5. Longest Palindromic Substring
Description:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: “bab”Explanation: “aba” is also a valid ans原创 2017-05-22 17:18:28 · 159 阅读 · 0 评论 -
【Leetcode】207. Course Schedule
Description: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 to first take course 1, which is expres原创 2017-06-19 12:46:39 · 275 阅读 · 0 评论 -
8.15 NP完全问题证明
Description:Show that the following problem is NP-complete. MAXIMUM COMMON SUBGRAPH Input: Two graphs G1=(V1,E1)G_1 = (V_1, E_1) and G2=(V2,E2)G_2 = (V_2, E_2) ; a budget bb . Output: Two set o原创 2017-06-08 19:05:10 · 577 阅读 · 0 评论 -
【Leetcode】100. Same Tree
Description: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 and the nodes have the same value. /原创 2017-06-25 00:14:07 · 166 阅读 · 0 评论 -
【Leetcode】520. Detect Capital
Description:Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds: All let原创 2017-06-13 11:52:57 · 222 阅读 · 0 评论 -
【Leetcode】200. Number of Island
Description:Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You原创 2017-06-25 21:08:16 · 257 阅读 · 0 评论 -
【Leetcode】617. Merge Two Binary Trees
Description:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new原创 2017-06-26 22:18:25 · 188 阅读 · 0 评论 -
【Leetcode】88. Merge Sorted Array
Desciption:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold a原创 2017-06-26 22:35:52 · 236 阅读 · 0 评论 -
【Leetcode】72. Edit Distance
Description:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on原创 2017-04-21 17:44:02 · 222 阅读 · 0 评论 -
【Leetcode】139. Word Break
Description:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. Y原创 2017-04-20 14:20:58 · 189 阅读 · 0 评论 -
【Leetcode】64. Minimum Path Sum
Description: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.Note:You can only move either down or ri原创 2017-04-17 00:39:38 · 187 阅读 · 0 评论 -
【Leetcode】529. Minesweeper
Description:Let’s play the minesweeper game (Wikipedia, online game)!You are given a 2D char matrix representing the game board. ‘M’ represents an unrevealed mine, ‘E’ represents an unrevealed empty sq原创 2017-03-18 13:47:55 · 270 阅读 · 0 评论 -
【Leetcode】300. Longest Increasing Subsequence
Description:Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], the原创 2017-04-08 00:11:30 · 254 阅读 · 0 评论 -
【Leetcode】55.Jump Game
Description: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 maximum jump length at that position.Determin原创 2017-03-30 01:18:42 · 245 阅读 · 0 评论 -
【Leetcode】517. Super Washing Machines
Description:You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty.For each move, you could choose any m (1 ≤ m ≤ n) washing machines, and pass o原创 2017-03-07 11:51:10 · 1255 阅读 · 0 评论 -
【Leetcode】74. Search a 2D Matrix
Description: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 from left to right. The first integer of原创 2017-03-09 15:54:59 · 211 阅读 · 0 评论 -
【Leetcode】312. Burst Balloons
Description:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will原创 2017-03-12 17:59:21 · 206 阅读 · 0 评论 -
【Leetcode】53. Maximum Subarray
Description: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,1,-5,4], the contiguous subarray [原创 2017-03-03 16:16:44 · 238 阅读 · 0 评论 -
【Leetcode】112. Path Sum
Description: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.Example:Given the below binary t原创 2017-03-16 22:58:00 · 268 阅读 · 0 评论 -
【Leetcode】310. Minimum Height Trees
Description: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 rooted trees, those with minimum height are原创 2017-03-22 21:12:10 · 292 阅读 · 0 评论 -
【Leetcode】455. Assign Cookies
Description:Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum si原创 2017-04-06 00:57:42 · 314 阅读 · 0 评论 -
【Leetcode】45. Jump Game II
Description: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 maximum jump length at that position.Y原创 2017-04-06 10:11:42 · 182 阅读 · 0 评论 -
【Leetcode】221. Maximal Square
Description:Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Example:Given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0原创 2017-05-01 01:21:19 · 248 阅读 · 0 评论 -
【Leetcode】152. Maximum Product Subarray
Description:Find the contiguous subarray within an array (containing at least one number) which has the largest product.Example:Given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest原创 2017-03-06 20:33:22 · 201 阅读 · 0 评论 -
【Leetcode】111. Minimum Depth of Binary Tree
Description: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 leaf node.思路:本题是求二叉树的最小深度,即根节点到最近叶节点的最短原创 2017-06-27 09:53:40 · 227 阅读 · 0 评论