- 博客(25)
- 资源 (1)
- 收藏
- 关注
原创 leetcode 随笔 Minimum Window Substring --双指针&hash
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).Example:Input: S = "ADOBECODEBANC", T = "ABC"Output: "BANC"Note:If there i...
2018-04-28 15:56:10 12663
原创 leetcode 随笔 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.Example 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Output: [ [1,0,1], [0,0,0], [1,0,1]]Example ...
2018-04-26 20:23:34 12768
原创 leetcode 随笔 Simplify Path --C++ 的split
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"string simplifyPath(string path) { string res, tmp; ve...
2018-04-25 22:09:08 12662
原创 leetcode 随笔 Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only the...
2018-04-25 17:47:36 12559
原创 leetcode 随笔 Plus One & Add Binary --两道 leetcode 适合新手的题
今天这两题可以说是很基础了,比较适合新手,lz大概是从大一就听C++老师给我们推荐去leetcode上面刷刷题锻炼编程,当时基本上也就是刚会写hello world的水平吧,看着输入的vector真是一脸懵逼,因此就放弃了。其实当时的基础几乎等于0,大二之前也没有写过超过200行的程序。到了大二下学习数据库,数据库老师又提起让我们没事刷刷leetcode,当时也有了一定的编程能力了,然后靠百度学会...
2018-04-24 21:19:47 12803
原创 leetcode 随笔 Valid Number
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true检测一段字符串是不是一个数字,这里的数字包括很多种情况,首先去除字符串首和串尾的连续空格1. 小数 :
2018-04-24 19:33:32 12512
原创 leetcode 随笔 Unique Paths & Unique PathsII
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 to reach the bott...
2018-04-20 20:06:02 12485
原创 leetcode 随笔 Rotate List --单链表的操作
Given a linked list, rotate the list to the right by k places, where k is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k = 2Output: 4->5->1->2->3->NULLExplanation...
2018-04-20 19:36:06 12551
原创 leetcode 随笔 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 for n = 3:"123""132""213""231""312""321"Giv
2018-04-20 19:14:15 12423
原创 leetcode 随笔 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 start times.Example 1...
2018-04-19 14:37:56 12452
原创 leetcode 随笔 Merge Intervals --对结构体的排序
Given a collection of intervals, merge all overlapping intervals.Example:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlaps, merge...
2018-04-18 19:21:09 12670
原创 leetcode 随笔 Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]Exampl...
2018-04-18 14:07:04 12321
原创 leetcode 随笔 Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanation: [4,...
2018-04-18 13:14:41 16373
原创 leetcode 随笔 N-Queens & N-Queens II -- N皇后问题
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 solu...
2018-04-17 22:10:51 12527
原创 leetcode 随笔 Pow(x, n)
--50题 撒花Implement pow(x, n), which calculates x raised to the power n (xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, -2Outp...
2018-04-17 16:50:47 12199
原创 leetcode 随笔 Group Anagrams --hash的使用
Given an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat",&quo
2018-04-17 12:07:41 12249
原创 leetcode 随笔 Rotate Image
一道找规律的题You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix ...
2018-04-16 22:42:37 12302
原创 leetcode 随笔 Permutations,Permutations II
Given a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]求一段数字的全排列,数字保证是没有重复的。遍历数组,每...
2018-04-16 11:16:46 12258
原创 leetcode 随笔 Jump Game II
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.Your goal is to rea...
2018-04-16 10:37:15 12193
原创 leetcode随笔 Wildcard Matching的几种解法与思路
Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the...
2018-04-12 21:01:05 11620
原创 leetcode 随笔 Multiply Strings--大数相乘问题
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is < 110.Both num1 and num2 contains only digits 0-9....
2018-04-10 22:52:45 9567
原创 leetcode 随笔 Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example,Given [0,1,0,2,1,0,1,3,2,1,2,1], retur...
2018-04-10 17:46:53 8688
原创 leetcode 随笔First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.有这么一组...
2018-04-09 21:16:04 8340
原创 leetcode 随笔:Count and Say
The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read off as "t...
2018-04-09 14:50:34 7953
原创 leetcode刷题随笔&数独是否合法&利用dfs求数独的解
最近看了一两篇关于leetcode刷题的总结,大体意思就是尽量不要使用ide(lll¬ω¬)然后默写代码保证bug free,这tm就让人很蒙蔽了,lz一直是用visual studio ,有时候程序跑崩了还用用单步调试,看来以后要改变自己的编程习惯了,是有些过分依赖ide了。以后每道题都尽量写一篇随笔把,谈谈对这题的感受,以后没准复习还能用得上。lz最近是电脑进水,项目就暂时不写了才有时间来刷l...
2018-04-09 12:08:32 17015
手写数字识别二进制数据集和label集
2019-03-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人