自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 二分查找旋转数组最大值和最小值

最大值:比较nums[left]和nums[mid],原因是nums[left] < nums[mid], left = mid(如果是比较nums[right]和nums[mid],nums[right] < nums[mid], left = mid)偏右 -> left + (right - left + 1) / 2 -> right = mid - 1;因为最大值是偏右的,意思是假设此时数组是7,8,我们要输出8,所以是要输出偏右的值。因此找最大值,就找偏右的,找最小值,就找偏左的。

2022-10-20 12:28:40 501 1

原创 力扣376. 摆动序列错误用例

力扣

2022-08-20 18:02:46 200

原创 力扣超级次方问题labuladong

超级次方

2022-06-28 15:11:17 199

原创 网易互娱22.4.16笔试LCP 09. 最小跳跃次数

LCP 09. 最小跳跃次数为了给刷题的同学一些奖励,力扣团队引入了一个弹簧游戏机。游戏机由 N 个特殊弹簧排成一排,编号为 0 到 N-1。初始有一个小球在编号 0 的弹簧处。若小球在编号为 i 的弹簧处,通过按动弹簧,可以选择把小球向右弹射 jump[i] 的距离,或者向左弹射到任意左侧弹簧的位置。也就是说,在编号为 i 弹簧处按动弹簧,小球可以弹向 0 到 i-1 中任意弹簧或者 i+jump[i] 的弹簧(若 i+jump[i]>=N ,则表示小球弹出了机器)。小球位于编号 0 处的弹簧时不

2022-04-16 01:26:41 327 1

原创 力扣1819. 序列中不同最大公约数的数目

1819. 序列中不同最大公约数的数目题解给你一个由正整数组成的数组 nums 。数字序列的 最大公约数 定义为序列中所有整数的共有约数中的最大整数。例如,序列 [4,6,16] 的最大公约数是 2 。数组的一个 子序列 本质是一个序列,可以通过删除数组中的某些元素(或者不删除)得到。例如,[2,5,10] 是 [1,2,1,2,4,1,5,10] 的一个子序列。计算并返回 nums 的所有 非空 子序列中 不同 最大公约数的 数目 。 示例 1:输入:nums = [6,

2022-04-02 01:19:33 249

原创 khash/flat hash map/unordered_map/map总结

Klib - C语言通用库Double Hashing(双重hash)C语言 | #运算符与##运算符Klib之khash学习笔记深入解读Khash.hC语言实战课-klib库学习I Wrote The Fastest Hashtable罗宾汉哈希为什么hashtable中桶的数目都是用质数表示HashMap初始容量为什么是2的n次幂及扩容为什么是2倍的形式?...

2022-03-26 22:16:19 2442

原创 二分法解决力扣2141、 774、209(不知出处)

2141. 同时运行 N 台电脑的最长时间class Solution {public: bool check(int n,long long mid,vector<int>& batteries){ long long sum = 0; for(auto &i:batteries){ sum = sum + min(mid,(long long)i); } return (sum

2022-03-25 23:44:12 745

原创 力扣滑动窗口

有框架设置头部和尾部for(移动头部直到最后){ 更新窗口值 while(当窗口值刚符合条件或刚不符合条件){ 移动头部直到符合条件或刚不符合条件 记录窗口值和结果 }}209.长度最小的子数组class Solution {public: int minSubArrayLen(int target, vector<int>& nums) { int res = INT_MAX; int i = 0; i

2022-02-23 16:29:30 89

原创 effective C++条款31:将文件间的编译依存关系降至最低读后感

在学习effective C++条款31:将文件间的编译依存关系降至最低时没看懂,所以上网找了资料,刚好自己对于文件编译依存关系一直都不太明白,所以记录下来以便以后复习https://segmentfault.com/a/1190000002790854https://blog.csdn.net/weixin_39408343/article/details/103300478https://blog.csdn.net/weixin_39956356/article/details/110404940

2022-01-03 02:27:32 386

原创 PAT甲级1151 LCA in a Binary Tree、1143 Lowest Common Ancestor最小公共节点

PAT甲级1151 LCA in a Binary TreeThe 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.Input Specification:Each i

2021-12-06 14:34:21 403

原创 PAT甲级1119 Pre- and Post-order Traversals

PAT甲级1119 Pre- and Post-order TraversalsSuppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and inorder traversal seque

2021-12-04 17:26:02 429

原创 二叉树各种遍历的结合模板

二叉树各种遍历模板以下代码假设输入的是先序遍历和中序遍历输出后序遍历测试用例31 2 32 1 32 3 171 2 4 6 5 7 36 4 2 5 7 1 36 4 7 5 2 3 1先序遍历 + 中序遍历 = 后序遍历仅要求输出序列如果改成后序遍历和中序遍历输出先序遍历,只需要把遍历中的root改成后序遍历中最后一个数字即可#include <iostream>#include <vector>using namespace std;i

2021-12-02 16:28:22 897

原创 PAT甲级1138 Postorder Traversal先序中序输出后序

1138Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal sequence of the corresponding binary tree.Input Spe

2021-12-02 11:54:37 953

原创 PAT甲级1127 ZigZagging on a Tree先后序建立树

1127Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences. And it is a simple standard routine to print the numbers in level-order. Ho

2021-12-01 19:35:25 94

原创 PAT甲级1064 Complete Binary Search Tree/1099 Build A Binary Search Tree完全二叉树、二叉搜索树

1064A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The right subtree of a node contains only nodes with keys greate

2021-12-01 15:12:01 366

原创 PAT甲级1094 The Largest Generation

1094A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input Specification:Each input file contains one test ca

2021-11-30 19:17:15 176

原创 PAT甲级1086 Tree Traversals Again

10861086 Tree Traversals Again (25 分)An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stack operations are:

2021-11-30 18:18:37 300

原创 PAT甲级1079 Total Sales of Supply Chain 1090 Highest Price in Supply Chain 1106 Lowest Price in Supply

1079A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys products from one's supplier in a pric

2021-11-29 15:20:26 241

原创 PAT甲级1059 Prime Factors

1059Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p 1​ k 1​ ×p 2​ k 2​ ×⋯×p m​ k m​ .Input Specification:Each input file contains one test case which give

2021-11-28 01:59:01 320

原创 PAT甲级1015 Reversible Primes

1015A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime.Now given any two positive integers N (<10

2021-11-24 01:33:59 295

原创 PAT甲级1088 Rational Arithmetic

1088牛客网For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test case, which gives in one line the two rational nu

2021-11-23 23:34:16 350

原创 PAT甲级1081 Rational Sum

1081Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive integer N (≤100), followed in the next line N rational

2021-11-23 01:28:11 97

原创 PAT甲级1136 A Delayed Palindrome

11361024Consider a positive integer N written in standard notation with k+1 digits a i​ as a k​ ⋯a 1​ a 0​ with 0≤a i​ <10 for all i and a k​ >0. Then N is palindromic if and only if a i​ =a k−i​ for all i. Zero is writte

2021-11-22 19:18:33 52

原创 PAT甲级1148 Werewolf - Simple Version

1148柳神Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: "Player #2 is a werewolf.";player #2 said: "Player #3 is a human.";player #3 said: "Playe

2021-11-22 13:32:05 216

原创 PAT甲级1048 Find Coins

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, there was a special requirement of the payment: for eac

2021-11-22 11:46:30 48

原创 PAT甲级1010 Radix个人理解

1010柳神最近都更新到本地了&再见萤火虫&1010 Radix (25 分)Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers

2021-11-22 02:32:58 243

原创 PAT甲级1029 Median

1029Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is 15. The median of two sequences is defined to be t

2021-11-21 00:57:39 53

原创 PAT甲级1009 Product of Polynomials

1009 Product of PolynomialsThis time, you are supposed to find A×B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:K N 1

2021-11-19 17:32:20 58

原创 PAT甲级1017 Queueing at Bank

1017 Queueing at BankSuppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow line, until it is his/her turn to be

2021-11-17 13:51:06 113

原创 PAT甲级1061 Dating

Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those strange strings are actually referring to the coded time Thursday 14:04

2021-11-16 17:02:03 107

原创 PAT甲级1082 Read Number in Chinese

Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu. Note: zero (li

2021-11-16 16:06:00 337

原创 PAT甲级1071 Speech Patterns

1071 Speech Patterns1071 Speech Patterns (25 分)People often have a preference among synonyms of the same word. For example, some may prefer "the police", while others may prefer "the cops". Analyzing such patterns can help to narrow down a speaker's iden

2021-11-16 13:04:46 108

原创 PTA关键点1065 A+B and C (64bit)

https://pintia.cn/problem-sets/994805342720868352/problems/994805406352654336https://blog.csdn.net/liuchuo/article/details/52109211?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163646030416780255222993%2522%252C%2522scm%2522%253A%252220140713.1

2021-11-09 23:24:46 849

原创 力扣笔记:452\435\763\56\738

452. 用最少数量的箭引爆气球在二维空间中有许多球形的气球。对于每个气球,提供的输入是水平方向上,气球直径的开始和结束坐标。由于它是水平的,所以纵坐标并不重要,因此只要知道开始和结束的横坐标就足够了。开始坐标总是小于结束坐标。一支弓箭可以沿着 x 轴从不同点完全垂直地射出。在坐标 x 处射出一支箭,若有一个气球的直径的开始和结束坐标为 xstart,xend, 且满足 xstart ≤ x ≤ xend,则该气球会被引爆。可以射出的弓箭的数量没有限制。 弓箭一旦被射出之后,可以无限地前进。我们想找

2021-10-30 23:01:41 122

原创 力扣回溯法40\216\90\491\47

回溯法问题包括:组合问题子集问题子序列问题排列问题回溯法问题解决起来大同小异首先是代码模板和解答树(这一步最好在脑中有大概的想象)(参考自https://programmercarl.com/)https://programmercarl.com/%E5%9B%9E%E6%BA%AF%E7%AE%97%E6%B3%95%E7%90%86%E8%AE%BA%E5%9F%BA%E7%A1%80.html#%E5%85%B6%E4%BB%96%E8%AF%AD%E8%A8%80%E7%89%8

2021-10-24 15:46:03 102

原创 vector二维数组注意空间分配

vector二维数组注意使用前要分配空间,不然就会出现以下错误:error: reference binding to null pointer of type 'value_type'错误不唯一所以最好在vector二维数组定义时就分配好空间vector<vector<int>> vec(m, vector<int>(n, 0));//初始化一个m行n列的元素值全为0的二维数组参考资料:https://www.cnblogs.com/ranzhong/p

2021-05-12 16:13:50 806

原创 Leetcode 1021. 删除最外层的括号

1021. 删除最外层的括号有效括号字符串为空 ("")、"(" + A + ")" 或 A + B,其中 A 和 B 都是有效的括号字符串,+ 代表字符串的连接。例如,"","()","(())()" 和 "(()(()))" 都是有效的括号字符串。如果有效字符串 S 非空,且不存在将其拆分为 S = A+B 的方法,我们称其为原语(primitive),其中 A 和 B 都是非空有效括号字符串。给出一个非空有效字符串 S,考虑将其进行原语化分解,使得:S = P_1 + P_2 + ... +

2021-04-22 13:23:39 115

原创 Leetcode 28. 实现 strStr()

28. 实现 strStr()实现 strStr() 函数。给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串出现的第一个位置(下标从 0 开始)。如果不存在,则返回 -1 。 说明:当 needle 是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。对于本题而言,当 needle 是空字符串时我们应当返回 0 。这与 C 语言的 strstr() 以及 Java 的 indexOf() 定义相符。

2021-04-22 12:14:28 107

原创 27. 移除元素

https://leetcode-cn.com/problems/remove-element/给你一个数组 nums 和一个值 val,你需要 原地 移除所有数值等于 val 的元素,并返回移除后数组的新长度。不要使用额外的数组空间,你必须仅使用 O(1) 额外空间并 原地 修改输入数组。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。示例 1:输入:nums = [3,2,2,3], val = 3输出:2, nums = [2,2]解释:函数应该返回新的长度 2, 并

2021-04-19 16:26:24 57

原创 室内定位会议和期刊(2020-2021)

INFOCOMIEEE Conference on Computer CommunicationsMobiComACM International Conference on Mobile Computing and NetworkingSenSysACM Conference on Embedded Networked Sensor Systems––待续

2021-03-17 10:31:30 816

空空如也

空空如也

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

TA关注的人

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