- 博客(4)
- 收藏
- 关注
原创 LeetCode——204. 计数质数
class Solution { public: int countPrimes(int n) { if(n<=2) return 0; int times[n]; for(int i=0;i<n;i++) times[i]=1; for(int i=2;i<n;i++){ for(...
2018-11-12 10:56:07
148
原创 448. 找到所有数组中消失的数字——c++
给定一个范围在 1 ≤ a[i] ≤ n ( n = 数组大小 ) 的 整型数组,数组中的元素一些出现了两次,另一些只出现一次。 找到所有在 [1, n] 范围之间没有出现在数组中的数字。 您能在不使用额外空间且时间复杂度为O(n)的情况下完成这个任务吗? 你可以假定返回的数组不算在额外空间内。 示例: 输入: [4,3,2,7,8,2,3,1] 输出: [5,6] class...
2018-10-22 20:10:35
457
原创 找到下一个排列——C++
class Solution { public: void swap(vector<int>& nums,int i,int change){ int temp; temp = nums[i]; nums[i] = nums[change]; nums[change] = temp; so...
2018-10-22 19:31:40
282
原创 859. 亲密字符串(Buddy Strings)——C++
class Solution { public: bool buddyStrings(string A, string B) { vector<int> a; if(A.length()==0 || B.length()==0) return false; else if(A.length()!=B.length()) retu...
2018-10-22 19:30:59
446
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人