
''算法''不能停……
我在通往牛B的路上,一路狂奔……
MissXy_
一定要记着,在不久的将来,你所有的付出都会有所回报的!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode --- Tree | 树相关题目
LeetCode — Tree | 树相关题目刷题顺序参考链接:CSON1 基础题号原题链接C/C++Python144Binary Tree Preorder Traversal (二叉树的前序遍历)Medium查看题解94Binary Tree Inorder Traversal (二叉树的中序遍历)Medium查看题解145Bin...原创 2019-10-26 10:51:11 · 381 阅读 · 0 评论 -
LeetCode --- Linked List丨链表相关题目
LeetCode — Linked List丨链表相关题目记录一下,关于链表的刷题,加油。题号题名C/C++Python2Add Two Numbers查看题解查看题解206Reverse Linked List查看题解查看题解...原创 2019-03-21 19:13:41 · 358 阅读 · 0 评论 -
LeetCode --- 142. Linked List Cycle II
142. Linked List Cycle IIDifficulty: MediumGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.To represent a cycle in the given linked list, we use an in...原创 2019-04-10 11:47:29 · 376 阅读 · 0 评论 -
LeetCode --- 703. Kth Largest Element in a Stream
703. Kth Largest Element in a StreamDifficulty: EasyDesign a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct elem...原创 2019-04-09 22:19:39 · 333 阅读 · 0 评论 -
LeetCode --- 92. Reverse Linked List II
92. Reverse Linked List IIDifficulty: MediumReverse a linked list from position m to n. Do it in one-pass.**Note: **1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m...原创 2019-04-09 19:51:55 · 317 阅读 · 0 评论 -
LeetCode --- 86. Partition List
86. Partition ListDifficulty: MediumGiven 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 rel...原创 2019-04-09 13:17:36 · 248 阅读 · 0 评论 -
LeetCode --- 61. Rotate List
61. Rotate ListDifficulty: MediumGiven 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-&...原创 2019-04-08 21:00:21 · 236 阅读 · 0 评论 -
LeetCode --- 82. Remove Duplicates from Sorted List II
82. Remove Duplicates from Sorted List IIDifficulty: MediumGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.Example 1:...原创 2019-04-08 13:09:36 · 368 阅读 · 0 评论 -
LeetCode --- 237. Delete Node in a Linked List
237. Delete Node in a Linked ListDifficulty: EasyWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list – head = [4,5,1,9], wh...原创 2019-04-05 13:23:31 · 489 阅读 · 0 评论 -
LeetCode --- 234. Palindrome Linked List
234. Palindrome Linked ListDifficulty: EasyGiven a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: false```**Example 2:**Input: 1->2->2->1Output...原创 2019-04-04 20:13:29 · 284 阅读 · 0 评论 -
LeetCode --- 203. Remove Linked List Elements
203. Remove Linked List ElementsDifficulty: EasyRemove all elements from a linked list of integers that have value val.Example:Input: 1->2->6->3->4->5->6, val = 6Output: 1->...原创 2019-04-04 14:33:34 · 315 阅读 · 0 评论 -
LeetCode --- 160. Intersection of Two Linked Lists
160. Intersection of Two Linked ListsDifficulty: EasyWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin ...原创 2019-04-03 13:33:00 · 336 阅读 · 0 评论 -
LeetCode --- 19. Remove Nth Node From End of List
19. Remove Nth Node From End of ListDifficulty: MediumGiven a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n...原创 2019-03-30 20:26:41 · 265 阅读 · 0 评论 -
LeetCode --- 141. Linked List Cycle
141. Linked List CycleDifficulty: EasyGiven a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-in...原创 2019-04-02 13:40:40 · 301 阅读 · 0 评论 -
LeetCode --- 232. Implement Queue using Stacks
232. Implement Queue using StacksDifficulty: EasyImplement the following operations of a queue using stacks.push(x) – Push element x to the back of queue.pop() – Removes the element from in front...原创 2019-03-27 13:17:19 · 339 阅读 · 0 评论 -
LeetCode --- 24. Swap Nodes in Pairs
24. Swap Nodes in PairsDifficulty: MediumGiven a linked list, swap every two adjacent nodes and return its head.You may not modify the values in the list’s nodes, only nodes itself may be changed....原创 2019-03-25 13:37:28 · 234 阅读 · 0 评论 -
LeetCode --- 20. Valid Parentheses
20. Valid ParenthesesDifficulty: EasyGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open bracket...原创 2019-03-26 13:59:35 · 241 阅读 · 0 评论 -
LeetCode --- 206. Reverse Linked List丨反转链表
206. Reverse Linked ListDifficulty: EasyReverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be r...原创 2019-03-20 11:27:05 · 298 阅读 · 0 评论 -
LeetCode --- 100. 相同的树(Same Tree)
100. 相同的树(Same Tree)题目难度: 简单给定两个二叉树,编写一个函数来检验它们是否相同。如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。示例 1:输入: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3]...原创 2018-09-15 16:54:10 · 241 阅读 · 0 评论 -
LeetCode --- 83. Remove Duplicates from Sorted List
83. 删除排序链表中的重复元素(Remove Duplicates from Sorted List)题目难度: 简单给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。示例 1:**输入:** 1->1->2**输出:** 1->2示例 2:输入: 1->1->2->3->3输出: 1->2->...原创 2018-09-06 11:22:25 · 299 阅读 · 0 评论 -
LeetCode --- 70. 爬楼梯(Climbing Stairs)
70. 爬楼梯(Climbing Stairs)题目难度: 简单假设你正在爬楼梯。需要 n 阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?注意:给定 n 是一个正整数。示例 1:输入: 2输出: 2解释: 有两种方法可以爬到楼顶。1. 1 阶 + 1 阶2. 2 阶示例 2:输入: 3输出: 3解释: 有...原创 2018-09-06 10:54:57 · 315 阅读 · 0 评论 -
LeetCode --- 69. x 的平方根(Sqrt(x))
69. x 的平方根(Sqrt(x))题目难度: 简单实现 int sqrt(int x) 函数。计算并返回 x 的平方根,其中 x 是非负整数。由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去。示例 1:输入: 4输出: 2示例 2:输入: 8输出: 2说明: 8 的平方根是 2.82842..., 由于返回类型是整数,小数部分将被...原创 2018-09-06 10:40:05 · 292 阅读 · 0 评论 -
LeetCode --- 66. 加一(Plus One)
66. 加一(Plus One)题目难度: 简单给定一个由整数组成的非空数组所表示的非负整数,在该数的基础上加一。最高位数字存放在数组的首位, 数组中每个元素只存储一个数字。你可以假设除了整数 0 之外,这个整数不会以零开头。示例 1:输入: [1,2,3]输出: [1,2,4]解释: 输入数组表示数字 123。示例 2:输入: [4,3,2,1]输出: ...原创 2018-09-04 14:40:04 · 249 阅读 · 0 评论 -
LeetCode --- 58. 最后一个单词的长度(Length of Last Word)
58. 最后一个单词的长度(Length of Last Word)题目难度: 简单给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一个单词的长度。如果不存在最后一个单词,请返回 0 。说明:一个单词是指由字母组成,但不包含任何空格的字符串。示例:输入: "Hello World"输出: 5解题思路: 从尾端向前找到第一个非’ ‘字符,计算位置。...原创 2018-09-02 16:21:41 · 273 阅读 · 0 评论 -
LeetCode --- 53. 最大子序和(Maximum Subarray)
53. 最大子序和(Maximum Subarray)题目难度: 简单给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。示例:输入: [-2,1,-3,4,-1,2,1,-5,4],输出: 6解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。进阶:如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙...原创 2018-08-22 10:19:55 · 285 阅读 · 0 评论 -
LeetCode --- 38. 报数(Count and Say)
38. 报数(Count and Say)题目难度: 简单报数序列是指一个整数序列,按照其中的整数的顺序进行报数,得到下一个数。其前五项如下:1. 12. 113. 214. 12115. 1112211 被读作 "one 1" ("一个一") , 即 11。 11 被读作 "two 1s" ("两个一"), 即 21。 ...原创 2018-08-21 19:15:08 · 256 阅读 · 0 评论 -
LeetCode --- 28. 实现strStr()(Implement strStr())
28. 实现strStr()(Implement strStr())题目难度: 简单实现 函数。给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始)。如果不存在,则返回 -1。示例 1:输入: haystack = "hello", needle = "ll"输出: 2...原创 2018-08-21 17:32:55 · 284 阅读 · 0 评论 -
LeetCode --- 35. 搜索插入位置(Search Insert Position)
35. 搜索插入位置(Search Insert Position)题目难度: 简单给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。你可以假设数组中无重复元素。示例 1:输入: [1,3,5,6], 5输出: 2示例 2:输入: [1,3,5,6], 2输出: 1示例 3:输入: [...原创 2018-08-21 18:25:14 · 235 阅读 · 0 评论 -
LeetCode --- 27. 移除元素(Remove Element)
27. 移除元素(Remove Element)题目难度: 简单给定一个数组 nums 和一个值 val,你需要移除所有数值等于 val 的元素,返回移除后数组的新长度。不要使用额外的数组空间,你必须在修改输入数组并在使用 O(1) 额外空间的条件下完成。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。示例 1:给定 _nums_ = [3,2,2,3], ...原创 2018-08-21 17:18:07 · 286 阅读 · 0 评论 -
LeetCode --- 26. 删除排序数组中的重复项(Remove Duplicates from Sorted Array)
26. 删除排序数组中的重复项(Remove Duplicates from Sorted Array)题目难度: 简单给定一个排序数组,你需要在删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。不要使用额外的数组空间,你必须在修改输入数组并在使用 O(1) 额外空间的条件下完成。示例 1:给定数组 _nums_ = [1,1,2], 函数应该返回新的...原创 2018-08-21 16:24:02 · 380 阅读 · 0 评论 -
LeetCode --- 21. Merge Two Sorted Lists
21. 合并两个有序链表(Merge Two Sorted Lists)题目难度: 简单将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例:输入:1->2->4, 1->3->4输出:1->1->2->3->4->4个人思路: 采用递归法,求链表!Solutio...原创 2018-08-21 16:02:52 · 343 阅读 · 0 评论 -
LeetCode --- 20. 有效的括号(Valid Parentheses)
20. 有效的括号(Valid Parentheses)题目难度: 简单给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。左括号必须以正确的顺序闭合。注意空字符串可被认为是有效字符串。示例 1:输入: "()"输出: true示例 2:输入: "()[]{...原创 2018-08-21 15:36:17 · 350 阅读 · 0 评论 -
LeetCode --- 14. 最长公共前缀(Longest Common Prefix)
14. 最长公共前缀(Longest Common Prefix)题目难度: 简单编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串 ""。示例 1:输入: ["flower","flow","flight"]输出: "fl"示例 2:输入: ["dog","racecar","car"]原创 2018-08-21 14:22:29 · 457 阅读 · 0 评论 -
LeetCode --- 9. 回文数(Palindrome Number)
9. 回文数(Palindrome Number)题目难度: 简单判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。示例 1:输入: 121输出: true示例 2:输入: -121输出: false解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。示例 3:输入: 10输出...原创 2018-08-20 20:47:07 · 441 阅读 · 0 评论 -
LeetCode --- 13. 罗马数字转整数(Roman to Integer)
13. 罗马数字转整数(Roman to Integer)题目难度: 简单罗马数字包含以下七种字符:I, V, X, L,C,D 和 M。字符 数值I 1V 5X 10L 50C 100D 500M ...原创 2018-08-20 22:53:20 · 433 阅读 · 0 评论 -
LeetCode --- 7. 反转整数(Reverse Integer)
7. 反转整数(Reverse Integer)题目难度: 简单给定一个 32 位有符号整数,将整数中的数字进行反转。示例 1:输入: 123输出: 321示例 2:输入: -123输出: -321示例 3:输入: 120输出: 21注意:假设我们的环境只能存储 32 位有符号整数,其数值范围是 [−231, 231 − 1]。根据这个假设,如果...原创 2018-08-20 20:12:15 · 214 阅读 · 0 评论 -
LeetCode --- 2. Add Two Numbers
Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the原创 2017-10-22 17:41:22 · 335 阅读 · 0 评论 -
LeetCode --- 1.Two Sum
Two SumGiven an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not u...原创 2017-10-17 21:24:52 · 377 阅读 · 0 评论