自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 【二叉树复习

二叉树:这是求最近祖先算法#include<iostream>using namespace std;const int maxn=51;struct Node{ int left;int right;}nodes[maxn];int LCA(int root,int k1,int k2){ if(root==-1) return -1;//一旦空 返回-1 然后上一层判断 if(root==k1||root==k2) return root;//遇见匹配的

2022-06-02 11:14:35 61

原创 复习排序。。。(今天效率好低啊)

#算法的稳定性:存在多个具有相同排序码的记录,排序后这些记录的相对次序保持不变#理想的空间效率:算法执行期间所需要的辅助空间与待排序的顺序无关折半插入排序快速排序:

2022-06-02 00:03:51 74

原创 duiduidui

// 2099. `找到和最大的长度为 K 的子序列`class Solution { class Pair{ public: int val; int idx; Pair() {} Pair(int v, int i) : val(v), idx(i) {} bool operator < (const Pair& o) const { return v

2022-05-29 21:04:09 121

原创 html2

2022-05-27 22:47:40 54

原创 html第一天

2022-05-26 15:56:03 55

原创 heibang

heibang#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <stack>#include <queue>#include <map>#include <cmath>#define INF 0x3f3f3f3f using namespace std;typedef l

2022-05-13 00:29:08 103

原创 记录改bug的第n天

虫子的生活虫子的生活#include<iostream>using namespace std;const int N = 2010;int pre[N], r[N];//pre存储i的父节点 r存储i和父节点的关系,0表示i和父节点是同性,1表示是异性 void init(int n){ for (int i = 0; i <= n; i++){ pre[i] = i;//自己为自己的父节点 r[i] = 0;//自己与自己是同性 }}int f

2022-05-06 14:23:38 167

原创 第一个值得思考

找出可行的回文串个数class Solution {public: bool canConstruct(string s, int k) { int hash[26]; int n = s.length(); memset(hash, 0, sizeof(hash)); for(int i = 0; i < n; i++) { hash[s[i] - 'a']++; //(1) }

2022-05-04 22:47:54 50

原创 03----5.1

(1)class Solution {public: vector<int> sortedSquares(vector<int>& nums) { vector<int>res; for(int num:nums){ res.push_back(num*num); } stable_sort(res.begin(),res.end()); return res; }};时间复杂度:O(

2022-05-03 22:37:31 280

原创 栓3-----

题目class Solution {public: int numSpecial(vector<vector<int>>& mat) { int rows=mat.size(); int cols=mat[0].size(); int rowcnt[rows]; int colcnt[cols]; memset(rowcnt,0,sizeof(rowcnt)); memset(colcnt,0,sizeof(colc

2022-04-30 21:43:47 416

原创 数据结构每日复习之链表1

多项式的加减乘除题目# include<iostream># include<algorithm>using namespace std;struct LNode{ int num; int pow; struct LNode * next;};void ListInsert(LNode * pHead, int a, int b){ LNode * p = new LNode; p->num = a; p->pow = b; p->n

2022-04-29 20:34:16 709

原创 栓2-----

唯一元素的 和class Solution {public: int sumOfUnique(vector<int>& nums) { int ans=0; int cnt[110]; memset(cnt,0,sizeof(cnt)); for(int i=0;i<nums.size();i++){ cnt[nums[i]]++; } for(int

2022-04-29 18:43:13 184

原创 栓1-------

class Solution {public: bool isPowerOfTwo(int n) { return n > 0 && (n & (n-1))==0; }};n&n-1==0 时 n为2的倍数class Solution {public: bool isPowerOfTwo(int n) { return n > 0 && (n & -n) == n;

2022-04-28 23:15:38 71

原创 第一天栓0

解压缩编码列表class Solution {public: vector<int> decompressRLElist(vector<int>& nums) { vector<int>res; for(int i=0;i<nums.size();i=i+2){ for(int j=nums[i];j>0;j--){ res.push_back(nums[i+1]);

2022-04-28 22:55:45 58

原创 呀呀呀呀呀

class Solution {public: int consecutiveNumbersSum(int n) { int ans=0; for(int k=1;n-(k-1)*k/2>0;k++){ if((n-(k-1)*k/2)%k==0)ans++; } return ans; }};题目class Solution {public: int consecutiveNumb.

2022-04-28 16:41:13 64

原创 滑动窗口k

‘’’class Solution {public:vector<vector> findContinuousSequence(int target) {int i = 1; // 滑动窗口的左边界int j = 1; // 滑动窗口的右边界int sum = 0; // 滑动窗口中数字的和vector<vector> res;while (i <= target / 2) { if (sum < target) { // 右边界向

2022-04-28 12:06:08 59

原创 螺旋矩阵(规律)

本来想找一找牛逼的解,看了一堆,麻了,直接找规律!!!#include<bits/stdc++.h>using namespace std;int n,i,j;int dfs(int n,int i,int j){ if(i==1){ return j; } if(j==n){ return n+i-1; } if(i==n){ return 3*n-j-1; } if(j==1){

2022-04-22 23:15:23 461

原创 字符串KMP算法

题目#include <iostream>#include <string>using namespace std;const int N = 100010, M = 1000010;int n, m;//int ne[N];char s[M], p[N];int * findNext(string p){ int j = 0; int k = -1; int m = p.length(); int * next = new int[m+10]; nex

2022-04-22 18:06:54 51

原创 中缀表达式的值

#include<iostream>#include<cstdio>#include<string>using namespace std;#include<stack>#include<queue>#include<map>struct node{ double num; char op; bool flag;};string str;stack<node>s;queue<node>

2022-04-19 18:23:13 114

原创 getline(str,90)

#include #include #includeusing namespace std;int main (){char str [90];cin.getline(str,90);int len = strlen ( str ), r =0, h =0;// r 为行, h 为列char ans [90][90];// ans [0]~ ans [ r ]存放单词for ( int i =0; i < len ; i ++){if ( str [ i ]!=’ ‘){ans

2022-03-24 16:39:40 65

原创 不知道搞了个啥,笔记

import java.io.File;import java.io.FileFilter;import java.io.IOException;public class FileDemo {public static void printDir(File dir) {/* if(dir.isFile()){System.out.println(dir);}else{File[] files=dir.listFiles();for(File file:files){if(file.i

2021-11-26 00:10:53 146

原创 2021-11-15

integr的compareto实现//compareTopublic int compareTo(Integer anotherInteger) { return compare(this.value, anotherInteger.value);}//comparepublic static int compare(int x, int y) { return (x < y) ? -1 : ((x == y) ? 0 : 1);}

2021-11-15 15:53:35 195

原创 2021-11-05

C语言复习1通过递归替代循环。通过短路运算符来替代条件判断。while(scanf("%d",&a))!=EOF)怎么结束?由于是手动输入(从键盘输入)的数据信息,所以我们要给让此类循环结束,需要我们键入ctrl+z 再加enter就结束了交换变量可用异或...

2021-11-05 00:19:32 55

原创 2021-02-05

第二个#includeusing namespace std;#includestruct hero{string sex;int age;string name;};void bubblesort(struct hero herroarray[], int len){for (int i = 0; i < len-1; i++){ for (int j = 0; j < len - 1 - i; j++) { if (herroarray[j].age>

2021-02-05 21:30:35 53

原创 2021-02-05

菜鸟学习C加加的第一天用结构体表示,老师和学生的信息#includeusing namespace std;#include#includestruct student{string name;int score;};struct teacher{string name;struct student sarray[5];};void allocatespace(struct teacher tarray[], int len){string nameseed = “ABC

2021-02-05 20:51:05 86

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除