uacs2024

导航

2022年9月29日 #

leetcode69-x的平方根

摘要: 69. x 的平方根 简单题,但是考察的内容可以有很多 首先是纯暴力法,毫无特色。速度也很慢。 class Solution { public: int mySqrt(int x) { long long i=1; while(1) { if(i*i<=x) i++; else break; } r 阅读全文

posted @ 2022-09-29 18:57 ᶜʸᵃⁿ 阅读(14) 评论(0) 推荐(0) 编辑

leetcode169-多数元素

摘要: 169. 多数元素 这道题虽然是简单题,但是有很多精妙的解法。详情看官方题解 class Solution { public: int majorityElement(vector<int>& nums) { int size=nums.size(); if(size<=2) return nums 阅读全文

posted @ 2022-09-29 14:32 ᶜʸᵃⁿ 阅读(14) 评论(0) 推荐(0) 编辑