
LeetCode
文章平均质量分 66
xiongluo0628
这个作者很懒,什么都没留下…
展开
-
LeetCode Easy 前26-30道
#111 Minimum Depth of Binary Tree#112 Path Sum#118 Pascal’s Triangle#119 Pascal’s Triangle II#121 Best Time to Buy and Sell Stock#111 Minimum Depth of Binary Tree要求:求二叉树的最浅深度思路1:采用递归的思路,没毛病,一次ACclass Solution {public: int minDepth(TreeNode* r原创 2021-08-19 23:35:52 · 220 阅读 · 0 评论 -
LeetCode Easy 前21-25道
#100 Same Tree #101 Symmetric Tree #104 Maximum Depth of Binary Tree #108 Convert Sorted Array to Binary Search Tree #110 Balanced Binary Tree #100 Same Tree 要求:给定2个树,判断是否完全相同思路1:递归判别即可,上代码class Solution {public: bool isSameTree(TreeNode* p,原创 2021-08-18 21:02:27 · 170 阅读 · 0 评论 -
LeetCode Easy 前16-20道
#69 Sqrt(x)#70 Climbing Stairs#83 Remove Duplicates from Sorted List#88 Merge Sorted Array#94 Binary Tree Inorder Traversal#69 Sqrt(x)要求:给定非负整数,求其整数平方根,不能使用库函数思路1:从0开始逐渐平方往给定数值靠近。但是总感觉这个方法很一般,倒是能通过class Solution {public: int mySqrt(int x) {原创 2021-08-14 19:26:22 · 228 阅读 · 0 评论 -
LeetCode Easy 前11-15道
#35 Search Insert Position#53 Maximum Subarray#58 Length of Last Word#66 Plus One#67 Add Binary#35 Search Insert Position要求:给定排序数组和一个数字,返回数字在数组中的索引,或者找不到时,返回插入位置的索引,算法O(logN)思路1:O(n)容易,遍历即可,但不符合题目要求。class Solution {public: int searchInsert(v原创 2021-08-13 16:24:44 · 173 阅读 · 0 评论 -
LeetCode Easy 前6-10道
#20 Valid Parentheses#21 Merge Two Sorted Lists#26 Remove Duplicates from Sorted Array#27 Remove Element#28 Implement strStr()#20 Valid Parentheses要求:给定括号字符串,判断是否有效括号串思路1:遍历字符串,栈结构,压栈时,判断与栈顶的关系;匹配则弹出。不匹配继续入栈。最后判断栈是否为空。一次通过。class Solution {public:原创 2021-08-12 17:27:15 · 94 阅读 · 0 评论 -
LeetCode Easy 前1-5道
LeetCode Easy 前5道1 Two Sum7 Reverse Integer9 Palindrome Number13 Roman to Integer14 Longest Common Prefix原创 2021-08-11 22:02:16 · 109 阅读 · 0 评论