自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 第224场周赛 思维

1725. 可以形成最大正方形的矩形数目Noteo(n) 签到,1726. 同积元组Note思路:o(n^2)算出乘积值出现过的次数,再通过公式求得最终答案 A(2,2) * 4 * C(出现次数,2)Codeclass Solution: def tupleSameProduct(self, nums: List[int]) -> int: dic = defaultdict(int) for i in range(len(num

2021-01-24 23:18:09 155 1

原创 双周赛43 数学递推,递归,栈,[TODO]: 思维题

1716. 计算力扣银行的钱Note直接线性模拟,时间复杂度o(n),懒得贴代码了利用公式:7 * (7 + week) * / 2 + left * (left + 1) / 2 + left * week; 线性复杂度求出等差数列化简后可得i+(i+1)+(i+2)+…+(j-2)+(j-1)+j = (i+j)(j-i+1)/2;1717. 删除子字符串的最大得分Note做的时候xjb试了一下,竟然过了,事后分析了一下,整体思路如下所示:利用栈进行模拟,思路是第一遍删除所

2021-01-17 18:26:58 193 2

原创 223周赛 (快慢指针,并查集的操作(重复需删除),状态压缩dp)

1720. 解码异或后的数组整数数组 arr 由 n 个非负整数组成。经编码后变为长度为 n - 1 的另一个整数数组 encoded ,其中 encoded[i] = arr[i] XOR arr[i + 1] 。例如,arr = [1,0,2,1] 经编码后得到 encoded = [1,2,3] 。给你编码后的数组 encoded 和原数组 arr 的第一个元素 first(arr[0])。请解码返回原数组 arr 。可以证明答案存在并且是唯一的。示例 1:输入:encoded = [1,

2021-01-11 16:58:21 231

原创 Leecode周赛 222 [前缀和、LCS]

5641. 卡车上的最大单元数请你将一些箱子装在 一辆卡车 上。给你一个二维数组 boxTypes ,其中 boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi] :numberOfBoxesi 是类型 i 的箱子的数量。numberOfUnitsPerBoxi 是类型 i 每个箱子可以装载的单元数量。整数 truckSize 表示卡车上可以装载 箱子 的 最大数量 。只要箱子数量不超过 truckSize ,你就可以选择任意箱子装到卡车上。返回卡

2021-01-03 18:00:00 146 1

原创 二叉搜索树的后序遍历序列

剑指 Offer 33. 二叉搜索树的后序遍历序列难度中等159输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历结果。如果是则返回 true,否则返回 false。假设输入的数组的任意两个数字都互不相同。参考以下这颗二叉搜索树: 5 / \ 2 6 / \ 1 3示例 1:输入: [1,6,3,2,5]输出: false示例 2:输入: [1,3,2,6,5]输出: true提示:数组长度 <= 1000Note想到d

2020-12-28 23:14:20 81

原创 最小堆,优先队列

最小堆,优先队列使用方法定义一个list h = []CRUD:插入: heapq.heappush(h, (key, value))删除: key, value = heapq.heappop(h)查找: 堆顶(最小),h[0][0]替换: heapq.heapreplace(heap, (key,value))参考链接1705. 吃苹果的最大数目有一棵特殊的苹果树,一连 n 天,每天都可以长出若干个苹果。在第 i 天,树上会长出 apples[i] 个苹果,这些苹果将会在

2020-12-28 18:58:18 219

原创 Leetcode216周赛

1662. 具有给定数值的最小字符串a为1,z为26, 给出需要的字母个数n,和k求出满足要求的字典序最小的序列示例 1:输入:n = 3, k = 27输出:“aay”解释:字符串的数值为 1 + 1 + 25 = 27,它是数值满足要求且长度等于 3 字典序最小的字符串。示例 2:输入:n = 5, k = 73输出:“aaszz”提示:1 <= n <= 105n <= k <= 26 * nNote1首先想到的方法是用递归,栈爆了,数据也就过了1\

2020-11-29 17:26:14 141

原创 Okhttp的缓存机制

[@TOC]Okhttp的缓存机制缓存目的:减少用户向服务器发送请求的次数,从而加快响应的速度,降低服务器的负载Http协议下的缓存机制强制缓存通过http协议所传送的数据,会被保存到缓存数据库中,强制缓存的意思是指,若缓存数据库中的数据仍未失效,则直接通过缓存数据库获得数据,不再通过http向服务器发送请求。其中有两个比较重要的字段用于控制是否失效:Expires指过期的时间,其值由服务器所决定。当在缓存数据库取得相应的数据时,通过比较当前时间与Expires来决定是否直接使用缓存数据库中的

2020-11-13 21:18:11 5538

原创 Day1

DAY1安装JDK8卸载掉了之前的新版本,其实只需要配置好环境变量即可卸载后的环境变量忘记删除,导致两个版本jdk环境变量共存,因优先级出错jdk8安装网址vpn突然抽风 解决:重启。。。安装flutter方法论有问题,应该先找flutter官方网址,而我直接csdn一顿猛搜,导致各种bug两个环境变量没配置成服务器(怕被墙)导致最后flutter项目一直运行出现问题阿里云git的使用srr链接配置问题,离开了github,感觉一切操作都从零开始,没

2020-10-12 23:05:50 134

原创 P1002 过河卒

P1002 过河卒题目描述棋盘上 AA 点有一个过河卒,需要走到目标 BB 点。卒行走的规则:可以向下、或者向右。同时在棋盘上 CC 点有一个对方的马,该马所在的点和所有跳跃一步可达的点称为对方马的控制点。因此称之为“马拦过河卒”。棋盘用坐标表示,AA 点 (0, 0)(0,0)、BB 点 (n, m)(n,m),同样马的位置坐标是需要给出的。现在要求你计算出卒从 AA 点能够到达 BB 点的路径的条数,假设马的位置是固定不动的,并不是卒走一步马走一步。输入格式一行四个正整数,分别表示 BB

2020-07-04 14:44:32 335

原创 vs code 脱离鼠标的快捷键

vs code 脱离鼠标的快捷键光标移动下一个单词 Ctrl + right行首 homeAlt + Click 插入光标-支持多个选择选择单词 Ctrl + shift + left/right选择一行 Alt +shift + right + right删除一个单词 Ctrl + Delete / Ctrl + Backspace删除一行 Ctrl + X上下移动...

2020-01-12 13:16:37 627

原创 进制转换

32 - 2 进制转成十进制int RadixtoDecimal(string s, int radix){ char temp[20]; char *error; strcpy(temp, s.c_str()); return strtol(temp, &error, radix); // stringtolong}十进制转2 - 32进制string Decimalt...

2019-12-07 11:36:32 100

原创 链表重排

模板struct node{ int address, data, next, flag , index;}a[maxn];unordered_map<int, int> visited;bool cmp(node a, node b){ if(a.flag == b.flag) return a.index < b.index; else return a.f...

2019-09-03 20:11:08 234

原创 浙江大学计算机与软件学院2019年考研复试上机模拟练习

7-1 Conway’s ConjectureJohn Horton Conway, a British mathematician active in recreational mathematics, proposed a conjecture in 2014: arrange the factors of any given number in ascending order, and p...

2019-09-02 20:50:09 1396

原创 晴神模拟赛

你们要的中缀表达式树Case Time Limit: 100 MS (Others) / 200 MS (Java) Case Memory Limit: 256 MB (Others) / 512 MB (Java)Accepted: 74 Total Submission: 280Problem Description给定一棵二叉树,二叉树的各个结点要么表示四则运...

2019-09-01 15:45:30 201

原创 PAT仿真模拟

note1dfs版本Code1#include<bits/stdc++.h>using namespace std;const int maxn = 1000;set<int> save;vector<int> s;int a[maxn][maxn];int visited[maxn] = {0}, liarnum = 0;void D...

2019-08-31 22:56:51 290

原创 1151 LCA in a Binary Tree (30 分)

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.Inpu...

2019-08-31 00:10:23 87

原创 1131 Subway Map (30 分) 思维

Keywords: Dfs, 思维In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to he...

2019-08-27 14:12:37 387

原创 PAT排序总结

题目列表1012. The Best Rank (25)1013. Phone Bills (25)1017. Queueing at Bank (25)1025. PAT Ranking (25)1026. Table Tennis (30)1028. List Sorting (25)1052. Linked List Sorting (25)1055. The World’s...

2019-08-25 22:00:34 282

原创 中序前序后序层序转换总结

模板链表版(直接建树)1.前序中序建树#include<iostream>#include<vector>#include<algorithm>using namespace std;const int maxn = 1e4 + 10;struct node{ node *lchild; node *rchild; ...

2019-08-25 21:43:22 726

原创 pat真题阅读索引

2012年秋季1038-10412012年冬季1046-10492013年春季1050-10532013年秋季1061-10642013年冬季1069-10722014年春季1073-10762014年秋季1084-10872014年冬季1088-10912015年春季1092-10952015年秋季1100-11032015年冬季1104-110720...

2019-08-21 23:54:15 212

原创 1135 Is It A Red-Black Tree (30 分) 红黑树

There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The root is black.(3) Every le...

2019-08-19 22:03:01 196

原创 1144 1145 1146 1147模拟练习

1144 The Missing Number (20 分)Sample Input:105 -25 9 6 1 3 4 2 5 17Sample Output:7Note找到第一个没有出现的整数Code#include<iostream>#include<cstdio>#include<vector>#include<cmat...

2019-08-18 17:12:47 184

原创 1140 1141 1142 1143模拟练习 (谜之压轴题)

1140 Look-and-say Sequence (20 分)Sample Input:1 8Sample Output:1123123111Note1 11 12 1121 122111 112213 12221131 1123123111题意:没经过一次变换,都用一个数记录之前数出现过的次数思路:先造一个两倍长的string,循环记录即可Code#include&l...

2019-08-17 18:57:08 217

原创 1136 1137 1138 1139 模拟练习

1136 A Delayed Palindrome (20 分)Sample Input 1:97152Sample Output 1:97152 + 25179 = 122331122331 + 133221 = 255552255552 is a palindromic number.Sample Input 2:196Sample Output 2:196 + 691 =...

2019-08-16 22:09:11 276

原创 1133 Splitting A Linked List (25 分)

Keywords: 各种错误总结Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear befo...

2019-08-15 21:02:37 274

原创 A1116 A1117 A1118 A1119 模拟练习4

1116 Come on! Let’s C (20 分)Sample Input:61111666688881234555500016888800011111222288882222Sample Output:8888: Minion0001: Chocolate1111: Mystery Award2222: Are you kidding?8888: ...

2019-08-12 21:40:14 169

原创 A1112 A1113 A1114 A1115 模拟练习3 待补并查集

1112 Stucked Keyboard (20 分)题目链接Sample Input:3caseee1__thiiis_iiisss_a_teeeeeestSample Output:eicase1__this_isss_a_teestNote1题意, 输入坏键重复的次数,输入字符串,检测坏键思路: 以为要用stl(但是并没有)就没想模拟去解,以后碰到这种题管他麻烦还是不...

2019-08-12 00:00:11 156

原创 A1108 A1109 A1110 A1111 模拟练习2

1008题目链接Sample Input 1:75 -3.2 aaa 9999 2.3.4 7.123 2.35Sample Output 1:ERROR: aaa is not a legal numberERROR: 9999 is not a legal numberERROR: 2.3.4 is not a legal numberERROR: 7.123 is not ...

2019-08-11 15:56:06 227

原创 A1101 A1103 A1104 A1105 模拟练习1

A1104题目链接Sample Input:40.1 0.2 0.3 0.4Sample Output:5.00Note题意为输出所有增序的序列合题目简单但是直接模拟做回导致运行超时推导所需的公式:假设序列的首尾指针 分别为p和q,那么对于p,有i种选择,即12…i,对于q,有n-i+1种选择,即i, i+1, … n,所以p和q组合 形成的⾸首尾⽚片段有i * (n-i+1...

2019-08-09 23:51:59 150

原创 DFS 总结

模板void Dfs(int n, int depth){ visited[n] = 1; /* 加入对该节点的操作或剪枝*/ for(int i = 0; i < a[i].size(); i++){ if(visited[i] == 0) Dfs(i, depth + 1); }}int main(){ ...

2019-08-09 19:35:02 210

原创 1091 Acute Stroke (30 分)DFS 内存超限, 未完待续

One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c...

2019-08-08 21:49:32 481

原创 1097 Deduplication on a Linked List (25 分) 静态链表 时间长

Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a...

2019-08-08 19:27:35 112

原创 1078 Hashing (25 分) Quadratic probing

The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%TSiz...

2019-08-07 15:05:12 167

原创 1059 Prime Factors (25 分) 合数的因式分解( Composite number)

Input Specification:Each input file contains one test case which gives a positive integer N in the range of long int.Output Specification:Sample Input:97532468Sample Output:97532468=2^21117101...

2019-08-07 13:47:02 150

原创 1024 Palindromic Number (25 分) 大数

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...

2019-08-06 21:51:39 130

原创 1093 Count PAT's (25 分)巧妙递推

The string APPAPT contains two PAT’s as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now g...

2019-08-06 16:21:01 339

原创 1048 Find Coins (25 分) 模拟 ->二分

Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However,...

2019-08-05 21:47:24 161

原创 1044 Shopping in Mars (25 分) 二分

Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any position ...

2019-08-05 21:32:31 139

原创 1085 Perfect Sequence (25 分) 双指针, 短小精悍

Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×p where M and m are the maximum and minimum numbers in the sequence, respecti...

2019-08-05 20:08:38 171

空空如也

空空如也

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

TA关注的人

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