
leetcode
minGW_Lee
I don't know, Just do it!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Linked list 总结
单链表总结:首先就是指针的问题,就算new出新指针tmp做临时变量,对tmp的改变会同时改掉原指针,因为它们本身指向同一内存地址。所以对链表的操作,一定要注意指针的操作顺序。对链表的逆序,注意添加头结点,会是操作方便很多nlogn的排序有快速排序、归并排序、堆排序。 双向链表用快排比较适合,堆排序也可以用于链表,单向链表适合用归并排序技巧:添加头指针,再进行操作,更加方便。使用快慢指针原创 2017-03-17 20:02:01 · 315 阅读 · 0 评论 -
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 they consist原创 2017-11-27 13:46:27 · 216 阅读 · 0 评论 -
Path Sum III
You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need to start or end at the root or a leaf, but it原创 2017-11-16 10:36:49 · 220 阅读 · 0 评论 -
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 the array el原创 2017-11-16 00:28:48 · 236 阅读 · 0 评论 -
301. Remove Invalid Parentheses
题目链接:https://leetcode.com/problems/remove-invalid-parentheses/ Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input str原创 2017-11-04 14:08:25 · 204 阅读 · 0 评论 -
Subarray Sum Equals K
Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1,1,1], k = 2Output: 2Note: The length of the ar原创 2017-11-18 15:08:06 · 177 阅读 · 0 评论 -
LeetCode Container With Most Water
题目:Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two原创 2017-08-19 21:06:44 · 195 阅读 · 0 评论 -
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 const原创 2017-08-18 22:00:51 · 193 阅读 · 0 评论 -
Jump Game
JumpGame 1 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.原创 2017-04-27 10:41:55 · 228 阅读 · 0 评论 -
leetcode直方图的最大矩阵算法
LeetCode 笔记系列 17 Largest Rectangle in HistogramLeetCode 笔记系列 18 Maximal Rectangle [学以致用]转载 2017-05-15 23:38:15 · 653 阅读 · 0 评论 -
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” Minimum window is”BANC”原创 2017-05-12 16:11:09 · 210 阅读 · 0 评论 -
Leetcode:Combinations组合数&&Permutations排列数
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], [1,4],] 解析:首先我原创 2017-04-13 09:16:51 · 784 阅读 · 0 评论 -
leetcode92. Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy原创 2017-03-17 13:50:17 · 275 阅读 · 0 评论 -
leetcode 4:median-of-two-sorted-arrays
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).难点:需要在O(log (m+n))内完成。//采用数组合并的思想,然后取原创 2017-03-25 10:10:00 · 267 阅读 · 0 评论 -
138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. Subscribe to see which companie原创 2017-03-22 22:32:06 · 231 阅读 · 0 评论 -
leetcode23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Subscribe to see which companies asked this question. 解题思路: 要给k个顺序单链表排序,我们熟知合并两个顺序单链表的操作。但是原创 2017-03-29 15:31:29 · 235 阅读 · 0 评论 -
单链表操作的递归总结
递归的思想:个人感觉先写递归表达式,想象最后一层的情况,思考跳出的条件。合并两个顺序表: public ListNode mergeTwoLists(ListNode l1,ListNode l2) { if (l1 == null) return l2; if (l2 == null) return l原创 2017-03-29 14:53:20 · 814 阅读 · 0 评论 -
leetcode279: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; given n = 13, re原创 2017-03-28 22:38:03 · 320 阅读 · 0 评论 -
309. Best Time to Buy and Sell Stock with Cooldown
题目:Say you have an array for which the i-th element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, bu转载 2018-01-24 10:46:33 · 198 阅读 · 0 评论