随笔分类 - leetcode
摘要:问题描述 解决方案 //按照组合的方法,求解 class Solution { public: int countNumbersWithUniqueDigits(int n) { if(n==0) return 1; int count=10; for(int i=2;i
阅读全文
摘要:问题描述 解决方案
阅读全文
摘要:问题描述 解决方案 我的解决方法 class Solution { public: int climbStairs(int n) { int a=1,b=1; for(int i=1;i
阅读全文
摘要:问题描述 解决方案 我的方法 别人的
阅读全文
摘要:问题描述 解决方案 class Solution { public: int maxProfit(vector& prices) { int ret =0; for(int i=1;i
阅读全文
摘要:问题描述 解决方案 class Solution { public: bool containsNearbyDuplicate(vector& nums, int k) { unordered_map mii; for(int i=0;i
阅读全文
摘要:问题描述 解决方案 cpp class Solution { public: int firstUniqChar(string s) { unordered_map mci; for(int i=0;i
阅读全文
摘要:问题描述 解决方案
阅读全文
摘要:问题描述 解决方案 下面两种方法的原理是相同的 cpp // class Solution { // public: // void rotate(vector& nums, int k) { // k%=nums.size(); // reverse(nums.begin(),nums.end()
阅读全文
摘要:问题描述 解决方案 cpp class Solution { public: //考虑溢出情况 int myAtoi(string str) { long long int lli=atoll(str.c_str()); if(lli 0&&lli INT_MAX) lli=INT_MAX; if(
阅读全文
摘要:问题描述 解决方案 非递归方式 递归方式
阅读全文
摘要:问题描述 解决方案 cpp class Solution { public: bool isPowerOfThree(int n) { if(n
阅读全文
摘要:问题描述 解决方案 cpp class Solution { public: // int majorityElement(vector& nums) { // sort(nums.begin(),nums.end()); // return nums[nums.size()/2]; // } in
阅读全文
浙公网安备 33010602011771号