自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 pycharm出现path is on mount ‘C:‘, start on mount ‘D:‘的问题

解决办法:将关于项目的所有文件和路径都放在一个盘中,不要分开放。例如:python编译器放c盘,python项目放c盘torch.hub.load()下载路径也在C盘。那么就可以解决了。

2022-02-24 09:44:18 2907

原创 avx指令+openmp多线程实现一个基本算法作业 c++

原代码数学思路point类//文件1,类的定义,point.h#ifndef _POINT_H#define _POINT_Hclass Point{public: Point(float x=0, float y=0) :x(x), y(y) {} float GetX() const {return x;} float GetY() const {return y;}private: float x,y;};#endif主函数//主函数,ma

2021-02-28 20:39:17 1260

原创 leetcode638 c++貌似不能开太大数组,需要把数组映射成数,不然会出错

注释掉的程序结果错误,但映射出来的结果正确class Solution {public: // int dp[7][7][7][7][7][7]; unordered_map<int,int> mp; int shoppingOffers(vector<int>& price, vector<vector<int>>& special, vector<int>& needs) {

2020-07-22 11:28:58 156

原创 风城用文章收藏

算法基础:康托展开与逆康托展开https://blog.csdn.net/ajaxlt/article/details/86544074

2020-07-15 11:16:53 118

原创 并查集模板

递归版并查集模板class Unionfind{private: vector<int> parents;public: //初始化每个点,每个点的父亲节点都指向自己 Unionfind() { for(int i=0;i<26;i++){ parents.push_back(i); } } //查找根节点 int find(int index){ if(paren

2020-06-24 21:05:56 97

原创 二叉树序列化和反序列化(bfs),和leetcode一致

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Codec {public: // Encodes a tree to a single str

2020-06-19 10:29:38 199

原创 翻转反转从位置 m 到 n 的链表,c++,双100%

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* re...

2020-04-14 19:11:21 485

原创 leetcode 1131 获取你好友已观看的视频

class Solution {public: vector<string> watchedVideosByFriends(vector<vector<string>>& watchedVideos, vector<vector<int>>& friends, int id, int level) { ...

2020-01-10 14:18:11 363

原创 leetcode 84 柱状图中最大的矩形

class Solution {public: int largestRectangleArea(vector<int>& heights) { stack<int> s; int res=0, i=0, size=heights.size(); int left=-1, right=size, val,s_...

2020-01-09 11:17:33 70

原创 一定要注意好运算符优先级

关于运算符的优先级string s="12345";(s[1]-'0' *10) //不等于20 等于50 -48*10 = -430 int uniquePaths(int m, int n) { long long res=1; int k=m+n-2; for(int i=1;i<=m-1;i++){ r...

2020-01-06 10:47:51 81

原创 leetcode669 修剪排序二叉树

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas...

2019-12-31 20:01:55 120

原创 leetcode 859 亲密字符串

条件太多了,差点崩溃…class Solution {public: bool buddyStrings(string A, string B) { int sum[27]={0}; int len1=A.size(); int len2=B.size(); if(len1!=len2 || len1<2 || le...

2019-11-29 20:25:15 122

原创 字符串乘法 只能用于短整数 明天看看长的怎么弄

class Solution {public: string multiply(string num1, string num2) { int len1 =num1.size(); int len2 =num2.size(); long long carry=0; long long n=1; long lo...

2019-11-27 12:59:26 78

原创 矩阵重叠问题

bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) { if(rec1[1]>=rec2[3] || rec1[3]<=rec2[1])//这样正确 if(rec1[1]<=rec2[3] || rec1[3]&gt...

2019-11-25 20:44:59 485

原创 要好好利用工具

要利用好string::erase()//抹除string中的某些字符string::c_str() //把string转成字符数组还有vector::insert()//把一个vector的元素加在另一个vector里面vector<int> aa(10,1); vector<int> bb(10,2); aa.insert(aa.end(),bb...

2019-06-30 22:52:29 122

原创 递归subsets没搞懂的问题

不知道为什么会这样输出,都输出了两次InputShow Difference[1,2,3]Output[[],[],[1],[1],[1,2],[1,2],[1,2,3],[1,2,3],[1,3],[1,3],[2],[2],[2,3],[2,3],[3],[3]]Expected[[],[1],[1,2],[1,2,3],[1,3],[2],[2,3],[3]]class ...

2019-06-30 16:48:03 102

原创 二叉树的按层序列化和反序列化

二叉树的按层序列化 3 / \9 20 / \ 15 7it will be serialized {3,9,20,#,#,15,7}class Solution {public: /** * This method will be invoked first, you should design your own algorithm * ...

2019-06-30 15:24:51 295

原创 没搞懂的问题

class TreeNode { public: int val; TreeNode *left, *right; TreeNode(int val) { this->val = val; this->left = this->right = NULL; } };class So...

2019-06-29 17:11:41 72

原创 将所有子节点的值为x的所有父节点的值求和哦

Examples:Input : Binary tree with x = 2: 4 / \ 2 5 / \ / \ 7 2 2 3 Output : 11 4 / \ 2 5 / \ / \ 7 2 2 3 The ...

2019-04-12 17:13:39 715

原创 求二叉树所有节点的和 递归方式

风之城的求二叉树所有节点的和 递归方式/* Program to print sum of all the elements of a binary tree */#include <iostream> using namespace std; struct Node { int key; Node* left, *right; }; /* utility th...

2019-04-12 16:36:44 2062

原创 用非递归的方法中序遍历一个二叉树

风之城的非递归中序遍历二叉树// C++ program to print inorder traversal // using stack. #include<bits/stdc++.h> using namespace std; struct Node { int data; struct Node* left; struct Node* ...

2019-04-12 16:15:50 1056

原创 插入一个节点至二叉树,在第一个可行的位置

风之城的插入二叉树// C++ program to insert element in binary tree #include <iostream> #include <queue> #include "stdlib.h"using namespace std; /* A binary tree node has key, pointer to left...

2019-04-12 14:47:38 371

原创 递归的一些有趣的题(二)

风之城的有趣的递归哦#include<stdio.h> /* fun(4); / fun(3), print(3), fun(2)(prints 0 1) / fun(2), print(2), fun(1)(prints 0) ...

2019-04-06 13:42:12 160

原创 递归的一些有趣的题(一)

风之城的有趣的递归哦#include <iostream>/* run this program using the console pauser or add your own getch, system("pause") or input loop *//* 输入4打印 * * * * * * * * * * */ void fun1(int n) { ...

2019-04-06 12:55:07 460

原创 遍历某一层的二叉树哦

风之城的遍历某一层的二叉树#include <iostream>#include "stdlib.h"struct Node{ int data; Node *left,*right; };Node* newNode(int data);void printLevelOrder(Node* root);void printGivenLevel(Node* root...

2019-04-05 21:55:01 338

原创 单链表的前7个操作哦

风之城的单链表#include <iostream>#include "stdlib.h"//Node结构体 struct Node{ int data; struct Node *next;}; //从头部添加新节点,新节点变为新的头部 void push(Node **head, int data){ Node *new_node = (Node*) ...

2019-04-05 16:52:51 67

原创 归并排序哦

风之城的归并排序#include<stdlib.h> #include<stdio.h> void merge(int arr[], int l, int m, int r){ int i,j,k; //n1为mid左边数组的大小 //n1为mid右边数组的大小 int n1 = m - l + 1; int n2 = r - m; //将数组初始...

2019-04-04 22:16:52 111

原创 插入排序哦

风之城的插入排序#include <iostream>void swap(int *a , int *b){ int temp = *a; *a = *b; *b = temp; }void printArray(int arr[], int size) { int i; for (i=0; i < size; i++) ...

2019-04-04 15:36:51 60

原创 冒泡排序

风之城的冒泡排序#include <iostream>/* run this program using the console pauser or add your own getch, system("pause") or input loop */void swap(int *a , int *b){ int temp = *a; *a = *b; *b = t...

2019-04-04 14:10:24 72

空空如也

空空如也

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

TA关注的人

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