- 博客(28)
- 收藏
- 关注
原创 LeetCode53-最大子序和
分治法:class Solution {public: int maxSubArray(vector<int>& nums) { if(nums.size()==0)return 0; return helper(nums,0,nums.size()-1); } int helper(vector<int&g...
2019-09-17 01:09:20 107
原创 八皇后问题
#include<iostream>#include<math.h>using namespace std;int n = 8;int total = 0;int *c = new int(n); //也可以写为int c[n];表示皇后放在第几列bool check(int curRow){ //放当前行的皇后时,只需要检查跟前面那些行的皇后有...
2019-09-17 00:00:12 351
原创 LeetCode-字符串-38-49-151
38报数:class Solution { public String countAndSay(int n) { String s = "1"; int k; for (int i = 1; i < n; i++) { StringBuilder t = new StringBuilder(); ...
2019-08-13 15:13:24 119
原创 AcWing-82-圆圈中最后剩下的数字
1.数组模拟环:2.链表实现:public int LastRemaining_Solution(int n, int m) { // 使用LinkedList模拟,排除一个删一个 LinkedList<Integer> list = new LinkedList(); for(int i = 1; i <= n; i++) { ...
2019-07-26 15:03:11 128
原创 AcWing-80-骰子的点数
C++实现代码:class Solution {public: vector<int> numberOfDice(int n) { vector<vector<int>> dp(n + 1, vector<int>(6 * n + 1, 0)); dp[0][0] = 1; for(in...
2019-07-26 14:45:35 129
原创 LeetCode-239-滑动窗口最大值
双端队列实现:class Solution {public: vector<int> maxSlidingWindow(vector<int>& nums, int k) { vector<int>vec; deque<int>q; for(int i=0;i<nu...
2019-07-26 11:29:51 167
原创 LeetCode-987-二叉树的垂序遍历
C++实现:class Solution {public: map<int,vector<int> > m;// record idx unordered_map<int,int> h; //record high void preorder(int idx,TreeNode* root,int high){//前序遍历 记录位置...
2019-07-26 10:18:28 138
转载 LeetCode-多线程-1114
1114转载自:https://blog.csdn.net/fuxuemingzhu/article/details/95889253
2019-07-22 17:15:34 178
转载 LeetCode-树专题-94-105-102-236-297-543-124-173
94转载自:https://blog.csdn.net/weixin_42130471/article/details/80403114105转载自:https://blog.csdn.net/qq_40163148/article/details/89214880102转载自:https://blog.csdn.net/zhangyumengs/article/details...
2019-07-22 15:31:49 110
原创 LeetCode101- 对称二叉树
C++递归版本/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cl...
2019-07-22 15:00:27 78
原创 LeetCode98-验证二叉搜索树
中序遍历存入数组,最后为增序即可!/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode(int x) : val(x), left(NULL), right(NUL...
2019-07-22 10:53:31 69
原创 JDBC注意小细节!
版本问题,可能输入不一样,加粗部分是需要额外添加的代码串!conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/MyDB?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false", "root", "12...
2018-11-27 15:26:15 117
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人