Leetcode 72. Edit Distance 发表于 2019-12-01 | 分类于 Online Judge https://leetcode.com/problems/edit-distance/ 递归:123456789101112131415161718192021222324252627282930313233343536373839404142434445class Solution { ... 阅读全文 »
Leetcode 42. Trapping Rain Water 发表于 2019-12-01 | 分类于 Online Judge https://leetcode.com/problems/trapping-rain-water/ 第一种解法是单调栈 1234567891011121314151617181920212223242526272829303132class Solution {public: in ... 阅读全文 »
2019_被3整除 发表于 2019-11-04 | 分类于 Online Judge https://www.nowcoder.com/practice/51dcb4eef6004f6f8f44d927463ad5e8?tpId=98&tqId=32825&tPage=1&rp=1&ru=/ta/2019test&qru=/ta/2019tes ... 阅读全文 »
Hdu 2045. 涂色问题 发表于 2019-11-03 | 分类于 Online Judge http://acm.hdu.edu.cn/showproblem.php?pid=2045 12345678910111213141516171819202122232425#include <cstdio>//题意:三种颜色涂色,相邻不同颜色,首尾不同色,多少种涂色方案//看成一个环 ... 阅读全文 »
Leetcode 198. House Robber 发表于 2019-10-24 | 分类于 Online Judge https://leetcode.com/problems/house-robber/ 题意:抢劫,返回能抢到的最大数值,但是如果连续抢两个的话就会报警 思路:不会做伤心。。。 动态规划问题,遍历数组,对每一个元素考虑两种情况,抢它和不抢它 123456789101112131415class So ... 阅读全文 »
Leetcode 102. Binary Tree Level Order Traversal 发表于 2019-10-23 | 分类于 Online Judge https://leetcode.com/problems/binary-tree-level-order-traversal/ 题意:二叉树的层序遍历 代码: 12345678910111213141516171819202122232425262728293031323334353637/** ... 阅读全文 »
Leetcode 94. Binary Tree Inorder Traversal 发表于 2019-10-23 | 分类于 Online Judge https://leetcode.com/problems/binary-tree-inorder-traversal/ 二叉树的中序遍历 递归:1234567891011121314151617181920212223/** * Definition for a binary tree node. ... 阅读全文 »
Leetcode 10. Regular Expression Matching 发表于 2019-10-21 | 分类于 Online Judge https://leetcode.com/problems/regular-expression-matching/ 题意:正则表达式匹配 代码:1234567891011121314151617181920212223242526class Solution {public: bo ... 阅读全文 »
Leetcode 5. Longest Palindromic Substring 发表于 2019-10-18 | 分类于 Online Judge https://leetcode.com/problems/longest-palindromic-substring/ 题意:搜索一个字符串中最长的回文序列 思路:回文序列的搜索以中间一个单独一个字母和中间两个相同字符分为两类 代码123456789101112131415161718192021 ... 阅读全文 »
Leetcode 4. Median of Two Sorted Arrays 发表于 2019-10-18 | 分类于 Online Judge https://leetcode.com/problems/median-of-two-sorted-arrays/ 这道题的题意是给定两个已经排好序的数组,求这两个数组所有数字的中位数,要求时间复杂度是O(log(m+n))的(应该自然想到是二分法) 这道题感觉有点难,看了半天代码也看不懂是什么意 ... 阅读全文 »