自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 leetcode 780. Reaching Points

题目:A move consists of taking a point (x, y) and transforming it to either (x, x+y) or (x+y, y).Given a starting point (sx, sy) and a target point (tx, ty), return True if and only if a sequence of mov...

2018-04-16 12:16:12 299

原创 leetcode 754. Reach a Number

题目:You are standing at position 0 on an infinite number line. There is a goal at position target.On each move, you can either go left or right. During the n-th move (starting from 1), you take n steps...

2018-04-14 11:04:10 314

原创 Leetcode 526. Beautiful Arrangement

题目: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 position (1 &l...

2018-04-12 17:01:40 201

原创 Leetcode 329. Longest Increasing Path in a Matrix

题目: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 down. You may NOT move diagonally or move outside ...

2018-04-05 16:57:27 241

原创 leetcode 647. Palindromic Substrings

题目: Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even th

2017-12-03 23:21:37 195

原创 leetcode 233. Number of Digit One

题目: 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 6, because digit 1 occurred in the

2017-12-02 23:04:59 190

原创 leetcode 214. Shortest Palindrome

题目: Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.

2017-12-02 17:58:06 228

原创 leetcode 503. Next Greater Element II

题目: Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The Next Greater Number of a number x is the

2017-12-02 16:17:31 162

原创 leetcode 132. Palindrome Partitioning II

题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab", R

2017-12-02 14:55:58 154

原创 leetcode 539. Minimum Time Difference

题目: Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list. Example 1: Input: ["23:59","00:00"] Outp

2017-12-01 13:51:47 200

原创 leetcode 287. Find the Duplicate Number

题目: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate n

2017-11-06 20:39:12 189

原创 leetcode 416. Partition Equal Subset Sum

题目: 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 in both subsets is equal. Note: Each of

2017-11-06 15:06:37 199

原创 leetcode 648. Replace Words

题目: In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For example, the root an, followed by othe

2017-11-03 20:46:06 233

原创 leetcode 229. Majority Element II

题目: Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. 思路: http://www.cnblogs.com/grandyang/p/4606

2017-11-02 15:09:11 186

原创 leetcode 307. Range Sum Query - Mutable

题目: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by updating the element at index i to val.

2017-11-02 11:02:54 176

原创 leetcode House Robber

题目: 198. House Robber 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 you from robbing each

2017-10-29 21:34:01 207

原创 leetcode 686. Repeated String Match

题目: Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For example, with A = "abcd" and B = "cda

2017-10-29 11:27:19 406

原创 leetcode 55. Jump Game

题目: 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. De

2017-10-25 22:21:42 161

原创 leetcode 456. 132 Pattern

题目: Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i j k and ai < ak j. Design an algorithm that takes a list of n numbers as input

2017-10-25 12:00:07 188

原创 leetcode 230. Kth Smallest Element in a BST

题目: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note:  You may assume k is always valid, 1 ≤ k ≤ BST's total elements. void f(vector &r

2017-10-24 16:43:38 193

原创 leetcode 435. Non-overlapping Intervals

题目: Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note: You may assume the interval's end poi

2017-10-24 10:37:05 216

原创 leetcode 204. Count Primes

题目: Description: Count the number of prime numbers less than a non-negative number, n. 思路: 暴力求解是一种,还有就是筛选法,创建一个n的数组,初始化为true,遍历开始,就是当i是质(素)数的时候,i的所有的倍数必然是合数。如果i已经被判断不是质数了,那么再找到i后面的质数来把这个质数的倍

2017-10-23 18:42:55 148

原创 leetcode 453. Minimum Moves to Equal Array Elements

题目: Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1. Example: Input: [1

2017-10-23 18:21:20 142

原创 Leetcode 330. Patching Array

题目: Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some elements in the

2017-10-21 12:00:44 153

原创 Leetcode 513. Find Bottom Left Tree Value

题目: Given a binary tree, find the leftmost value in the last row of the tree. void f(TreeNode* root,int cur,vector>& re){ if(root !=NULL){ if(cur < re.size()){ re[cur].push

2017-10-20 16:04:55 144

原创 leetcode 451. Sort Characters By Frequency

题目: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear on

2017-10-19 12:03:12 149

转载 leetcode 139. Word Break

题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode", dict 

2017-10-19 12:02:08 131

原创 leetcode 279. Perfect Squares

题目: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4;

2017-10-17 22:34:59 131

翻译 Leetcode 390. Elimination Game

raw blog:http://blog.csdn.net/corpsepiges/article/details/52573281  题目: There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other numbe

2017-10-10 16:56:49 283

原创 Leetcode 452. Minimum Number of Arrows to Burst Balloons

题目: here are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y

2017-09-17 16:17:52 237

原创 招银信用卡笔试 先手获胜题

题目: A,B从M个员工里面选择人数,每人每次从左边开始选择1或者2个人,一直到结束,累计每个人选择的人数的总身高。A先开始选择,判断A是否能获得胜利。 思路:dp问题,dp[i]表示第i层时先拿的人能获得的最大身高总数。假设拿一块,能获得的最大总数为,a[i]+min(dp[i-2],dp[i-3]),既是另一个人选1或者2块后能获得的最大值。 同理 如果拿两块的化,最大值为a[i]+a[

2017-09-14 09:34:21 783

原创 Leetcode 221. Maximal Square

题目: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1

2017-09-13 09:45:47 182

原创 Leetcode 40. Combination Sum II

题目: 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 number in C may only be used once in th

2017-09-12 23:12:09 163

转载 [leetcode] 391. Perfect Rectangle 解题报告

题目链接:https://leetcode.com/problems/perfect-rectangle/ Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region. Each rectangle

2017-09-10 13:14:51 207

原创 LeetCode 477. Total Hamming Distance

题目: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Now your job is to find the total Hamming distance between all pairs o

2017-09-06 17:33:59 197

原创 LeetCode 517. Super Washing Machines

题目: 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 one

2017-09-03 22:57:30 240

原创 Leetcode 207. Course Schedule

题目: 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 expr

2017-08-31 15:08:36 215

原创 搜狐2018笔试 8.28

第一题: 求数列的前n项,给定一个数字字典,比如{2,1,3,1},构造一个新数列,新数列满足以下: 1:字典里的数循环重复,如果把重复的数记为一组,以每一组的个数构成新数列,新数列和原数列一样。 以上面字典为例:生成数组为:2,2,1,1,3,1,2,2,2。。。 思路:假设需要生成的数组为a,第一个数肯定就是字典第一个,同时他还代表了这个数出现的次数。所以数组向后重复,然后数组的第二个

2017-08-29 10:29:52 464

原创 434. Number of Segments in a String 字符串分割

题目:Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.Please note that the string does not contain any non-printable characters.Ex...

2017-08-28 14:35:37 219

原创 逆序对

归并算法求逆序,基于分治的,剑指offer上那个感觉有问题啊。每次合并之后没有把辅助数组里的值放回原来的地方,我还以为是边界没写好看了半天。 而且这个和昨天的360那个跳水计算的是一样的,只不过逆序对的记录是记录每个点上的,在每个点上有多少需要把前面的加起来。 class Solution { public: int f(vector &data,vector &copy,int i

2017-08-27 10:48:00 249

空空如也

空空如也

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

TA关注的人

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