会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
红桃J
用心写好每行完美的代码,远比写一堆更有价值
博客园
::
首页
::
博问
::
闪存
::
新随笔
::
联系
::
订阅
::
管理
::
公告
上一页
1
2
3
4
5
6
7
8
9
···
15
下一页
2015年5月6日
STL 堆的使用
摘要: 本来是要写leetcode上的merge k sorted lists那道题目,这个题目我还是很熟悉的,毕竟是看过算法导论的人,但是写的过程中对堆的维护代码还是挺多的,所以我想到了STL中的堆。下面就来学习一下这个STL。先介绍一个非常好的学习C++的网站http://www.cplusplus.c...
阅读全文
posted @ 2015-05-06 15:45 红桃J
阅读(542)
评论(0)
推荐(0)
2015年5月1日
设计模式1
摘要: 静态工厂模式,工厂方法模式,抽象工厂模式工厂方法改进了添加新产品时,静态工厂不满足的开-闭原则;而抽象工厂满足了当产品是一个产品族的情况。桥接模式,命令模式桥接模式将抽象部分与实现部分分离,使它们可以相互独立命令模式中命令的执行是作为该命令属性的命令执行者执行的,并不必须返回什么,只要执行完命令即可...
阅读全文
posted @ 2015-05-01 23:19 红桃J
阅读(130)
评论(0)
推荐(0)
2015年4月23日
leetcode Search Insert Position
摘要: 代码: 1 #include 2 3 using namespace std; 4 5 int searchInsert(int A[], int n, int target) { 6 int l = 0; 7 int r = n - 1; 8 while (l A[m...
阅读全文
posted @ 2015-04-23 16:53 红桃J
阅读(126)
评论(0)
推荐(0)
2015年4月22日
leetcode Search for a Range
摘要: 代码: 1 #include 2 #include 3 4 using namespace std; 5 6 int searchSmallest(int A[], int n, int target){ 7 int l = 0; 8 int r = n - 1; 9 w...
阅读全文
posted @ 2015-04-22 22:04 红桃J
阅读(120)
评论(0)
推荐(0)
leetcode Next Permutation
摘要: 我的代码:#include#include#includeusing namespace std;void swap(int &a, int &b){ int t = a; a = b; b = t;}void nextPermutation(vector &num) { i...
阅读全文
posted @ 2015-04-22 21:27 红桃J
阅读(142)
评论(0)
推荐(0)
leetcode Divide Two Integers
摘要: 题目:Divide Two Integers思考方式:刚开始无从下手,tag里的提示是binary search 也就是二分搜索,以前的二分搜索都是知道两端开始向中间靠拢。这里的二分搜索是向右方靠拢, 然后循环的地方在如果越界,就在最后的区间内寻找,可见这种二分搜索的效率是不如那种的。但是这依然是O...
阅读全文
posted @ 2015-04-22 20:12 红桃J
阅读(128)
评论(0)
推荐(0)
2015年4月21日
leetcode Remove Element
摘要: 代码:#includeusing namespace std;int removeElement(int A[], int n, int elem) { int t = 0; for (int i = 0; i < n; i++){ if (A[i] == elem){ ...
阅读全文
posted @ 2015-04-21 19:57 红桃J
阅读(126)
评论(0)
推荐(0)
leetcode Swap Nodes in Pairs
摘要: 我写的代码就不贴了。下面这个是discuss里看的,代码真的好简洁,而且思路清晰,并不影响阅读,学习 1 public class Solution { 2 public ListNode swapPairs(ListNode head) { 3 ListNode start = new...
阅读全文
posted @ 2015-04-21 19:31 红桃J
阅读(147)
评论(0)
推荐(0)
leetcode Remove Duplicates from Sorted Array
摘要: 做这个问题时没有看认真看题,把sorted看漏了,结果写了如下代码:虽然错了,但我觉得我下面这个代码写的还是挺不错的。 1 #include 2 3 using namespace std; 4 5 int removeDuplicates(int A[], int n) { 6 int...
阅读全文
posted @ 2015-04-21 18:03 红桃J
阅读(139)
评论(0)
推荐(0)
Windows系统编程之进程同步试验
摘要: 试验过程中调用了不少系统函数,并且涉及到一些系统级的概念,在此记录下来做为解决问题的一种方式。也许在以后的编程的过程中是否可以通过调用系统平台上的东西来完成一些任务,这仍不失为一种好的思维方式。多线程编程时通常要考虑到进程是否已经结束,进程等待等问题。那么你需要这两个函数(WaitForSingle...
阅读全文
posted @ 2015-04-21 16:59 红桃J
阅读(747)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
···
15
下一页