会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
repinkply
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
12
13
14
15
16
17
18
19
20
···
36
下一页
2020年5月1日
p152 对单链表进行插入排序(leetcode 147)
摘要: 一:解题思路 Time:O(n^2),Space:O(1) 二:完整代码示例 (C++版和Java版) C++: class Solution { public: ListNode* insertionSortList(ListNode* head) { if (head == NULL || he
阅读全文
posted @ 2020-05-01 20:34 repinkply
阅读(227)
评论(0)
推荐(0)
2020年4月29日
p151 寻找数组的中心索引(leetcode 724)
摘要: 一:解题思路 Time:O(n),Space:O(1) 二:完整代码示例 (C++版和Java版) C++: class Solution { public: int pivotIndex(vector<int>& nums) { if (nums.size() == 0) return -1; i
阅读全文
posted @ 2020-04-29 10:34 repinkply
阅读(135)
评论(0)
推荐(0)
2020年4月28日
s6 快速排序
摘要: 一:解题思路 Time:O(n*log(n)),Space:O(1) 是一种不稳定的排序方法 二:完整代码示例 (C++版和Java版) C++: template <typename T> static void Swap(T& a,T& b) { T c(a); a=b; b=c; } temp
阅读全文
posted @ 2020-04-28 18:16 repinkply
阅读(137)
评论(0)
推荐(0)
s5 归并排序
摘要: 一:解题思路 Time:O(n*log(n)),Space:O(n) 二:完整代码示例 (C++版和Java版) C++: template <typename T> static void Merge(T array[], T helper[], int begin,int mid,int end
阅读全文
posted @ 2020-04-28 17:20 repinkply
阅读(114)
评论(0)
推荐(0)
s4 希尔排序
摘要: 一:解题思路 Time:O(n^2/3),Space:O(1) 二:完整代码示例 (C++版和Java版) C++: template <typename T> static void Shell(T array[],int len,bool min2max=true) { if(len==0) r
阅读全文
posted @ 2020-04-28 16:44 repinkply
阅读(146)
评论(0)
推荐(0)
s3 冒泡排序
摘要: 一:解题思路 Time:O(n^2),Space:O(1) 二:完整代码示例 (C++版和Java版) C++: template <typename T> static void Swap(T& a,T& b) { T c(a); a=b; b=c; } template <typename T>
阅读全文
posted @ 2020-04-28 16:33 repinkply
阅读(142)
评论(0)
推荐(0)
s2 插入排序
摘要: 一:解题思路 Time:O(n^2),Space:O(1) 二:完整代码示例 (C++版和Java版) C++: template <typename T> static void Insert(T array[],int len,bool min2max=true) { if(len==0) re
阅读全文
posted @ 2020-04-28 12:18 repinkply
阅读(121)
评论(0)
推荐(0)
s1 选择排序
摘要: 一:解题思路 Time:O(n^2),Space:O(1) 二:完整代码示例 (C++版和Java版) C++: template <typename T> static void Swap(T& a,T& b) { T c(a); a=b; b=c; } template <typename T>
阅读全文
posted @ 2020-04-28 12:08 repinkply
阅读(145)
评论(0)
推荐(0)
2020年4月27日
用队列实现栈(leetcode 225)
摘要: 一:解题思路 用2个队列实现栈 二:完整代码示例 (C++、Java、Python) C++: class MyStack { private: queue<int> m_queueIn; queue<int> m_queueOut; queue<int>* m_pIn; queue<int>* m
阅读全文
posted @ 2020-04-27 21:02 repinkply
阅读(152)
评论(0)
推荐(0)
2020年4月21日
p149 第一个出错的版本(leetcode 278)
摘要: 一:解题思路 采用二分搜索的思想来做这道题目。Time:O(log(n)),Space:O(1) 二:完整代码示例 (C++版和Java版) C++: class Solution { public: int firstBadVersion(int n) { int low = 1; int hig
阅读全文
posted @ 2020-04-21 10:55 repinkply
阅读(159)
评论(0)
推荐(0)
上一页
1
···
12
13
14
15
16
17
18
19
20
···
36
下一页
公告