自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode 思路总结

思路总结(不定时更新!!!!!!)1.解题技巧1.1提升效率我们在做题过程中可以通过使用更加高效的数据结构,来满足不同问题的需求。例如为了提高查找效率,我们可以使用哈希表减少查找的时间复杂度,例如在LeetCode第一题中的求解两数之和,我们可以计算出需要的第二个数,如果存在则返回,不存在就把需要的第二个数放在哈希表中。2.实际函数操作2.1数组C++c++中的vect...

2018-05-16 15:26:19 655

原创 87.乱串追源

Scramble String问题描述:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = “great”:great/ \

2017-10-01 10:40:21 195

原创 85.最大矩阵

Maximal Rectangle问题描述Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle 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

2017-09-19 10:08:18 361

原创 86.区间链表

Partition List问题描述Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nod

2017-09-19 09:48:43 483

原创 84.直方图中最大矩阵

Largest Rectangle in Histogram问题描述:Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above

2017-09-13 11:44:36 234

原创 100.判断树是否相同

测试代码:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */

2017-09-12 10:10:00 202

原创 83.移除链表重复项

Remove Duplicates from Sorted List问题描述:Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1

2017-09-12 09:50:41 183

原创 82移除重复链表第二弹

Remove Duplicates from Sorted List II问题描述:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->

2017-09-11 10:17:56 237

原创 81.旋转数组找数第二弹

Search in Rotated Sorted Array II问题描述:Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed?Would this affect the run-time complexity? How and why? Suppose an array sorted in

2017-09-10 15:04:37 207

原创 80.移除有序数组中重复元素第二弹

Remove Duplicates from Sorted Array II问题描述: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 should re

2017-09-07 09:47:35 317

原创 79.查询单词

Word Search问题描述: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 “adjacent” cells are those horizontally or

2017-09-05 16:31:59 214

原创 78.子集

subset问题描述:Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,3], a solution is:[ [3], [1],

2017-09-04 09:47:40 775

原创 77.组合问题

Combinations问题描述:Given two integers n and k, return all possible combinations of k numbers out of 1 … n.For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3],

2017-09-03 11:33:11 202

原创 76.窗口滑动最小子串

Minimum Window Substring问题描述:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minim

2017-09-02 19:23:38 642

原创 75.颜色排序

Sort Colors问题描述: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, white and blue.Here, we will use th

2017-09-01 16:33:50 339

原创 74.二维数组中找数

Search a 2D Matrix问题描述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

2017-08-30 11:52:20 220

原创 73.设置数组为0

Set Matrix Zeroes问题描述:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.测试代码(Python):class Solution(object): def setZeroes(self, matrix): """

2017-08-29 09:39:41 446

原创 72.单词转变

Edit Distance问题描述: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 permitt

2017-08-28 09:56:16 191

原创 71.简化路径

Simplify Path问题描述:Given an absolute path for a file (Unix-style), simplify it.For example, path = “/home/”, => “/home” path = “/a/./b/../../c/”, => “/c”测试代码(c++):class Solution {public: string s

2017-08-27 13:40:36 351

原创 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 you climb to the top?Note: Given n wil

2017-08-26 13:10:02 328

原创 69.平方根函数

Sqrt(x)问题描述:Implement int sqrt(int x).Compute and return the square root of x.参考答案(c++):class Solution {public: int mySqrt(int x) { long r = x; while (r*r > x) r = (r +

2017-08-26 12:58:08 355

原创 68.文本格式化

Text Justification问题描述:Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greed

2017-08-25 15:21:19 215

原创 67.二进制加法

Add Binary问题描述:Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.参考答案(python):class Solution(object): def addBinary(self, a, b):

2017-08-24 10:17:02 843

原创 66.

Plus One问题描述: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 leading zero, except the number 0 itself.The

2017-08-24 10:01:37 222

原创 65.验证数字

Valid Number问题描述:Validate if a given string is numeric.Some examples: “0” => true ” 0.1 ” => true “abc” => false “1 a” => false “2e10” => true Note: It is intended for the problem statement to be

2017-08-23 10:44:06 192

原创 64.最小路径和

Minimum Path Sum问题描述: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

2017-08-22 09:59:43 777

原创 63.寻找路径第二弹

Unique Paths II问题描述: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 is marked as 1 and 0 respectivel

2017-08-21 17:01:30 195

原创 62.寻找路径

Unique Paths问题描述: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 point in time. The robot is trying t

2017-08-20 11:19:13 172

原创 61.链表旋转

Rotate List问题描述:Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.测试代码(python):# Definition

2017-08-18 10:53:44 280

原创 60.全排列

Permutation Sequence问题描述:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3):“123” “

2017-08-17 14:57:17 168

原创 59.螺旋数组第二弹

Spiral Matrix II问题描述: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 following matrix:[ [ 1, 2, 3 ], [ 8

2017-08-16 10:31:33 136

原创 58.最后单词的长度

Length of Last Word问题描述:Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string.If the last word does not exist, return 0.No

2017-08-15 11:57:10 945

原创 57.插入间隔

Insert Interval问题描述:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their st

2017-08-14 11:53:55 254

原创 56.合并间隔

Merge Intervals问题描述: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].知识补充:自定义sort函数sort(intervals.begin(), i

2017-08-13 11:09:35 238

原创 55.jump游戏

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.Determ

2017-08-12 10:49:01 155

原创 54.螺旋读取数组

Spiral Matrix问题描述: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:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8,

2017-08-11 14:51:37 232

原创 53.最大子数组

Maximum Subarray问题描述: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 subarr

2017-08-10 14:58:27 131

原创 52.多皇后问题第二弹

N-Queens II问题描述:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions. 测试代码(C++):int totalNQueens(int n) { vector<bool> col(n,

2017-08-09 11:05:15 125

原创 51.多皇后问题

#问题描述:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Each

2017-08-07 17:08:11 173

原创 50.实现幂函数

问题描述:Implement pow(x, n).参考答案:class Solution {public: double myPow(double x, int n) { double ans = 1; unsigned long long p; if (n < 0) { p = -n; x =

2017-08-07 11:26:30 264

空空如也

空空如也

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

TA关注的人

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