![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
stevexiaofei
这个作者很懒,什么都没留下…
展开
-
打家劫舍——四联
标准打架劫色class Solution {public: int rob(vector<int>& nums) { if (nums.size() == 0) return 0; if (nums.size() == 1) return nums[0]; int first = nums[0]; int second = max(nums[1], nums[0])原创 2021-07-16 01:01:16 · 88 阅读 · 0 评论 -
不同的二叉搜索树
class Solution {public: vector<TreeNode *> backtrace(int b, int e) { vector<TreeNode*> res; if (b>e) { res.push_back(nullptr); return res; } for (int i=b; i <= e; i++) {原创 2021-07-14 23:05:50 · 54 阅读 · 0 评论 -
字符串匹配dp
https://leetcode-cn.com/problems/regular-expression-matching/submissions/class Solution {public: bool isMatch(string s, string p) { int len_s = s.size(); int len_p = p.size(); vector<vector<bool>> dp(len_s+1);原创 2021-07-07 00:45:00 · 131 阅读 · 0 评论 -
k个一组反转列表
https://leetcode-cn.com/problems/reverse-nodes-in-k-group//** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {}原创 2021-07-06 23:08:00 · 81 阅读 · 0 评论 -
旋转图像——48
旋转图像class Solution {public: void swap_(int& a, int& b, int& c, int& d) { if (&a==&b) return; auto tmp = d; d = c; c = b; b = a; a = tmp; } void rotate(vector&原创 2021-06-09 00:26:06 · 46 阅读 · 0 评论 -
快速排序——quicksort
快速排序#include <iostream>#include <bits/stdc++.h>using namespace std;int partition(vector<int>& nums, int b, int e) { cout<<b<<" "<<e<<endl; int p = b-1; for (int i = b; i < e; i++) { i原创 2021-06-08 23:45:30 · 61 阅读 · 0 评论 -
矩阵的蛇形打印
矩阵的蛇形打印#include <iostream>#include<bits/stdc++.h>using namespace std;vector<int> print_mat(vector<vector<int>> mat) { vector<int> res; int m = mat.size(); int n = mat[0].size(); int i=0; int j=0; bool reverse =原创 2021-05-29 17:13:08 · 122 阅读 · 0 评论