随笔分类 - 比赛
摘要:
#1 不同的平均值数目 不同的平均值数目 ##Solution class Solution { public: int distinctAverages(vector<int>& nums) { sort(nums.begin(),nums.end()); int i = 0,j = nums.s
阅读全文
#1 不同的平均值数目 不同的平均值数目 ##Solution class Solution { public: int distinctAverages(vector<int>& nums) { sort(nums.begin(),nums.end()); int i = 0,j = nums.s
阅读全文
摘要:
1 温度转换 温度转换 Solution class Solution { public: vector<double> convertTemperature(double celsius) { double kelvin = celsius + 273.15; double fahrenheit
阅读全文
1 温度转换 温度转换 Solution class Solution { public: vector<double> convertTemperature(double celsius) { double kelvin = celsius + 273.15; double fahrenheit
阅读全文
摘要:
#1.数组中不等三元组的数目 数组中不等三元组的数目 ##Solution class Solution { public: int unequalTriplets(vector<int>& nums) { int n = nums.size(); int cnt = 0; for(int i =
阅读全文
#1.数组中不等三元组的数目 数组中不等三元组的数目 ##Solution class Solution { public: int unequalTriplets(vector<int>& nums) { int n = nums.size(); int cnt = 0; for(int i =
阅读全文
摘要:
#1.根据规则将箱子分类 根据规则将箱子分类 ##Solution class Solution { public: string categorizeBox(int length, int width, int height, int mass) { long long w = 1e4, v =
阅读全文
#1.根据规则将箱子分类 根据规则将箱子分类 ##Solution class Solution { public: string categorizeBox(int length, int width, int height, int mass) { long long w = 1e4, v =
阅读全文
摘要:
#1.分割圆的最少切割次数 分割圆的最少切割次数 ##Solution class Solution { public: int numberOfCuts(int n) { int tmp = 360 / n; if(n == 1) return 0; if(n % 2 == 0) return n
阅读全文
#1.分割圆的最少切割次数 分割圆的最少切割次数 ##Solution class Solution { public: int numberOfCuts(int n) { int tmp = 360 / n; if(n == 1) return 0; if(n % 2 == 0) return n
阅读全文
摘要:
#1.找出中枢整数 找出中枢整数 Solution class Solution { public: int pivotInteger(int n) { int sum = (1 + n)* n / 2; int tmp = (int)sqrt(sum); return tmp * tmp == s
阅读全文
#1.找出中枢整数 找出中枢整数 Solution class Solution { public: int pivotInteger(int n) { int sum = (1 + n)* n / 2; int tmp = (int)sqrt(sum); return tmp * tmp == s
阅读全文
摘要:
#1.回环句 回环句 Solution class Solution { public: bool isCircularSentence(string sentence) { int n = sentence.size(), i = 0; if (sentence[0] != sentence[n
阅读全文
#1.回环句 回环句 Solution class Solution { public: bool isCircularSentence(string sentence) { int n = sentence.size(), i = 0; if (sentence[0] != sentence[n
阅读全文
摘要:
#1.数组中字符串的最大值 数组中字符串的最大值 Solution class Solution { public: int maximumValue(vector<string>& strs) { int ans = -1; for(auto x : strs){ int n = x.size()
阅读全文
#1.数组中字符串的最大值 数组中字符串的最大值 Solution class Solution { public: int maximumValue(vector<string>& strs) { int ans = -1; for(auto x : strs){ int n = x.size()
阅读全文
摘要:
#1.统计相似字符串对的数目 统计相似字符串对的数目 Solution class Solution { public: int similarPairs(vector<string>& words) { unordered_map<int,int> book; int len1 = words.s
阅读全文
#1.统计相似字符串对的数目 统计相似字符串对的数目 Solution class Solution { public: int similarPairs(vector<string>& words) { unordered_map<int,int> book; int len1 = words.s
阅读全文
摘要:
1.统计能整除数字的位数 统计能整除数字的位数 Solution class Solution { public: int countDigits(int num) { int ans = 0; int n = num; while(n){ int t = n % 10; if(num % t ==
阅读全文
1.统计能整除数字的位数 统计能整除数字的位数 Solution class Solution { public: int countDigits(int num) { int ans = 0; int n = num; while(n){ int t = n % 10; if(num % t ==
阅读全文
摘要:
A - Power Given integers A and B, print the value A^B. 基础不解答 B - First Query Problem 基础不解答 C - Cash Register Takahashi is a cashier. There is a cash r
阅读全文
A - Power Given integers A and B, print the value A^B. 基础不解答 B - First Query Problem 基础不解答 C - Cash Register Takahashi is a cashier. There is a cash r
阅读全文
摘要:
1.最多可以摧毁的敌人城堡数目 题目 最多可以摧毁的敌人城堡数目 Solution 可以第一重循环找到$1$,然后从该位置分别向左和向又寻找$-1$,寻找过程中遇到$1$则停止,不更新ans,遇到$-1$则更新ans。 class Solution { public: int captureFort
阅读全文
1.最多可以摧毁的敌人城堡数目 题目 最多可以摧毁的敌人城堡数目 Solution 可以第一重循环找到$1$,然后从该位置分别向左和向又寻找$-1$,寻找过程中遇到$1$则停止,不更新ans,遇到$-1$则更新ans。 class Solution { public: int captureFort
阅读全文
摘要:
1.到目标字符串的最短距离 题目 Solution class Solution { public: int closetTarget(vector<string>& words, string target, int startIndex) { int n = words.size(); int
阅读全文
1.到目标字符串的最短距离 题目 Solution class Solution { public: int closetTarget(vector<string>& words, string target, int startIndex) { int n = words.size(); int
阅读全文

浙公网安备 33010602011771号