摘要: 1 /* 2 struct ListNode { 3 int val; 4 struct ListNode *next; 5 ListNode(int x) : 6 val(x), next(NULL) { 7 } 8 };*/ 9 class Solution { 10 public: 11 ListNode*... 阅读全文
posted @ 2019-07-05 17:39 Austin_anheqiao 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 求a^b,朴素算法就是把a连乘b次,这样一来时间复杂度是O(b)也即是O(n)级别,快速幂能做到O(logn)。 a11=a(2^0+2^1+2^3) 11的二进制是1011,11 = 2³×1 + 2²×0 + 2¹×1 + 2º×1 因此,a¹¹ = a2^0*a2^1*a2^3 = a1*a2 阅读全文
posted @ 2019-07-05 15:05 Austin_anheqiao 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 快速幂 阅读全文
posted @ 2019-07-05 15:00 Austin_anheqiao 阅读(141) 评论(0) 推荐(0) 编辑
摘要: c++ 空间换时间 时间换空间 类似于冒泡排序 阅读全文
posted @ 2019-07-05 11:40 Austin_anheqiao 阅读(127) 评论(0) 推荐(0) 编辑
摘要: swap(vec[i],vec[j]); 交换两个元素。 阅读全文
posted @ 2019-07-05 11:06 Austin_anheqiao 阅读(180) 评论(0) 推荐(0) 编辑