摘要: Weekly Contest 312 Problem A Sort the People 思路 水题,按值排序就行 代码 class Solution: def sortPeople(self, names: List[str], heights: List[int]) -> List[str]: 阅读全文
posted @ 2022-10-02 10:53 浅花迷人 阅读(10) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 311 Problem A Smallest Even Multiple 思路 水题,判一下奇偶就行 代码 class Solution: def smallestEvenMultiple(self, n: int) -> int: if n%2==0: return 阅读全文
posted @ 2022-09-24 21:59 浅花迷人 阅读(13) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 310 Problem A Most Frequent Even Element 思路 水题,用map存一下每个偶数数量然后统计就行 代码 class Solution: def mostFrequentEven(self, nums: List[int]) -> in 阅读全文
posted @ 2022-09-19 18:01 浅花迷人 阅读(15) 评论(0) 推荐(0) 编辑
摘要: Weekly Contest 309 Problem A Check Distances Between Same Letters 思路 水题,遍历数组然后check一下就行 代码 class Solution: def checkDistances(self, s: str, distance: 阅读全文
posted @ 2022-09-12 21:08 浅花迷人 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 题目:538. Convert BST to Greater Tree 思路: 基本思想就是根据二叉搜索树的特性,一个节点比他大的点都一定在他的右边,可以先遍历书,取出所有的值,然后按照右-中-左的顺序遍历整个书,保证按照从大到小的顺序访问所有的节点,则每个节点应该加的值就是前面所访问过的节点的和。 阅读全文
posted @ 2022-04-16 16:04 浅花迷人 阅读(23) 评论(0) 推荐(0) 编辑
摘要: QAQ: A. Cow and Haybales 题意: 有n个盒子,第i个盒子初始有ai个物品,每一天你可以把某个盒子的一个物品移动到相邻盒子里,求d天之后第一个盒子最多有多少个物品 思路: 简单题,直接模拟即可,详细见代码。 代码: #include <bits/stdc++.h> using 阅读全文
posted @ 2020-03-10 18:45 浅花迷人 阅读(183) 评论(0) 推荐(0) 编辑
摘要: QAQ: A. Two Rabbits 题意: 有两只兔子,距离为n,左边兔子每秒向右跳a,右边兔子每秒向左跳b,问两只兔子何时能相遇,如果不能相遇输出-1。 思路: #include <bits/stdc++.h> using namespace std; typedef long long LL 阅读全文
posted @ 2020-03-09 22:25 浅花迷人 阅读(157) 评论(0) 推荐(0) 编辑
摘要: QAQ: A. Three Strings 题意: 给你三个等长字符串a,b,c,你对于每一位i,你必须要cI去替换ai或者bi,问最后能不能让a串和b串相同。 思路: 简单题,直接模拟即可,详细见代码。 代码: #include<bits/stdc++.h> using namespace std 阅读全文
posted @ 2020-03-09 21:31 浅花迷人 阅读(160) 评论(0) 推荐(0) 编辑
摘要: QAQ: A. Erasing Zeroes 题意: 给你一个01串,问最少删掉多少个0使得串中的所有1都相邻。 思路: 简单题,详细见代码。 代码: #include <bits/stdc++.h> using namespace std; const int maxn = 2e5+10; typ 阅读全文
posted @ 2020-03-09 18:37 浅花迷人 阅读(158) 评论(0) 推荐(0) 编辑
摘要: QAQ:我太难了 A. Even But Not Even 题意: 给你一个长度为n的数组a,你可把其中一个数的值加一,这个操作你可以做无数次,要求最后的数组之和不等于零,数组之积不等于0,输出所需最小的操作数。 思路: 暴力模拟即可,要求数组中不能有0,和不等于0。 代码: #include <b 阅读全文
posted @ 2020-03-09 00:40 浅花迷人 阅读(178) 评论(0) 推荐(0) 编辑