自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(56)
  • 收藏
  • 关注

原创 [LeetCode .213] House Robber II

声明:题目来自LeetcodeYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means th...

2019-03-05 18:34:15 165

原创 [Algorithms] 证明支配集问题是NP完全问题

声明:原题目出自《算法概论》,解答部分为原创Problem :  In an undirected graph G = (V, E), we say D ⊆ V is a dominating set if every v∈V is either in D or adjacent to at least one member of D. In the DOMINATING SE

2017-07-14 21:19:44 4348

原创 [sicily] 1003. 相连的1

声明:原题目转载自中山大学sicily平台,解答部分为原创Problem :    对于一个01矩阵A,求其中有多少片连成一片的1. 每个1可以和上下左右的1相连.     请为下面的Solution类实现解决这一问题的函数countConnectedOnes,函数参数A为给出的01矩阵,A的行数和列数均不大于1000. 函数的返回值是问题的答案.

2017-06-19 21:38:19 402

原创 [sicily] 1002. 等价二叉树

声明:原题目转载自中山大学sicily平台,解答部分为原创Problem :    两个二叉树结构相同,且对应结点的值相同,我们称这两个二叉树等价.     例如:以下两个二叉树等价        1           1       /  \         /  \      2   3       2   3

2017-06-19 21:16:40 392

原创 [sicily] 1001. 会议安排

声明:原题目转载自中山大学sicily平台,解答部分为原创Problem :   N个会议要同时举行,参会人数分别为A[0], A[1], ..., A[N-1]. 现有M个会议室,会议室可容纳人数分别为B[0], B[1], ..., B[M-1]. 当A[i]    1     请为下面的Solution类实现解决上述问题的函数ass

2017-06-19 21:03:54 385

原创 [sicily] 1000.函数求值

声明:原题目转载自中山大学sicily平台,解答部分为原创Problem :  定义超级和函数F如下:  F(0, n) = n,对于所有的正整数n..  F(k, n) = F(k – 1, 1) + F(k – 1, 2) + … + F(k – 1, n),对于所有的正整数k和n.   请实现下面Solution类中计算F(k, n

2017-06-19 20:53:14 340

原创 [LeetCode] Longest Increasing Subsequence 最长递增子序列的长度

声明:原题目转载自LeetCode,解答部分为原创Problem :    Given an unsorted array of integers, find the length of longest increasing subsequence.    For example,    Given [10, 9, 2, 5, 3, 7, 101, 18],

2017-06-12 17:04:44 559

原创 [LeetCode] Range Sum Query - Immutable 求部分和

声明:原题目转载自LeetCode,解答部分为原创Problem :    Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.    Example:Given nums = [-2, 0, 3, -5,

2017-06-12 16:40:54 222

原创 [LeetCode] House Robber II 求循环数组中元素两两不相邻的子序列最大和

声明:原题目转载自LeetCode,解答部分为原创Problem :    Note: This is an extension of House Robber. [LeetCode] House Robber    After robbing those houses on that street, the thief has found himself

2017-06-12 16:28:16 1052

原创 [LeetCode] House Robber 求数组中元素两两不相邻的子序列最大和

声明:原题目转载自LeetCode,解答部分为原创Problem :    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping

2017-06-12 15:04:29 3386

原创 [LeetCode] Maximum Product Subarray 求连续子数组的最大乘积

声明:原题目转载自LeetCode,解答部分为原创Problem :    Find the contiguous subarray within an array (containing at least one number) which has the largest product.    For example, given the array [2,

2017-06-05 22:56:31 2105

原创 [LeetCode] Maximum Subarray 求连续子数组的最大和

声明:原题目转载自LeetCode,解答部分为原创Problem :    Find the contiguous subarray within an array (containing at least one number) which has the largest sum.    For example, given the array [-2,1,-

2017-06-05 21:52:41 2261

原创 [LeetCode] Climbing stairs 爬楼梯问题

声明:原题目转载自LeetCode,解答部分为原创Problem :    You are climbing a stair case. It takes n steps to reach to the top.    Each time you can either climb 1 or 2 steps. In how many distinct ways c

2017-06-05 21:29:54 377

原创 [LeetCode] Unique Paths II 起点与终点确定的路径数II

声明:原题目转载自LeetCode,解答部分为原创Problem :    Follow up for "Unique Paths":    Now consider if some obstacles are added to the grids. How many unique paths would there be?    An obstacle

2017-05-31 01:11:04 346

原创 [LeetCode] Unique Paths 起点与终点确定的路径数

声明:原题目转载自LeetCode,解答部分为原创Problem :    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

2017-05-31 00:01:41 506

原创 [LeetCode] Combination Sum 和确定的组合数的个数

声明:原题目转载自LeetCode,解答部分为原创Problem :        Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbe

2017-05-30 04:26:06 262

原创 Combination Sum IV 组合数

声明:原题目转载自LeetCode,解答部分为原创Problem :Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.

2017-05-30 04:09:38 242

原创 [LeetCode] Longest Palindromic Subsequence 最长回文子序列

声明:原题目转载自LeetCode,解答部分为原创Problem :        Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:

2017-05-30 03:09:56 283

原创 [LeetCode] Partition Equal Subset Sum划分数组形成两个和相等的子集

声明:原题目转载自LeetCode,解答部分为原创Problem :        Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements i

2017-05-30 01:58:59 3409

原创 [LeetCode] Target Sum通过添加+/-获得目标结果

声明:原题目转载自LeetCode,解答部分为原创 Problem :        You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should

2017-05-30 01:36:45 886

原创 [LeetCode] Predict the Winner 预测得分最高的赢家

声明:原题目转载自LeetCode,解答部分为原创Problem :        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

2017-05-29 23:22:15 358

原创 [LeetCode] Is Subsequence 判断一个字符串是否为另一个的子序列

声明:原题目转载自LeetCode,解答部分为原创Problem :Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is p

2017-05-21 11:10:41 6451

原创 [LeetCode] Integer Break 切割整数,求取最大乘积

Problem :Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For exampl

2017-05-15 22:50:57 379

原创 [LeetCode] Count Numbers with Unique Digits 计算各位数值不同的数的个数

声明:原题目转载自LeetCode,解答部分为原创Problem :        Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.        Example:        Given n = 2, return 91. (Th

2017-05-15 12:35:57 265

原创 [LeetCode] Excel Sheet Column Number 字符串转数字

声明:原题目转载自LeetCode,解答部分为原创Problem :Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...

2017-05-08 22:25:52 257

原创 [LeetCode] First Unique Character in a String 寻找第一个不重复出现的字符

声明:原题目转载自LeetCode,解答部分为原创Problem :    Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"ret

2017-05-08 22:19:31 1177

原创 [LeetCode] Excel Sheet Column Title 数值按进制转字符

声明:原题目转载自LeetCode,解答部分为原创Problem :Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ...

2017-05-08 22:14:05 170

原创 [LeetCode] Sum of Left Leaves 左叶子节点的和

声明:原题目转载自LeetCode,解答部分为原创Problem :Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tr

2017-05-08 22:08:47 225

原创 [LeetCode] Arithmetic Slices 等差数列的个数

声明:原题目转载自LeetCode,解答部分为原创Problem :        A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements i

2017-05-01 18:00:28 646

原创 [LeetCode] Counting Bits 计算二进制表示法中1的位数

声明:原题目转载自LeetCode,解答部分为原创Problem :        Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation

2017-05-01 16:42:11 405

原创 [LeetCode] Jump Game 跳跃游戏

声明:原题目转载自LeetCode,解答部分为原创Problem: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

2017-04-23 21:13:31 272

原创 [LeetCode] Minimum Depth of Binary Tree 根到叶的最短深度

声明:原题目转载自LeetCode,解答部分为原创Problem:      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 t

2017-04-23 20:02:19 185

原创 [LeetCode] Assign Cookies 分饼干

声明:原题目转载自LeetCode,解答部分为原创Problem: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 gree

2017-04-16 14:37:19 295

原创 [LeetCode] Queue Reconstruction by Height 身高队列

声明:原题目转载自LeetCode,解答部分为原创Problem:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the p

2017-04-16 14:01:08 343

原创 [LeetCode] Best Time to Buy and Sell Stock II

声明:原题目转载自LeetCode,解答部分为原创Problem :     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

2017-04-07 22:58:20 204

原创 [LeetCode] Best Time to Buy and Sell Stock

声明:原题目转载自LeetCode,解答部分为原创Problem :    Say you have an array for which the ith element is the price of a given stock on day i.    If you were only permitted to complete at most one tr

2017-04-07 22:46:50 170

原创 [LeetCode] Missing Number

声明:原题目转载自LeetCode,解答部分为原创Problem :       Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.      For example, 

2017-04-07 22:11:25 230

原创 [LeetCode] Max Consecutive Ones 最大的“1”连续个数

声明:原题目转载自LeetCode,解答部分为原创Problem :       Given a binary array, find the maximum number of consecutive 1s in this array.       Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation

2017-04-03 22:45:06 259

原创 [LeetCode] Lexicographical Numbers 字典序排列数字

声明:原题目转载自LeetCode,解答部分为原创Problem :       Given an integer n, return 1 - n in lexicographical order.        For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].       

2017-04-03 22:16:35 803

原创 [LeetCode] Unique Binary Search Trees n结点二叉搜索树的数目

声明:原题目转载自LeetCode,解答部分为原创Problem :Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique B

2017-04-03 21:04:21 270

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除