随笔分类 - LeetCode
摘要:题目描述 1052. 爱生气的书店老板 难度:中等-简单 今天,书店老板有一家店打算试营业 customers.length 分钟。每分钟都有一些顾客(customers[i])会进入书店,所有这些顾客都会在那一分钟结束后离开。 在某些时候,书店老板会生气。 如果书店老板在第 i 分钟生气,那么 g
阅读全文
摘要:题目描述 1438. 绝对差不超过限制的最长连续子数组 难度 中等 给你一个整数数组 nums ,和一个表示限制的整数 limit,请你返回最长连续子数组的长度,该子数组中的任意两个元素之间的绝对差必须小于或者等于 limit 。 如果不存在满足条件的子数组,则返回 0 。 示例 1: 输入:num
阅读全文
摘要:0.题目描述 697. 数组的度 难度:简单 给定一个非空且只包含非负数的整数数组 nums,数组的度的定义是指数组里任一元素出现频数的最大值。 你的任务是在 nums 中找到与 nums 拥有相同大小的度的最短连续子数组,返回其长度。 示例 1: 输入:[1, 2, 2, 3, 1]输出:2解释:
阅读全文
摘要:#include<stdio.h> #include<string.h> int main(void){ char ch,stro[1001],stack[1001]; int numstack[1001]; int top=-1,head=-1; /************************
阅读全文
摘要:蚂蚁碰撞后反向与穿越的时间一样。 穷竭搜索 >想象力 #include<stdio.h> int main(void){ int n,len,ansNum,mintime,maxtime,loc; scanf("%d",&n); for(int i=1;i<=n;i++){ mintime=maxt
阅读全文
摘要:Big Number Problem Description As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a
阅读全文
摘要:1.普通的求幂方法: 时间复杂度为O(n),对于比较大的数在1s限时内可能会TLE int pow(int base,int p){ int ans=1; for(int i=1;i<=p;i++) ans*=base; return ans; } 2.快速幂: 时间复杂度为logn (1)结合位运
阅读全文
摘要:Have Fun with Numbers Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it
阅读全文
摘要:数组元素循环右移问题 一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由(A0A1⋯AN−1)变换为(AN−M⋯AN−1A0A1⋯AN−M−1)(最后M个数循环移至最前面的M个位置)。
阅读全文
摘要:0.埃氏筛 时间复杂度O(nloglogn) 传统的寻找素数的方法时间复杂度很高,当数据规模很大时不再实用,对于OJ通常几百ms或1s的限时,我们通常会采用用空间换时间的方法。 埃氏筛的思路是在一开始创建一个长度为N+1(N为要查找的最大范围)的数组,数组的下标(从1开始)对应要查找的数字,一开始将
阅读全文

浙公网安备 33010602011771号