自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

xunalove的博客

时间是一个伟大的作者,它会给每个人写出完美的结局来。

原创 657. Judge Route Circle(路线圈)

题目 Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to t...

2018-02-26 21:03:34

阅读数 158

评论数 0

原创 520. Detect Capital(检测大写字母)

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

2018-02-26 20:47:46

阅读数 353

评论数 0

原创 383. Ransom Note(map容器)

题目 Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the...

2018-02-26 17:50:40

阅读数 163

评论数 0

原创 387. First Unique Character in a String

题目 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 = "leetcod...

2018-02-26 17:32:48

阅读数 98

评论数 0

原创 292. Nim Game(尼姆游戏)

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

2018-02-26 16:30:29

阅读数 940

评论数 0

原创 350. Intersection of Two Arrays II(两数组交集)

题目 Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: E...

2018-02-26 00:15:07

阅读数 126

评论数 0

原创 349. Intersection of Two Arrays(两数组的交集,vector中find()函数, 结果集去重)

题目 Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each...

2018-02-25 23:18:30

阅读数 146

评论数 0

原创 242. Valid Anagram(有颠倒顺序构成的字符串---字符串排序(c++和python)

题目 Given two strings s and t, write a function to determine if t is an anagram of s. s = "anagram", t = "nagaram", return t...

2018-02-25 23:03:37

阅读数 217

评论数 0

原创 204. Count Primes(厄拉多塞筛法--质数筛法)

题目 Description: Count the number of prime numbers less than a non-negative number, n. 题意 小于n的素数的个数。 题解 普通的筛法求素数超时。 提示中的一种解法:厄拉多塞筛法(https...

2018-02-25 22:57:44

阅读数 377

评论数 0

原创 202. Happy Number(unordered_map)

题目 Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following process: Starting with any positive ...

2018-02-24 17:13:27

阅读数 96

评论数 0

原创 455. Assign Cookies(分蛋糕--贪心)

题目 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 ha...

2018-02-24 15:36:05

阅读数 163

评论数 0

原创 303. Range Sum Query - Immutable(和累加法)

题目 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, 2, -...

2018-02-24 12:16:04

阅读数 161

评论数 0

原创 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 stoppi...

2018-02-24 11:47:23

阅读数 608

评论数 0

原创 70. Climbing Stairs(爬楼梯)

题目 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 can ...

2018-02-24 11:13:29

阅读数 129

评论数 0

原创 682. Baseball Game(栈的应用)

题目 You’re now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round's ...

2018-02-24 00:53:17

阅读数 188

评论数 0

原创 496. Next Greater Element I(下一个更大的元素)

题目 You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for n...

2018-02-23 23:56:35

阅读数 273

评论数 0

原创 232. Implement Queue using Stacks(用栈模拟队列)

题目 Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in...

2018-02-23 22:44:30

阅读数 135

评论数 0

原创 225. Implement Stack using Queues(用队列模拟栈)

题目 Implement the following operations of a stack using queues. push(x) – Push element x onto stack. pop() – Removes the element on top of the stac...

2018-02-21 14:25:26

阅读数 119

评论数 0

原创 155. Min Stack(带有获取当前最小值的栈)

题目 Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() --...

2018-02-21 13:48:20

阅读数 144

评论数 0

原创 Leetcode#661. Image Smoother

题目 Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes th...

2018-02-19 21:35:35

阅读数 69

评论数 0

原创 Leetcode#561. Array Partition I

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

2018-02-19 21:27:12

阅读数 78

评论数 0

原创 Leetcode#746. Min Cost Climbing Stairs(最低花费登楼梯--动态规划)

题目 On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two st...

2018-02-19 17:07:20

阅读数 111

评论数 0

原创 Leetcode#695. Max Area of Island(岛屿最大面积,深搜dfs)

题目 Given a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical...

2018-02-19 16:15:45

阅读数 787

评论数 0

原创 Leetcode#697. Degree of an Array(数组的度)

题目 Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. ...

2018-02-18 23:48:12

阅读数 448

评论数 0

原创 Leetcode#724. Find Pivot Index

题目 Given an array of integers nums, write a method that returns the “pivot” index of this array. We define the pivot index as the index where the s...

2018-02-18 22:07:56

阅读数 124

评论数 0

原创 Leetcode#747. Largest Number At Least Twice of Others

题目 In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as m...

2018-02-18 22:02:55

阅读数 119

评论数 0

原创 Leetcode#665. Non-decreasing Array(非递减数组)

题目 Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. We define an array is no...

2018-02-18 21:52:06

阅读数 129

评论数 0

原创 Leetcode已刷题目题解汇总

Leetcode已刷题目题解链接汇总(持续更新中。。。。。。。) 分类 题解链接 【Easy-Brainteaser】 脑筋急转弯 1道 292. Nim Game(尼姆游戏) 【Easy-Sort 】 排序 3道 242. Valid Anagram(有颠倒顺序...

2018-02-16 21:57:12

阅读数 862

评论数 0

原创 Leetcode#674. Longest Continuous Increasing Subsequence(最长连续递增子序列的长度))

题目 Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray). Example 1: Input: [1,3,5,4,7] Out...

2018-02-16 21:53:16

阅读数 181

评论数 0

原创 Leetcode#643. Maximum Average Subarray I(连续子数组的最大平均值)

题目 Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to outpu...

2018-02-10 14:34:27

阅读数 679

评论数 0

原创 Leetcode#M628.aximum Product of Three Numbers(三个数最大积)

题目 Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Examp...

2018-02-09 22:22:00

阅读数 83

评论数 0

原创 Leetcode#581. Shortest Unsorted Continuous Subarray(最短未排连续子数组)

题目 Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array wil...

2018-02-09 18:13:24

阅读数 112

评论数 0

原创 Leetcode#566. Reshape the Matrix(重塑矩阵)

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

2018-02-09 17:31:35

阅读数 89

评论数 0

原创 Leetcode#532. K-diff Pairs in an Array(k差异对)

题目 Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an...

2018-02-09 16:59:57

阅读数 125

评论数 0

原创 Leetcode#219. Contains Duplicate II(包含副本II)

题目 Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and...

2018-02-08 18:30:18

阅读数 66

评论数 0

原创 Leetcode#189. Rotate Array(翻转数组)

题目 Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4...

2018-02-08 14:44:37

阅读数 83

评论数 0

原创 Leetcode#605. Can Place Flowers

题目 Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots -...

2018-02-07 21:34:23

阅读数 82

评论数 0

原创 Leetcode#485. Max Consecutive Ones

题目 Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The fir...

2018-02-07 20:11:46

阅读数 74

评论数 0

原创 Leetcode#414. Third Maximum Number

题目 Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time com...

2018-02-07 19:54:46

阅读数 69

评论数 0

原创 Leetcode#766. Toeplitz Matrix (托普利兹矩阵)

题目 A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, return True if and only if...

2018-02-07 19:40:07

阅读数 691

评论数 0

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