Weekly Contest 119】的更多相关文章

第一题: 973. K Closest Points to Origin  We have a list of points on the plane.  Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is the Euclidean distance.) You may return the answer in any order.  The a…
LeetCode Weekly Contest 8 415. Add Strings User Accepted: 765 User Tried: 822 Total Accepted: 789 Total Submissions: 1844 Difficulty: Easy Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. Note: The…
Weekly Contest 86 A:840. 矩阵中的幻方 3 x 3 的幻方是一个填充有从 1 到 9 的不同数字的 3 x 3 矩阵,其中每行,每列以及两条对角线上的各数之和都相等. 给定一个由整数组成的 N × N 矩阵,其中有多少个 3 × 3 的 “幻方” 子矩阵?(每个子矩阵都是连续的). 直接模拟即可,本来是签到题,由于粗心,浪费了时间. class Solution { public: int numMagicSquaresInside(vector<vector<int&…
leetcode weekly contest 43 leetcode649. Dota2 Senate leetcode649.Dota2 Senate 思路: 模拟规则round by round. class Solution { public: string predictPartyVictory(string senate) { int len = senate.size(); int r = 0; int d = 0; int i = 0; while(1) { if(senate[…
LeetCode Weekly Contest 23 1. Reverse String II Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them.…
第一题:柠檬水找零 问题: 在柠檬水摊上,每一杯柠檬水的售价为 5 美元. 顾客排队购买你的产品,(按账单 bills 支付的顺序)一次购买一杯. 每位顾客只买一杯柠檬水,然后向你付 5 美元.10 美元或 20 美元.你必须给每个顾客正确找零,也就是说净交易是每位顾客向你支付 5 美元. 注意,一开始你手头没有任何零钱. 如果你能给每位顾客正确找零,返回 true ,否则返回 false . 示例 1: 输入:[5,5,5,10,20] 输出:true 解释: 前 3 位顾客那里,我们按顺序收…
链接:https://leetcode.com/contest/leetcode-weekly-contest-33/ A.Longest Harmonious Subsequence 思路:hash加查找 class Solution { public: int findLHS(vector<int>& nums) { if (nums.empty()) ; ; int len = nums.size(); unordered_map<int, int> hash(len…
闲着无聊参加了这个比赛,我刚加入战场的时候时间已经过了三分多钟,这个时候已经有20多个大佬做出了4分题,我一脸懵逼地打开第一道题 665. Non-decreasing Array My SubmissionsBack to Contest   User Accepted:1054 User Tried:1755 Total Accepted:1080 Total Submissions:7519 Difficulty:Easy Given an array with n integers, y…
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.  Each glass holds one cup (250ml) of champagne. Then, some champagne is poured in the first glass at the top.  When the top m…
第一题:905. 按奇偶校验排序数组 问题: 给定一个非负整数数组 A,返回一个由 A 的所有偶数元素组成的数组,后面跟 A 的所有奇数元素. 你可以返回满足此条件的任何数组作为答案. 示例: 输入:[3,1,2,4] 输出:[2,4,3,1] 输出 [4,2,3,1],[2,4,1,3] 和 [4,2,1,3] 也会被接受. 提示: 1 <= A.length <= 5000 0 <= A[i] <= 5000 链接:https://leetcode-cn.com/contest…