- 博客(7)
- 资源 (1)
- 收藏
- 关注
原创 killprocess
#include <bits/stdc++.h>#include <unordered_map>using namespace std;vector<int>son = { 2,1,3,6,10 };vector<int>father = { 10,6,7,4,1 };vector<int>ans;class solution{public: void recur_kill_son(unordered_map<int,
2021-12-05 20:31:28
73
原创 LC题解
LC题解:回溯算法经典题目N皇后问题:https://leetcode-cn.com/problems/n-queens//*经典回溯算法题目*/class Solution{public: vector<vector<string>>ans; vector<vector<string>> solveNQueens(int n) { vector<string> board(n,string(n,'
2021-05-15 15:42:26
69
原创 LC题解
399. 除法求值来源:https://leetcode-cn.com/problems/evaluate-division/本文仅为记录,作为学习提高之用。给你一个变量对数组 equations 和一个实数值数组 values 作为已知条件,其中 equations[i] = [Ai, Bi] 和 values[i] 共同表示等式 Ai / Bi = values[i] 。每个 Ai 或 Bi 是一个表示单个变量的字符串。另有一些以数组 queries 表示的问题,其中 queries[j] =
2021-05-14 22:07:39
95
原创 LC560
560. 和为K的子数组给定一个整数数组和一个整数 k,你需要找到该数组中和为 k 的连续的子数组的个数。示例 1 :输入:nums = [1,1,1], k = 2输出: 2 , [1,1] 与 [1,1] 为两种不同的情况。/*前缀和+hash*/class Solution{public: int subarraySum(vector<int>& nums, int k) { int cnt=0,pre=0; unor
2021-04-25 19:28:09
67
原创 DAG的拓扑排序
思想:维护一个入度为0的节点队列,每次出队一个并打印,然后删除所有从该节点出发的路径,并更新各个节点的入度,再次入队一个入度为0的节点,直至队列为空。/*topological sort of dag*/#include<bits/stdc++.h>using namespace std;class graph{public: graph(int V); ~graph(); void addedg(int v, int w); bool topological_sort(
2021-04-20 21:03:56
119
原创 LC题解:回文子串
LC题解5. 最长回文子串https://leetcode-cn.com/problems/longest-palindromic-substring/给你一个字符串 s,找到 s 中最长的回文子串。示例:输入:s = “babad”输出:“bab”解释:“aba” 同样是符合题意的答案。思路:暴力/中心扩散法/马拉车算法中心扩散法如下:class Solution {public: string longestPalindrome(string s) {
2021-04-20 19:18:14
103
原创 快速排序_quicksort
quicksort algorithm#include<bits/stdc++.h>using namespace std;int qsl(vector<int>& num, int l, int r){ if (l > r) { return 0; } int temp = num[l]; while (l != r) { while (l < r && num[r] >= temp)--r; num[l] = n
2021-04-09 00:32:23
98
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人