持续更新... 题目网址:https://leetcode.com/problemset/all/?difficulty=Easy 1.Two Sum[4ms] 2. Reverse Integer [12ms] 题意:将一个32bit signed integer反转输出,如果反转之后超出32位补码范围 [-2^31,2^31-1],则输出0 思路:边取模边算结果,结果存longlong判界 3. Palindrome Number [112ms] 题...
类似题目: LeetCode 731. 我的日程安排表 II(set二分查找 / 差分思想) LeetCode 732. 我的日程安排表 III(差分思想) 2.1 set 二分查找 代码语言:javascript 代码运行次数:0 运行 AI代码解释 classMyCalendar{set<pair<int,int>>s;public:MyCalendar(){}boolbook(int start,int end){if(s.empty()){s....
Idiot-maker Set Matrix Zeroes https://leetcode.com/problems/set-matrix-zeroes/ Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(mn) space is ...
原题地址:http://acm.hdu.edu.cn/showproblem.php?pid=5927 题意: 一棵节点数为n的有根数,根节点为1,一开始所有的点都是重点,接下来有q次询问,每次询问把m个点变为轻点,问你树中还有多少个重点。 重点应该满足的条件为: 1.它本身是重点。 2.它为两个重点的最近公共祖先。 每次询问之后在下次询问前,...
最基本的来自https://leetcode.com/problems/range-sum-query-mutable/ 调用: 待深入的话题:离散化,插入,lazy更新 待用线段树解决的问题: 1,https://leetcode.com/problems/the-skyline-problem/ 2,https://codingcompetitions.withgoogle.com/kicks...线段树...
Leetcode 295. 数据流的中位数 1.题目要求 中位数是有序列表中间的数.如果列表长度是偶数,中位数则是中间两个数的平均值. 例如, [2,3,4] 的中位数是 3 [2,3] 的中位数是 (2 + 3) / 2 = 2.5 设计一个 ... Codeforces Round #201 (Div. 2)C,E 数论: C. Alice and Bob time limit...
path-sum 3 2019-12-22 20:15 − https://leetcode.com/problems/path-sum-iii/submissions/ 题目: /** * Definition for a binary tree node. * public class TreeNode ... 会飞的企鹅吧 0 246 Problem I. Wiki with Special Poker Cards 2019-12-20 21:19 − Problem I. Wiki with ...
Baozi Leetcode solution 1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold 2019-12-19 12:14 −Problem Statement Given a m x n matrix mat and an integer threshold. Return the maximum side-length of a square with a... ...
We just loop once, putting the number in set to find the duplicated, and sum all the numbers to calculate the missing value at the end of loop. Time complexity is O(n), space complexity is O(n). classSolution {public: vector<int> findErrorNums(vector<int>&nums) {set<int>s;intdup...
AC: #include<iostream>#include<cstdio>#include<cstring>#defineN 1000000007usingnamespacestd; typedeflonglongll;intpow(ll x,ll y) { ll res=1;while(y) {if(y&1) res= res * x %N; x= x * x %N; y>>=1; }returnres-1;