![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
perseverance_lucky
做自己的女王
展开
-
Leetcode106 链表相交
随性更新刷题系列。原创 2022-09-29 20:53:57 · 213 阅读 · 0 评论 -
Leetcode15 三数之和
看了题解才会的,过段时间复盘吧class Solution: def threeSum(self, nums: List[int]) -> List[List[int]]: answer=list() nums.sort() length=len(nums) #第一层循环第一个数 for i in range(0,length): if i>0 and nums[i]==num.原创 2021-04-25 14:52:03 · 73 阅读 · 1 评论 -
Leetcode11 盛最多水的容器
暴力求解会超时,用双指针class Solution: def maxArea(self, height: List[int]) -> int: #双指针 start,end=0,len(height)-1 area,max=0,0 while start<end: area=(end-start)*min(height[start],height[end]) if heig原创 2021-04-25 10:53:52 · 120 阅读 · 0 评论 -
Leetcode4 寻找两个正序数组中位数
class Solution: def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: def Getkthsmall(nums1,start1,end1,nums2,start2,end2,k): len1=end1-start1+1 len2=end2-start2+1 if(len1>len原创 2021-04-24 21:01:38 · 70 阅读 · 0 评论 -
哈希表训练
菜鸡的进阶之路因为pat现在好像不支持gets了,所以用gets会报错,换成cin.getline没毛病#include<stdio.h>#define maxsize 10001//什么时候用string类,什么时候要用字符串数组int main(){ char s[maxsize]; int count[200]={}; char target[]="PATest"; gets(s); for(int i=0; s[i]!='\0';i+原创 2020-09-11 21:23:49 · 85 阅读 · 0 评论 -
排序题训练
https://www.patest.cn/#include<iostream>#include<algorithm>#include<string.h>#define maxsize 100000using namespace std;struct record{ int ID; char name[9]; int grade;};// increasing order according to ID'sbool cmp1(原创 2020-09-10 19:22:24 · 172 阅读 · 1 评论 -
模拟题训练
做题网址:https://www.patest.cn/!!这个代码有部分案例没通过,有时间再看一遍#include<iostream>#define maxsize 10001using namespace std;int main(){ unsigned int N; cin >> N; int grade[maxsize]={}; int n,score; for(int i=1; i<=N; i++){原创 2020-09-07 17:00:43 · 153 阅读 · 0 评论 -
输入输出训练
杭电1000计算A+B注意点:处理到文件末尾—while(scanf()!=EOF),代表的意思是一直输入,直到scanf返回的值是-1时才会停止输入#include<stdio.h>int main(void){ int A,B; while (scanf("%d %d",&A,&B)!=EOF){ int sum = A+B; printf("%d\n",sum); }原创 2020-07-21 15:07:33 · 229 阅读 · 0 评论 -
链表使用---创建、插入、删除(代码)
链表使用—创建、插入、删除(代码)(1) 创建链表这里用c++中的new关键字来分配内存,个人觉得比malloc简单哟,至少比它短hhhstruct node { int data; node* next;}node* create(int Array[]) { //要有头节点,前驱节点 node *p, *pre, *head; head = new node; head -...原创 2019-12-05 21:17:35 · 202 阅读 · 0 评论 -
树之 树的遍历
树的遍历我萌讨论的是一般的树,就是子结点个数不限同时也没有先后次序的树let’s start结点结构体定义:`struct node { int data; //数据域 vector<int> child; //指针域,存放所有子结点的下标} Node[maxn];//结点数组树的先根遍历:void PreOrder(int root) { printf("%d ...原创 2019-12-04 00:29:02 · 76 阅读 · 0 评论 -
树之二叉树 代码模板总结
树总结(一) 树的遍历1 前中后序遍历以前序为例:/*c*/原创 2019-12-03 23:48:45 · 176 阅读 · 0 评论