笔记
qq_45403704
这个作者很懒,什么都没留下…
展开
-
八大排序算法
https://www.cnblogs.com/morethink/p/8419151.html原创 2021-09-02 11:53:28 · 59 阅读 · 0 评论 -
图的操作最短路径最小生成树问题
import java.util.*;import java.util.Queue;import java.util.Stack;//有权无向图public class Graph { public Vertex[] vertexList; //存放顶点 public int[][] mGraph; //用矩阵表示边 public int size; //当前顶点数 public int[] distance; //原创 2021-09-01 17:51:17 · 71 阅读 · 0 评论 -
树的遍历插入最小平衡子树
import javax.swing.tree.TreeNode;import java.util.*;import java.util.Queue;import java.util.Stack;public class BinaryTreeNode { public Tree construct(int[] preorder, int[] inorder){ // 输入的合法性判断 if (preorder == null || inorder == nu原创 2021-09-01 15:00:41 · 99 阅读 · 0 评论 -
青蛙跳台阶和斐波那契数列
青蛙跳台阶class Solution {public: int numWays(int n) { int a = 1, b = 1, sum; for(int i = 0; i < n; i++){ sum = (a + b) % 1000000007; a = b; b = sum; } return a; }};斐波那契数列class原创 2021-08-16 11:48:03 · 57 阅读 · 0 评论 -
输入某二叉树的前序遍历和中序遍历的结果,请构建该二叉树并返回其根节点。
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: vector<int> Preorder ;原创 2021-08-16 11:39:39 · 538 阅读 · 0 评论 -
反转数组四种方式
https://blog.csdn.net/pro1515151515/article/details/90383807原创 2021-08-16 10:19:19 · 86 阅读 · 0 评论 -
2021-07-24
class Solution {public: vector<int> intersect(vector<int>& nums1, vector<int>& nums2) { vector<int> x; int j; sort(nums1.begin(),nums1.end()); //排序预处理 sort(nums2.begin(),nums2.end());原创 2021-07-24 19:13:08 · 57 阅读 · 0 评论 -
层次遍历存储
class Solution {public: vector<int> levelOrder(TreeNode* root) { if(!root) return {}; //如果节点为空放回空容器 queue<TreeNode*> data; //定义一个队列 TreeNode* p=root; //新增一个节点将头节点赋值给他 TreeNode* s; vector<in原创 2021-07-23 17:01:49 · 63 阅读 · 0 评论 -
2021-07-23
class Solution {public: bool validateStackSequences(vector<int>& pushed, vector<int>& popped) { stack<int> data; if(pushed.size() == 0 && popped.size() == 0){ return true; }原创 2021-07-23 16:13:34 · 47 阅读 · 0 评论 -
转圈循环数组
class Solution {public: vector<int> spiralOrder(vector<vector<int>>& matrix) { vector <int> x; if(matrix.empty()) return x; int top=0; int rh=matrix[0].size()-1; int rl=0; int原创 2021-07-23 15:36:09 · 88 阅读 · 0 评论 -
2021-07-23
class Solution {public: bool isSymmetric(TreeNode* root) { if(!root) return true; return Helper(root->left, root->right); } bool Helper(TreeNode* left, TreeNode* right) { if(!left && !right) {原创 2021-07-23 14:55:08 · 46 阅读 · 0 评论 -
镜像树xxx
TreeNode* mirrorTree(TreeNode* root) { if(!root) return root; TreeNode* tmp = root->left; root->left = root->right; root->right = tmp; mirrorTree(root->left); mirrorTree(root->right); .原创 2021-07-23 14:32:14 · 48 阅读 · 0 评论 -
2021-07-23
class Solution {public: int findRepeatNumber(vector<int>& nums) { unordered_set<int> c1; //定义哈希表存储数组 for(int num : nums) { if(c1.find(num)!=c1.end()) //利用迭代器判断是否存在这个元素 { return num;原创 2021-07-23 14:15:29 · 48 阅读 · 0 评论 -
2021-05-08
Android Studio中使用webview加载URL出现net::ERR_CLEARTEXT_NOT_PERMITTED cleartext为明文 permitted表示允许 即加载http时明文不被允许从Android 9.0(API级别28)开始,默认情况下禁用明文支持。因此http的url均无法在webview中加载因此需要添加允许权限<applicationandroid:allowBackup=“true”android:icon="@mipmap/ic_launcher"原创 2021-05-08 11:20:12 · 117 阅读 · 3 评论 -
二叉树层次遍历
class Solution {public: vector<vector<int>> levelOrder(TreeNode* root) { queue<TreeNode*> r; //定义一个队列储存树节点 vector<vector<int>> res; //定义一个容器储存多个储存整数的容器 if(root==NULL) //如果根节点为空返回res容器 { ret原创 2021-04-23 19:36:17 · 58 阅读 · 0 评论 -
递归实现判断两棵树是否相同
class Solution {public: void check(TreeNode *p,TreeNode *q,int &i) { if(p!=NULL&&q!=NULL) { if(p->val!=q->val) { i=0; return; } check(p->le原创 2021-04-23 18:07:51 · 393 阅读 · 0 评论 -
中序遍历递归实现栈实现
class Solution {public:void inorder(TreeNode* root, vector& a) {if (!root) {return;}inorder(root->left, a);a.push_back(root->val);inorder(root->right, a);};vector<int> inorderTraversal(TreeNode* root) { vector<int> a;原创 2021-04-23 17:56:15 · 133 阅读 · 0 评论 -
涂方格
class Solution {public int paintingPlan(int n, int k) {int res = 0;//边界问题if(k == 0)return 1;if(k == n * n)return 1; //第一层循环表示涂 i 行 第二层循环表示涂 j 列 for(int i = 0;i <= n;i++){ for(int j = 0;j <= n;j++) //当你涂了 i 行 j 列 则有 i原创 2021-03-02 16:20:13 · 98 阅读 · 0 评论 -
奇数位于偶数前面
class Solution { public int[] exchange(int[] nums) { int left = 0; int right = nums.length - 1; while (left < right) { while (left < right && nums[left] % 2 != 0) { left++; }原创 2021-03-01 19:11:08 · 43 阅读 · 0 评论