
LeetCode
zhangpeterx
这个作者很懒,什么都没留下…
展开
-
LeetCode 报错解决 heap-buffer-overflow Heap-use-after-free Stack-buffer-overflow Global-buffer-overflow
文章目录前言Heap-buffer-overflowHeap-use-after-freeStack-buffer-overflowGlobal-buffer-overflow前言在做LeetCode题时发现一个有趣的事情。对于C语言来说,如果直接访问超出Index的数组,会报错:int main(int argc, char **argv) { int array [100];...原创 2019-03-24 12:20:38 · 54349 阅读 · 22 评论 -
LeetCode 所有题目总结
结题注意事项:1.注意空字符串,以及各种极端情况。2.异或运算有奇效题目分类:字符串题型:具有最多两个不同字符的最长子串的长度LeetCode 159. Longest Substring with At Most Two Distinct Characters --Java,C++,Python解法...原创 2020-01-03 13:56:58 · 2725 阅读 · 0 评论 -
LeetCode 1242. Web Crawler Multithreaded--Java 解法--网路爬虫并发系列--ConcurrentHashMap/Collections.synchroni
此文首发于我的Jekyll博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Web Crawler Multithreaded - LeetCodeGiven a url startUrl and an interface HtmlParser, implement ...原创 2020-02-12 10:12:47 · 1517 阅读 · 0 评论 -
LeetCode 1195. Fizz Buzz Multithreaded--并发系列题目--Java 解法--AtomicInteger/CountDownLatch/CyclicBarrier
此文首发于我的Jekyll博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Fizz Buzz Multithreaded - LeetCodeWrite a program that outputs the string representation of numb...原创 2020-02-11 17:32:50 · 1239 阅读 · 0 评论 -
LeetCode 1188. Design Bounded Blocking Queue--并发系列--Java 解法--设计有界阻塞队列--使用ArrayBlockingQueue和LinkedLi
此文首发于我的Jekyll博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Design Bounded Blocking Queue - LeetCodeImplement a thread safe bounded blocking queue that has ...原创 2020-02-10 16:07:52 · 1259 阅读 · 1 评论 -
LeetCode 92. Reverse Linked List II--Python 解法--反转部分链表--笔试算法题
此文首发于我的个人博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Reverse Linked List II - LeetCodeReverse a linked list from position m to n. Do it in one-pass.Note...原创 2020-02-10 10:21:57 · 523 阅读 · 0 评论 -
LeetCode 309. Best Time to Buy and Sell Stock with Cooldown--Java解法-卖股票系列题目
此文首发于我的Jekyll博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Best Time to Buy and Sell Stock with Cooldown - LeetCodeSay you have an array for which the ith ...原创 2020-02-06 10:49:33 · 326 阅读 · 0 评论 -
从LeetCode 679. 24 Game--C++ 解法--二十四点 到穷举24点所有可能性-24点大全
从LeetCode 679. 24 Game–C++ 解法–二十四点 到穷举24点所有可能性此文首发于我的个人博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:24 Game - LeetCodeou have 4 cards each containing a n...原创 2020-02-04 11:13:15 · 749 阅读 · 0 评论 -
LeetCode 41. First Missing Positive--Python 解法--数学题-找到不存在的最小正整数-O(1)空间复杂度
此文首发于我的Jekyll博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:First Missing Positive - LeetCodeGiven an unsorted integer array, find the smallest missing posi...原创 2020-02-02 15:50:07 · 559 阅读 · 0 评论 -
LeetCode 399. Evaluate Division--Python-DFS解法
LeetCode 399. Evaluate Division–Python-DFS解法此文首发于我的个人博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Evaluate Division - LeetCodeEquations are given in the ...原创 2020-02-02 10:17:46 · 479 阅读 · 0 评论 -
LeetCode 207. Course Schedule--有向图找环--面试算法题--DFS递归,拓扑排序迭代--Python
LeetCode 207. Course Schedule–有向图找环–面试算法题–DFS递归,拓扑排序迭代–Python此文首发于我的个人博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Course Schedule - LeetCodeThere are a ...原创 2020-01-29 14:16:13 · 1230 阅读 · 1 评论 -
数据结构线段树介绍与笔试算法题-LeetCode 307. Range Sum Query - Mutable--Java解法
此文首发于我的个人博客:zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结线段树(Segment Tree)常用于解决区间统计问题。求最值,区间和等操作均可使用该数据结构。线段树的最简单的实现是通过数组(通过数组是为了让查找单个元素可以在O(1)的时间内做到),就像最小堆可以用数组实现...原创 2020-01-28 15:12:15 · 378 阅读 · 0 评论 -
LeetCode 22. Generate Parentheses--Python 解法--广度优先、深度优先解法
此文首发于我的个人博客:LeetCode 22. Generate Parentheses–Python 解法–广度优先、深度优先解法 — zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Generate Parentheses - LeetCodeGiven n pai...原创 2020-01-24 15:55:35 · 432 阅读 · 0 评论 -
LeetCode 31. Next Permutation-- Python 解法--数学题--比当前数大的最小的数
LeetCode 31. Next Permutation-- Python 解法–数学题–比当前数大的最小的数此文首发于我的个人博客:LeetCode 31. Next Permutation-- Python 解法–数学题–比当前数大的最小的数 — zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解文章集合LeetCode 所有题目总结:LeetCode...原创 2020-01-22 08:40:04 · 549 阅读 · 0 评论 -
LeetCode 11. Container With Most Water--Java 解法--困雨水简单版
LeetCode 11. Container With Most Water–Java 解法此文首发于我的个人博客:LeetCode 11. Container With Most Water–Java 解法–困雨水简单版 — zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Con...原创 2020-01-21 20:21:01 · 433 阅读 · 0 评论 -
LeetCode 111. Minimum Depth of Binary Tree--Java, Python解法--二叉树最小高度--迭代,递归
此文首发于我的个人博客:LeetCode 111. Minimum Depth of Binary Tree–Python解法–二叉树最小高度–迭代,递归 — zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Minimum Depth of Binary Tree - LeetCod...原创 2020-01-15 10:45:31 · 350 阅读 · 0 评论 -
LeetCode 202. Happy Number--Python解法--数学题
LeetCode 202. Happy Number–C++,Python解法LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Happy Number - LeetCodeWrite an algorithm to determine if a number is “ha...原创 2020-01-14 11:57:59 · 398 阅读 · 0 评论 -
LeetCode1117. Building H2O --Java解法--多线程保证执行顺序--AtomicInteger
此文首发于我的个人博客:LeetCode 1117. Building H2O --Java解法–多线程保证执行顺序–AtomicInteger — zhang0peter的个人博客LeetCode题解文章分类:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Building H2O - LeetCodeThere are two kind...原创 2020-01-14 10:44:20 · 434 阅读 · 0 评论 -
LeetCode 1115. Print FooBar Alternately--多线程并发问题--Java解法--CyclicBarrier, synchronized, Semaphore 信号量
此文首发于我的个人博客:zhang0peter的个人博客LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结题目地址:Print FooBar Alternately - LeetCodeSuppose you are given the following code:class FooBar { public void ...原创 2020-01-12 09:22:48 · 419 阅读 · 0 评论 -
LeetCode 268. Missing Number--Python解法--数学题
LeetCode 268. Missing Number–Python解法–数学题LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++,Python,Java的解法都有。题目地址:Missing Number - LeetCodeGiven an array containing n distinct numb...原创 2019-12-27 13:26:57 · 267 阅读 · 0 评论 -
LeetCode 123. Best Time to Buy and Sell Stock III--Python解法--动态规划--数学题
LeetCode 123. Best Time to Buy and Sell Stock III–Python解法–动态规划LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++,Python,Java的解法都有。题目地址:Best Time to Buy and Sell Stock III - LeetCode...原创 2019-11-26 15:03:17 · 355 阅读 · 0 评论 -
LeetCode 974. Subarray Sums Divisible by K--Python解法--数学题--取模求余
LeetCode 974. Subarray Sums Divisible by K–Python解法–数学题–取模求余LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Subarray Sums Divisible by K - LeetCodeGiven an arra...原创 2019-11-16 09:34:18 · 354 阅读 · 0 评论 -
LeetCode 653. Two Sum IV - Input is a BST--Python解法
LeetCode 653. Two Sum IV - Input is a BST–Python解法LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Two Sum IV - Input is a BST - LeetCodeGiven a Binary Search Tr...原创 2019-11-14 16:18:50 · 202 阅读 · 0 评论 -
LeetCode 167. Two Sum II - Input array is sorted--Python解法
LeetCode 167. Two Sum II - Input array is sorted–Python解法LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Two Sum II - Input array is sorted - LeetCodeGiven an a...原创 2019-11-07 21:13:13 · 246 阅读 · 0 评论 -
LeetCode 45. Jump Game II--Python解法--动态规划
LeetCode 45. Jump Game II–Python解法–动态规划LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Jump Game II - LeetCodeGiven an array of non-negative integers, you are i...原创 2019-11-06 11:38:07 · 404 阅读 · 0 评论 -
LeetCode 54. Spiral Matrix--Python解法--螺旋排序
LeetCode 54. Spiral Matrix–Python解法–螺旋排序LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Spiral Matrix - LeetCodeGiven a matrix of m x n elements (m rows, n colu...原创 2019-11-05 16:54:34 · 383 阅读 · 0 评论 -
LeetCode 202. Happy Number--Python解法
LeetCode 202. Happy Number–C++,Python解法LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结:LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Happy Number - LeetCodeWrite an algorithm to determine if a number is “ha...原创 2019-11-04 16:18:26 · 465 阅读 · 0 评论 -
LeetCode 547. Friend Circles--Python解法--笔试算法题
LeetCode 547. Friend Circles–Python解法–笔试算法题LeetCode题解专栏:LeetCode题解LeetCode 所有题目总结大部分题目C++和Python的解法都有。题目地址:Friend Circles - LeetCodeThere are N students in a class. Some of them are friends, w...原创 2019-11-04 15:45:37 · 564 阅读 · 0 评论 -
LeetCode 542. 01 Matrix--C++解法--动态规划
LeetCode 542. 01 Matrix–C++解法–动态规划LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目C++和Python的解法都有。题目地址:01 Matrix - LeetCodeGiven a matrix consists of 0 and 1, find the distance of the nea...原创 2019-11-04 08:45:12 · 467 阅读 · 0 评论 -
LeetCode 230. Kth Smallest Element in a BST--C++,Python解法--面试真题--找二叉树中第K小的元素
LeetCode 230. Kth Smallest Element in a BST–C++,Python解法–面试真题–找二叉树中第K小的元素LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目C++和Python的解法都有。题目地址:Kth Smallest Element in a BST - LeetCodeGiven...原创 2019-11-03 10:27:12 · 404 阅读 · 0 评论 -
LeetCode 98. Validate Binary Search Tree--C++解法--判断是否是BST--递归,迭代做法,中序遍历
LeetCode 98. Validate Binary Search Tree–C++解法–判断是否是BST–递归,迭代做法,中序遍历LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目C++和Python的解法都有。题目地址:Validate Binary Search Tree - LeetCodeGiven a bina...原创 2019-11-01 15:53:07 · 289 阅读 · 0 评论 -
LeetCode 23. Merge k Sorted Lists--Python解法--优先队列,分治法
LeetCode 23. Merge k Sorted Lists–C++,Python解法–优先队列,分治法LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目C++和Python的解法都有。题目地址:Merge k Sorted Lists - LeetCodeMerge k sorted linked lists and ...原创 2019-10-31 10:48:55 · 324 阅读 · 0 评论 -
LeetCode 421. Maximum XOR of Two Numbers in an Array--Python解法
LeetCode 421. Maximum XOR of Two Numbers in an Array–C++,Python解法LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目C++和Python的解法都有。题目地址:Maximum XOR of Two Numbers in an Array - LeetCodeGive...原创 2019-10-31 08:39:19 · 266 阅读 · 0 评论 -
LeetCode 221. Maximal Square----动态规划--谷歌面试算法题--Python解法
LeetCode 221. Maximal Square----动态规划–华为,谷歌面试算法题–Python解法LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目C++和Python的解法都有。题目地址:Maximal Square - LeetCodeGiven a 2D binary matrix filled with ...原创 2019-10-16 18:47:11 · 545 阅读 · 0 评论 -
LeetCode 148. Sort List--面试算法题--C++,Python解法
LeetCode 148. Sort List–拼多多面试算法题–C++,Python解法LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目C++和Python的解法都有。题目地址:Sort List - LeetCodeSort a linked list in O(n log n) time using constant ...原创 2019-10-15 16:49:36 · 265 阅读 · 0 评论 -
LeetCode 3. Longest Substring Without Repeating Characters-- c++,java,python解法
LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目Java和Python的解法都有。Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3...原创 2019-04-08 17:23:09 · 225 阅读 · 0 评论 -
LeetCode 5. Longest Palindromic Substring
LeetCode 5. Longest Palindromic SubstringGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: "babad"Output: "bab"N...原创 2019-04-03 21:55:26 · 188 阅读 · 0 评论 -
LeetCode 15. 3Sum--Java,Python解法
LeetCode 15. 3SumGiven an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution s...原创 2019-03-21 16:36:51 · 274 阅读 · 0 评论 -
LeetCode 37. Sudoku Solver--数独求解(回溯法)--Java 3ms,Python 80ms 解法
LeetCode 37. Sudoku SolverLeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目Java和Python的解法都有。Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisf...原创 2019-03-25 12:52:42 · 435 阅读 · 0 评论 -
LeetCode 42. Trapping Rain Water--算法题--c++解法
LeetCode 42. Trapping Rain Water–c++解法LeetCode题解专栏:LeetCode题解我做的所有的LeetCode的题目都放在这个专栏里,大部分题目Java和Python的解法都有。Given n non-negative integers representing an elevation map where the width of each ba...原创 2019-10-12 16:21:47 · 467 阅读 · 0 评论