
leetcode
萤火虫啊飞呀飞
这个作者很懒,什么都没留下…
展开
-
LeetCode 7 Reverse Integer
LeetCode 7原创 2018-03-16 16:29:40 · 131 阅读 · 0 评论 -
LeetCode 6 ZigZag Conversion
LeetCode 6原创 2018-03-16 11:39:47 · 145 阅读 · 0 评论 -
LeetCode 5 Longest Palindromic Substring
LeetCode 5原创 2018-03-16 10:14:27 · 131 阅读 · 0 评论 -
LeetCode 4 Median of Two Sorted ArraysCharacters
LeetCode 4原创 2018-03-15 21:30:15 · 132 阅读 · 0 评论 -
Leetcode 3 Longest Substring Without Repeating Characters
LeetCode 3原创 2018-03-15 20:16:21 · 128 阅读 · 0 评论 -
LeetCode 2 Add Two Numbers
LeetCode 2原创 2018-03-15 20:09:10 · 130 阅读 · 0 评论 -
LeetCode 1 Two Sum
LeetCode 1 Two Sum原创 2018-03-15 20:01:56 · 203 阅读 · 0 评论 -
LeetCode 8 String to Integer (atoi)
LeetCode 8原创 2018-03-16 18:45:55 · 241 阅读 · 0 评论 -
LeetCode 9 Palindrome Number
LeetCode 9原创 2018-03-16 20:23:24 · 209 阅读 · 0 评论 -
LeetCode 10 Regular Expression Matching
LeetCode 10转载 2018-03-16 21:47:16 · 154 阅读 · 0 评论 -
LeetCode 11 Container With Most Water
LeetCode 11原创 2018-03-19 10:44:20 · 150 阅读 · 0 评论 -
LeetCode 12 Integer to Roman
LeetCode 12原创 2018-03-19 11:39:52 · 475 阅读 · 0 评论 -
LeetCode 735 Asteroid Collision
LeetCode 735Asteroid CollisionProblem Description: 题目大体意思就是给出一串整数(包括正数和负数,不包括零)来描述星体运动过程中产生的碰撞情况。其中,整数的绝对值代表星体的大小,正负号表示星体的运动方向,负号表示向左运动,正号表示向右运动。当两个星体碰撞时,大星体把小星体kill掉,剩下自己独孤求败。 具体的题目信息: https:...原创 2018-05-21 16:59:57 · 487 阅读 · 0 评论 -
LeetCode 331 Verify Preorder Serialization of a Binary Tree
LeetCode 331Verify Preorder Serialization of a Binary TreeProblem Description: 简而言之,对输入的字符串进行判断,看是否符合二叉树的前序遍历。 具体的题目信息: https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-...原创 2018-05-21 15:39:02 · 350 阅读 · 0 评论 -
LeetCode 503 Next Greater Element II
LeetCode 503Next Greater Element IIProblem Description: 循环顺序查找第一个比当前数大的数,如果找得到将该比当前数大的第一个数插入数组,否则插入-1。具体的题目信息: https://leetcode.com/problems/next-greater-element-ii/description/Solution: 用f...原创 2018-05-25 13:52:34 · 292 阅读 · 0 评论 -
LeetCode 456 132 Pattern
LeetCode 456132 PatternProblem Description: 给出一组数字,找出里面是否存在“132”模式,即左边的数字是三个数里面最小的,中间的数字是三个数里面最大的,右边的数字是三个数里面排第二大(小)的。需要注意的是,这三个数字不一定连续(废话!谁像你一样没看好题目==)具体的题目信息: https://leetcode.com/problems/...原创 2018-05-25 17:36:17 · 324 阅读 · 0 评论 -
LeetCode 203 Remove Linked List Elements
LeetCode 203Remove Linked List ElementsProblem Description: 删除链表中指定元素具体的题目信息: https://leetcode.com/problems/remove-linked-list-elements/description/Solution: 虽然比较简单,但其中需要注意第21行:head = p 这句...原创 2018-05-26 15:26:04 · 135 阅读 · 0 评论 -
LeetCode 234 Palindrome Linked List
LeetCode 234Palindrome Linked ListProblem Description: 判断链表是否是回文链表。所谓回文,即序列从两头起以相同速度向中间靠拢的过程中,对应位置的元素相同,比如1-2-2-1或者1-2-3-2-1都是回文序列。具体的题目信息: https://leetcode.com/problems/palindrome-linked-lis...原创 2018-05-26 16:02:28 · 250 阅读 · 0 评论 -
LeetCode 160 Intersection of Two Linked Lists
LeetCode 160Intersection of Two Linked ListsProblem Description: 找出两个单链表的公共节点具体的题目信息: https://leetcode.com/problems/intersection-of-two-linked-lists/description/Solution:解题思路 如果两个单链表有公共结点...原创 2018-05-26 16:32:10 · 145 阅读 · 0 评论 -
LeetCode 141 Linked List Cycle
LeetCode 141Linked List CycleProblem Description: 查看链表中是否存在环。需要注意的是,题目问的不是该链表是否是循环链表,而是问链表中有木有环具体的题目信息: https://leetcode.com/problems/linked-list-cycle/description/Solution:解题思路 我们用INT_MI...原创 2018-05-26 16:52:05 · 152 阅读 · 0 评论 -
LeetCode 21 Merge Two Sorted Lists
LeetCode 21Merge Two Sorted ListsProblem Description: 合并两个有序链表具体的题目信息: https://leetcode.com/problems/merge-two-sorted-lists/description/Solution:解题思路 我们把l1作为结果输出链表,扫描l2链表结点然后在l1链表上进行增加结点的...原创 2018-05-26 18:32:16 · 121 阅读 · 0 评论 -
LeetCode 206 Reverse Linked List
LeetCode 206Reverse Linked ListProblem Description: 将输入的链表结点进行逆转具体的题目信息: https://leetcode.com/problems/reverse-linked-list/description/Solution:解题思路 使用头插法,遍历原链表每个结点,将后一个结点插入到前一个结点前面,注意要标记...原创 2018-05-27 10:10:57 · 130 阅读 · 0 评论 -
LeetCode 237 Delete Node in a Linked List
LeetCode 237Delete Node in a Linked ListProblem Description: 删除链表中指定结点具体的题目信息: https://leetcode.com/problems/delete-node-in-a-linked-list/description/Solution:解题思路 这道题目传入的不是一个链表,因此我们不能从头遍...原创 2018-05-27 10:30:09 · 102 阅读 · 0 评论 -
LeetCode 19 Remove Nth Node From End of List
LeetCode 19Remove Nth Node From End of ListProblem Description: 删除链表中倒数第n个结点具体的题目信息: https://leetcode.com/problems/remove-nth-node-from-end-of-list/description/Solution:解题思路 这道题目删除倒数的第n个结...原创 2018-05-27 10:51:40 · 116 阅读 · 0 评论 -
LeetCode 61 Rotate List
LeetCode 61Rotate ListProblem Description: 将链表循环右移n个结点具体的题目信息: https://leetcode.com/problems/rotate-list/description/Solution:解题思路 循环右移就是将链表后n个结点搬到链表前面,原尾结点连接原链表头结点,后n个结点从头数的第一个结点为新的头结点,后...原创 2018-05-27 11:32:08 · 171 阅读 · 0 评论 -
LeetCode 833 Find And Replace in String
LeetCode 833Find And Replace in StringProblem Description: 题目给出四个已知条件:进行操作的字符串S,indexes数组(存储S中需进行替换的位置下标),sources数组(需要匹配S中有indexes数组中下标的子字符串是否与sources中对应子字符串相同),targets数组(如果匹配成功,将S中有indexes数组中下标...原创 2018-06-03 10:25:45 · 1156 阅读 · 0 评论 -
LeetCode 831 Masking Personal Information
LeetCode 831Masking Personal InformationProblem Description: 输入的字符串可能是email形式也可能是phone number形式,题目需要做的就是对不同的字符串进行一定的处理。具体的题目信息: https://leetcode.com/problems/masking-personal-information/de...原创 2018-06-03 11:20:18 · 224 阅读 · 0 评论 -
LeetCode 824 Goat Latin
LeetCode 824Goat LatinProblem Description: 对字符串中的每个单词进行处理,若单词的首字母不是元音字母,则将首字母放在该单词的最后面,如果单词的首字母是元音字母,则不需要进行处理。然后分别在每个单词后加上字符串ma和i个字符a,其中i从1开始递增。具体的题目信息: https://leetcode.com/problems/goat-lat...原创 2018-06-03 12:08:28 · 271 阅读 · 0 评论 -
LeetCode 809 Expressive Words
LeetCode 809Expressive WordsProblem Description: 给出一个字符串S和一个字符串数组vector<string>& words,遍历整个数组返回数组中可扩展成字符串S的字符串的数目。对于可扩展的定义,题目认为相同字符必须连续出现三次及以上才认为是可扩展的,若只出现两次是不可扩展的。具体的题目信息: https://...原创 2018-06-03 16:03:10 · 598 阅读 · 0 评论 -
LeetCode 144 Binary Tree Preorder Traversal
LeetCode 144Binary Tree Preorder TraversalProblem Description: 用栈实现树的先序遍历 具体的题目信息: https://leetcode.com/problems/binary-tree-preorder-traversal/description/Solution: 树的先序遍历顺序:根节点、左节点、右节点 根据...原创 2018-05-23 14:49:42 · 151 阅读 · 0 评论 -
LeetCode 82 Remove Duplicates from Sorted List II
LeetCode 82Remove Duplicates from Sorted List IIProblem Description: 将有序链表中具有重复数值的结点都删掉具体的题目信息: https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/description/Solution:解题思...原创 2018-05-28 12:26:19 · 145 阅读 · 0 评论 -
LeetCode 145 Binary Tree Postorder Traversal
LeetCode 145Binary Tree Postorder TraversalProblem Description: 用栈实现树的后序遍历 具体的题目信息: https://leetcode.com/problems/binary-tree-postorder-traversal/description/Solution: 树的先序遍历顺序:左子树、右子树、根节点 ...原创 2018-05-23 15:57:11 · 506 阅读 · 0 评论 -
LeetCode 71 Simplify Path
LeetCode 71Simplify PathProblem Description: 简化输入的绝对路径 具体的题目信息: https://leetcode.com/problems/simplify-path/description/Attention: (1)/home/..abvh简化后仍是/home/..abvh (2)/home/…简化后仍是/home/… ...原创 2018-05-23 19:47:31 · 144 阅读 · 0 评论 -
LeetCode 86 Partition List
LeetCode 86Partition ListProblem Description: 给出一个值x,将链表中所有小于x的值放在所有大于或等于x的值前面,其中不改变所有小于x的值的相对位置,也不改变所有大于或等于x的值的相对位置。具体的题目信息: https://leetcode.com/problems/partition-list/description/Solutio...原创 2018-05-28 21:46:08 · 136 阅读 · 0 评论 -
LeetCode 199 Binary Tree Right Side View
LeetCode 199Binary Tree Right Side ViewProblem Description: 这道题目给出一棵二叉树,输入从右侧看树得到的结点值。具体的题目信息: https://leetcode.com/problems/binary-tree-right-side-view/description/Example: Solution: 解题...原创 2018-06-11 21:35:19 · 235 阅读 · 0 评论 -
LeetCode 394 Decode String
LeetCode 394Decode String说明:在提交测试过程中发现很多自己没想到的情况,在原基础上进行修改,可能思路看起来不太清晰,有心情再完善吧(很大可能忘了)。不看也罢,谨以此纪念我产生的代码垃圾。Problem Description: 对给出的一串简略字符串进行翻译还原 具体的题目信息: https://leetcode.com/problems/decode...原创 2018-05-24 12:17:13 · 376 阅读 · 0 评论 -
LeetCode 98 Validate Binary Search Tree
LeetCode 98Validate Binary Search TreeProblem Description: 判断给出的二叉树是否是二叉搜索树。 二叉搜索树:要么是空树,要么是具有以下性质的二叉树:若它的左子树不为空,则左子树上所有结点的值均小于它的根节点的值;若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值;它的左、右子树也分别为二叉搜索树。具体的题...原创 2018-06-12 11:00:07 · 147 阅读 · 0 评论 -
LeetCode 101 Symmetric Tree
LeetCode 101Symmetric TreeProblem Description: 判断给出的二叉树是否是对称二叉树。具体的题目信息: https://leetcode.com/problems/symmetric-tree/description/Example: Solution:/** * Definition for a binary tree n...原创 2018-06-12 11:08:28 · 144 阅读 · 0 评论 -
LeetCode 257 Binary Tree Paths
LeetCode 257Binary Tree PathsProblem Description: 输出二叉树从根节点到叶节点的所有路径具体的题目信息: https://leetcode.com/problems/binary-tree-paths/description/Example: Solution: 解题思路:本题可直接用非递归后序遍历来实现。编程实现:...原创 2018-06-12 11:46:27 · 175 阅读 · 0 评论 -
LeetCode 636 Exclusive Time of Functions
LeetCode 636Exclusive Time of FunctionsProblem Description: 记录每一函数运行时间,其中需要注意到当前函数start开始时,上一个函数可能还米有end。 具体的题目信息: https://leetcode.com/problems/exclusive-time-of-functions/description/Exampl...原创 2018-05-24 17:44:31 · 233 阅读 · 0 评论