自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 关于个人定位的问题

我记得以前老师说过,不要随意给别人贴标签,后来我感觉,贴标签也不是什么坏事,甚至我想给自己贴贴标签,因为标签代表一个人属于某一个类别,而这个类别大概率从全人类来看是属于一个群体的,那么我就在这个方面找到了社会中的一个群体,我在这个方面找到了我在社会中的一个定位,我感觉这在认识自己这个方面是有好处的。自然科学——太宽广的一个概念,一直以来,科学能改变人的认识,推动人们生活整体变好,但是个人的力量太过渺小,能在短短的人生过程中,学习和创造一点点价值,足矣。计算机——工作的技能,也是现代科学的核心技术工具。

2024-03-24 17:02:14 240

原创 linux环境安装secretflow

secrertflow installation

2023-01-23 14:48:08 701

原创 Leetcode链表练习总结

Leetcode链表练习总结

2022-06-15 02:27:17 115

原创 Leetcode数组练习总结

leetcode数组练习

2022-06-11 23:08:34 119

原创 字符全排列(字典序)

给定一个字符序列,按照字典序,依次输出所有的全排列#include <iostream>#include <vector>#include <map>using namespace std;vector<char> v; // origin char listmap<char, int> m; // record charvector<vector<char>> result; // .

2022-02-15 10:51:34 376

原创 The Castle题解

链接#include <iostream>#include <cstring>using namespace std;const int MAXN = 60;const int MAXM = 60; // 最大的房间数量int N, M;int map[MAXN][MAXM]; // 记录输入数据bool visit[MAXN][MAXM]; // 辅助数组,记录是否访问过,dfs要用到// x, y表示房间的横纵坐标,返回相连的房间数量int df

2021-10-10 21:56:54 170

原创 螺旋矩阵题解

链接class Solution { vector<int> v;public: vector<int> spiralOrder(vector<vector<int>>& matrix) { if (matrix.size() == 0) return v; spiralOrder(matrix, 0, matrix.size() - 1, 0, matrix[0].size() - 1);

2021-09-28 22:36:00 50

原创 相同的树题解

链接/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

2021-09-28 21:59:00 80

原创 最后一个单词的长度题解

链接class Solution {public: int lengthOfLastWord(string s) { int len = 0; int j = s.size() - 1; while (s[j] == ' ') --j; for (; j >= 0; j--) { if (s[j] == ' ') { break; } else {

2021-09-28 21:50:12 43

原创 删除排序链表中的重复元素题解

链接/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne

2021-09-28 21:39:36 46

原创 链表排序题解

链接/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne

2021-09-25 16:17:27 190

原创 最长不含重复字符的子字符串

链接class Solution {public: int lengthOfLongestSubstring(string s) { int i = 0; // 指标,指示最长子串的起始位置 int result = 0; // 存放结果 unordered_map<char, int> umap; // 记录字符、下标的hash表 for (int j = 0; j < s.size(); j++) {

2021-09-15 23:18:39 57

原创 输出规律图形例题(叠框)

#include<iostream>using namespace std;int main() { int k; char center; char outer; int i_index, j_index; scanf("%d %c %c", &k, &center, &outer); // 输入一个奇整数,两个字符 int mode = ((k - 1) / 2) % 2; // 判断先输出center还是ou

2021-09-06 15:50:23 185

原创 判断两个日期之间间隔天数

#include<iostream>using namespace std;// 设置一个自己的日期类typedef struct MyDate { int year; int month; int day;}MyDate;// 存放每月的天数(闰年需要判断后在2月+1)int month_day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};// 根据一个输入的整数,转化为自己的日期类

2021-09-05 20:52:03 340

原创 根据前序和后序遍历构造二叉树题解

链接/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

2021-08-06 11:25:31 55

原创 找出顶峰元素题解

链接class Solution {public: vector<int> findPeakGrid(vector<vector<int>>& mat) { int rowh = mat.size() - 1; int rowl = 0; int rowm = -1; int maxValueIndex = -1; vector<int> ret{-1,-1};

2021-08-06 10:56:33 158

原创 前序中序遍历序列构造二叉树

链接/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

2021-08-05 17:28:02 87

原创 颠倒二进制位题解

链接class Solution {public: uint32_t reverseBits(uint32_t n) { uint32_t ret = 0; for (int i = 0; i < 32; i++) { if (n & (1 << i)) { flipBit(ret, 31-i); } } return ret;

2021-08-05 15:32:17 45

原创 **所有可能的满二叉树题解

链接/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

2021-08-05 11:38:06 54

原创 **字符串解码题解

链接class Solution {public: string decodeString(string s) { int num = 0; string ret = ""; stack<string> str; stack<int> n; int len = s.size(); for (int i = 0; i < len; ++i) { if

2021-07-10 23:19:33 108

原创 重排链表题解

链接/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne

2021-07-10 19:48:28 121

原创 反转字符串题解

链接class Solution {public: void reverseString(vector<char>& s) { char tmp; for (int i = 0; i < s.size()/2; ++i) { tmp = s[i]; s[i] = s[s.size()-1-i]; s[s.size()-1-i] = tmp; }

2021-07-10 18:40:51 65

原创 3的幂题解

链接class Solution {public: bool isPowerOfThree(int n) { if (n == 0) return false; if (n == 1) return true; if (n % 3 != 0) return false; else return isPowerOfThree(n/3); }};思路先判断0和1,若大于1,则通过是否整除3进行判断;要点注意在n

2021-07-10 18:08:03 50

原创 反转链表题解

链接/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne

2021-07-10 18:01:08 72

原创 移除链表元素题解

链接/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne

2021-07-10 17:44:05 71

原创 合并两个有序链表题解

链接/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne

2021-07-10 17:31:46 37

原创 有效的数独题解

链接class Solution {public: bool isValidSudoku(vector<vector<char>>& board) { int v_tmp[11] = {0}; int index,r,c; for (int i = 0; i < 9; i++) { memset(v_tmp, 0, sizeof(v_tmp)); for (int

2021-07-05 22:17:02 35

原创 下一个排列题解

链接class Solution {public: void nextPermutation(vector<int>& nums) { int index = -1; int tmp; for (int i = nums.size()-1; i > 0; --i) { if (nums[i-1] < nums[i]) { index = i-1;

2021-06-15 23:23:48 38

原创 盛最多水的容器题解

链接class Solution {public: int maxArea(vector<int>& height) { int i = 0; int j = height.size() - 1; int max_v = 0; int tmp_v = 0; while (i < j) { tmp_v = min(height[i], height[j]) * (j -

2021-06-10 22:34:52 56

原创 第三大的数题解

链接class Solution {public: int thirdMax(vector<int>& nums) { int index = 1; int i = 0; int pre; sort(nums.begin(), nums.end()); for (i = nums.size() - 1; i >= 0; i--) { if (i == nums.siz

2021-06-10 16:25:49 58

原创 种花问题题解

链接class Solution {public: bool canPlaceFlowers(vector<int>& flowerbed, int n) { int count = 0; for (int i = 0; i < flowerbed.size();) { if (flowerbed[i] == 1) { if (i > 0) flowerbed[i-1] = 1

2021-06-10 16:15:16 126

原创 二进制矩阵中的特殊位置题解

链接class Solution {public: int numSpecial(vector<vector<int>>& mat) { int row = mat.size(); int col = mat[0].size(); int c_index = -1; int r_nums = 0; int count = 0; for (int i = 0; i &lt

2021-06-05 22:41:11 49

原创 重塑矩阵题解

链接class Solution {public: vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) { if (mat.size() * mat[0].size() != r * c) { return mat; } vector<vector<int>

2021-06-05 21:54:11 119

原创 复写零题解

链接class Solution {public: void duplicateZeros(vector<int>& arr) { vector<int> temp(arr.size()); temp[0] = 0; for (int i = 0; i < arr.size() - 1; i++) { if (arr[i] == 0) {

2021-06-04 23:13:06 53

原创 多数元素题解

链接class Solution {public: int majorityElement(vector<int>& nums) { int mid = nums.size() / 2; sort(nums.begin(), nums.end()); return nums[mid]; }};思路第一种:使用map数据结构,遍历数组,map中有则计数加一;在map中找到最大值;第二种:先对数组进行排序,按照定

2021-06-04 22:38:43 38

原创 买卖股票的最佳时机题解

链接class Solution {public: int maxProfit(vector<int>& prices) { int lowest_price = prices[0]; int profit = 0; for (int i = 0; i < prices.size(); i++) { if (profit < prices[i] - lowest_price) {

2021-06-03 23:25:47 62

原创 最大子序和题解

链接class Solution {public: int maxSubArray(vector<int>& nums) { int max = nums[0]; int tmpSum = 0; int index = 0; while (max < 0) { while (index < nums.size()) { if (nums[inde

2021-06-03 22:52:43 62

原创 删除有序数组中的重复项题解

链接class Solution {public: int removeDuplicates(vector<int>& nums) { if (nums.size() < 2) { return nums.size(); } int i = 0; int j = 1; while (j < nums.size()) { if (nums[

2021-06-03 00:06:24 62

原创 两数之和题解

链接class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> ret(2); for (int i = 0; i < nums.size(); i++) { for (int j = i + 1; j < nums.size(); j++) {

2021-06-02 23:51:55 121

原创 常见排序算法实现

插入排序#include<stdio.h>// 插入排序void sort(int *array, int start, int end) { int tmp,i,j; for (i = start + 1; i < end; i++) { // 取出待排元素 tmp = array[i]; for (j = i - 1; j >= start; j--) { // 元素后移,找到合适位置

2021-03-12 22:32:21 65

空空如也

空空如也

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

TA关注的人

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