04 2019 档案
654. Maximum Binary Tree最大二叉树
摘要:网址:https://leetcode.com/problems/maximum-binary-tree/ 参考: https://leetcode.com/problems/maximum-binary-tree/discuss/106146/C%2B%2B-O(N)-solution 我自己的做
阅读全文
102. Binary Tree Level Order Traversal二叉树层序遍历
摘要:网址:https://leetcode.com/problems/binary-tree-level-order-traversal/ 参考:https://www.cnblogs.com/grandyang/p/4051321.html 二叉树的层次遍历的做法是维护一个队列,不断使节点入队,使用了
阅读全文
983. Minimum Cost For Tickets
摘要:网址:https://leetcode.com/problems/minimum-cost-for-tickets/ 参考:https://leetcode.com/problems/minimum-cost-for-tickets/discuss/226659/Two-DP-solutions-w
阅读全文
229. Majority Element II求众数II
摘要:网址:https://leetcode.com/problems/majority-element-ii/ 参考:https://blog.csdn.net/u014248127/article/details/79230221 摩尔投票算法( Boyer-Moore Voting Algorith
阅读全文
169. Majority Element求众数
摘要:网址:https://leetcode.com/problems/majority-element/ 参考:https://blog.csdn.net/u014248127/article/details/79230221 不断的消去两个不同的数,最后剩下的数肯定是所求的众数! 细节:
阅读全文
567. Permutation in String字符串的排列(效率待提高)
摘要:网址:https://leetcode.com/problems/permutation-in-string/ 参考:https://leetcode.com/problems/permutation-in-string/discuss/102588/Java-Solution-Sliding-Wi
阅读全文
51. N-Queens N皇后
摘要:网址:https://leetcode.com/problems/n-queens/ 类似见:https://www.cnblogs.com/tornado549/p/10701124.html
阅读全文
52. N-Queens II N皇后II
摘要:网址:https://leetcode.com/problems/n-queens-ii/ 方法1:按照逻辑思路,通过回溯法解决问题。速度较慢! 方法2:位运算 参考:https://www.bilibili.com/video/av46292575/?p=43
阅读全文
322. Coin Change零钱兑换
摘要:网址:https://leetcode.com/problems/coin-change/ 典型的动态规划问题,类比背包问题,这就是完全背包问题
阅读全文
43. Multiply Strings字符串相乘
摘要:网址:https://leetcode.com/problems/multiply-strings/submissions/ 参考:https://leetcode.com/problems/multiply-strings/discuss/17605/Easiest-JAVA-Solution-w
阅读全文
977. Squares of a Sorted Array有序数组的平方
摘要:网址:https://leetcode.com/problems/squares-of-a-sorted-array/ 双指针法 把左端的元素和右端的元素比较后挑出绝对值大的,将其平方放入ans中,并且将指针往中间移动 不断循环上述过程,直至两指针重合。注意处理重合位置 最后将 ans 通过 rev
阅读全文
1018. Binary Prefix Divisible By 5可被 5 整除的二进制前缀
摘要:网址:https://leetcode.com/problems/binary-prefix-divisible-by-5/ 一次for循环遍历数组,在上次计算的基础上得到本次的结果!
阅读全文
1021. Remove Outermost Parentheses删除最外层的括号
摘要:网址:https://leetcode.com/problems/remove-outermost-parentheses/ 使用栈的思想,选择合适的判断时机 删除最外层的括号
阅读全文
1022. Sum of Root To Leaf Binary Numbers从根到叶的二进制数之和
摘要:网址:https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/ 递归调用求和,同时注意%1000000007的位置
阅读全文
3. Longest Substring Without Repeating Characters无重复字符的最长子串
摘要:网址:https://leetcode.com/problems/longest-substring-without-repeating-characters/ 显然采用sliding window滑动窗口法,辅助以哈希表,判断字符是否已使用 不断扩充 j,直到 s[j] 已经使用 此时,把 i 移
阅读全文
946. Validate Stack Sequences验证栈序列
摘要:网址:https://leetcode.com/problems/validate-stack-sequences/ 参考:https://leetcode.com/problems/validate-stack-sequences/discuss/197667/Java-straight-forw
阅读全文
238. Product of Array Except Self除自身以外数组的乘积
摘要:网址:https://leetcode.com/problems/product-of-array-except-self/ 参考:https://leetcode.com/problems/product-of-array-except-self/discuss/65622/Simple-Java
阅读全文
91. Reverse Linked List 反转链表
摘要:网址:https://leetcode.com/problems/reverse-linked-list/ 直接参考92:https://www.cnblogs.com/tornado549/p/10639756.html
阅读全文
92. Reverse Linked List II 反转链表 II
摘要:网址:https://leetcode.com/problems/reverse-linked-list-ii/ 核心部分:通过a、b、c三个变量之间的相互更新,不断反转部分链表 然后将反转部分左右两端接上! 当测试数据 m 为 1 时,原始代码行不通。 故我们在原head前加一个fake_h节点,
阅读全文
浙公网安备 33010602011771号