由于选择次序在第二位,因此,我们无法控制上位(即Alice)的选择,她的选择永远会比我们大,但是,为了让我们最终的结果更优,我们可以强行安排Bob,让他每次取的都是全局最小的数字。 如此一来,我们的最优策略就是取第 3 × i + 2 ( i = 0 , . . . , n − 1 ) 3\times i + 2 (i = 0, ...,...
LeetCode笔记:Weekly Contest 264 1. 题目一 1. 解题思路 2. 代码实现 2. 题目二 1. 解题思路 2. 代码实现 3. 题目三 1. 解题思路 2. 代码实现 4. 题目四 1. 解题思路 2. 代码实现 1. 题目一 给出题目一的试题链接如下: 2047. Number of Valid Words in a Sentence 1. 解题思路 这一...
每周参加weekly contest,发现前几名都会在半小时左右完成4题,我感觉对于一道陌生的MEDIUM题目,理解+思考...
vector<vector<int>> dp(n, vector<int>(n, -1));intmyBest = utill(nums, dp,0, n-1);return2*myBest >= accumulate(nums.begin(), nums.end(),0); }intutill(vector<int>& v, vector<vector<int>> &dp,inti,intj){if(i > j)return0;if(dp[i][j] != -1)returndp[i][j];int...
LeetCode Weekly Contest 8 LeetCode每周末举办比赛,这是今天上午比赛的题解。 1. Add Strings (LeetCode 415 Easy) Given two non-negative numbersnum1andnum2represented as string, return the sum ofnum1andnum2. Note: The length of bothnum1andnum2is < 5100....
https://leetcode.cn/contest/weekly-contest-400/problems/minimum-number-of-chairs-in-a-waiting-room/ 题意 直接枚举 思路 统计当前字符串中最大的E的统计数目即可,与多任务CPU类似。 复杂度分析: 时间复杂度:O(n \log n), 其中n表示数组的长度。
Algorithms Exercise: LeetCode Problems, LeetCode Weekly Contest etc. github.com/caipengbo/LeetCode-CPP Resources Readme Activity Stars 56 stars Watchers 6 watching Forks 17 forks Report repository Releases No releases published Packages No packages published Languages Java 99.9% C++ 0.1...
128th LeetCode Weekly Contest Capacity To Ship Packages Within D Days,Aconveyorbelthaspackagesthatmustbeshippedfromoneporttoanotherwithin D days.The i-thpackageontheconveyorbelthasaweightof weight
给你一个字符串 s,找出它的所有子串并按字典序排列,返回排在最后的那个子串。 示例1: 输入:"abab" 输出:"bab" 解释:我们可以找出 7 个子串 ["a", "ab", "aba", "abab", "b", "ba", "bab"]。按字典序排在最后的子串是 "bab"。
又是一个周末,第一次参加leetcode的weekly-contest。早上起的晚了,匆匆忙忙打开室友的电脑(恩,他不在,也没有密码),就开始上午的刷题了。目前能力也是很菜滴,只做出两个,一个easy,一个medium。还剩两个没下笔。不过自我认为,题不在多,贵在总结,希望自己可以持之以恒。所以就码下自己做的总结,可能方法不是...