- 博客(25)
- 资源 (34)
- 问答 (1)
- 收藏
- 关注
原创 488. Zuma Game(leetcode DFS hard)
本题采用DFS求解,代码参考来自leetcode discussion, 地址如下 https://discuss.leetcode.com/topic/76681/simple-c-dfs-solution-using-list 不过我进行了相关的改进和说明。488. Zuma Game题目地址https://leetcode.com/problems/zuma-game/?tab=Descr
2017-02-24 11:48:52 1824 1
转载 432. All O`one Data Structure (类似 LFU算法的设计)
题目地址https://leetcode.com/problems/all-oone-data-structure/?tab=Descriptionac转载http://www.cnblogs.com/grandyang/p/6012229.html主要是双向链表 + map结构数据结构设计下面是纯粹用自己写的双向链表 和 C++ map 的ac代码 需要注意各种inc和dec处理的各种情况typ
2017-02-23 22:29:26 737
转载 473. Matchsticks to Square(dfs+回溯) / 416. Partition Equal Subset Sum 动归
题目地址https://leetcode.com/problems/matchsticks-to-square/?tab=Description题目描述Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out
2017-02-23 11:47:27 298
转载 Google C++测试单元工具 gtest(二)
gtest 学习和使用系列文章参考 作者:CoderZh 地址:http://www.cnblogs.com/coderzh/archive/2009/03/31/1426758.htmlgtest 断言gtest中,断言的宏可以理解为分为两类,一类是ASSERT系列,一类是EXPECT系列。一个直观的解释就是:ASSERT_* 系列的断言,当检查点失败时,退出当前函数(注意:并非退出当前案例
2017-02-22 11:46:25 646
转载 Google C++测试单元工具 gtest简单使用(win vs & linux)
转载于 作者:fengbingchun 地址:http://blog.csdn.net/fengbingchun/article/details/39667571我的实践如下(win7, vs2010, gtest-1.7.0)gtest的github地址如下: https://github.com/google/googletest可以下载一个release版本,比如 https://gi
2017-02-22 10:03:20 5817
原创 页面置换算法--LFU算法实现-O(1)时间复杂度
LFU: least frequently used (LFU) page-replacement algorithmleetcode题目地址https://leetcode.com/problems/lfu-cache/?tab=Description题目描述Design and implement a data structure for Least Frequently Used (LFU)
2017-02-21 10:50:08 13429
转载 126. Word Ladder II 、 127. Word Ladder(leetcode BFS+DFS)
127. Word Ladder 题目地址https://leetcode.com/problems/word-ladder/acac代码餐卡 博主:陆草纯 地址:http://www.cnblogs.com/ganganloveu/p/4125695.html 直接采用bfs, 注意判重,解map,set结构struct Node{ string word; int len
2017-02-17 18:51:47 601
转载 1119. Pre- and Post-order Traversals (30) (先序+后序,确定二叉树?)
题目地址https://www.patest.cn/contests/pat-a-practise/1119题目描述Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder
2017-02-16 20:41:43 1200
原创 1118. Birds in Forest (25) (并查集,注意顺序)
题目地址https://www.patest.cn/contests/pat-a-practise/1118题目描述Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree.
2017-02-16 14:10:57 467
原创 linux fork相关题目
求解可以采用如下的方式 i = 2的情况,在ubuntu下能打印出6个* printf(“\n”) 与否例子fork调用的一个奇妙之处就是它仅仅被调用一次,却能够返回两次,它可能有三种不同的返回值: 1)在父进程中,fork返回新创建子进程的进程ID; 2)在子进程中,fork返回0; 3)如果出现错误,fork返回一个负值;fork出错可能有两种原因: 1)当前的进程数已经达
2017-02-15 17:50:59 420
原创 1109. Group Photo (25) -- C++ list(双向链表使用)
题目地址https://www.patest.cn/contests/pat-a-practise/1109ac#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <iostream>#include <string>#include <vector>#include <queue>
2017-02-15 11:03:04 242
原创 1108. Finding Average (20) 字符处理
题目地址https://www.patest.cn/contests/pat-a-practise/1108ac#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <iostream>#include <string>#include <vector>#include <queue>
2017-02-15 11:01:08 349
原创 1105. Spiral Matrix (25) -- 模拟
题目地址https://www.patest.cn/contests/pat-a-practise/1105ac代码思路是:外围转一圈的函数封装起来,然后遍历填充,注意判断是否完成了#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <iostream>#include <string>
2017-02-14 19:18:09 338
转载 C++ 继承(public, protect, private)
在继承时: 不管采用哪种形式(public, protected或private),基类中的私有成员都不可以被继承;如果非要在派生类中使用基类的私有成员,可以有两种方法:一是使用属性,二是使用友元类或友元函数。 如果采用public形式,则基类除了私有成员的其它所有都被原样的继承到派生类中;即在基类中是public的,在派生类中还是public的,在基类中是protected的,在派生类中还是p
2017-02-14 12:16:12 1267
转载 页面置换算法LRU实现--leetcode O(1)时间复杂度
转载 作者:鱼与海洋 出处:http://www.cnblogs.com/joannacode/p/5998949.htmlleetcode题目地址https://leetcode.com/problems/lru-cache/题目描述Design and implement a data structure for Least Recently Used (LRU) cache. It sho
2017-02-13 10:21:13 3513
转载 在O(1)时间删除单链表结点
作者:周旭龙出处:http://edisonchou.cnblogs.com题目:给定单向链表的头指针和一个结点指针,定义一个函数在O(1)时间删除该结点。 原文采用的是C/C++,这里采用C#,节点定义如下: public class Node { // 数据域 public T Item { g
2017-02-12 21:04:42 323
原创 关于数的基础知识(存储&位运算)
为什么计算机采用补码存储数据http://www.360doc.com/content/12/1009/21/10086564_240513741.shtml字符常量一种是普通字符,即用单撇号括起来的一个字符,如’b’ ,’y’,‘?’。字符常量在储存在计算机的储存单元中时,是以其代码(一般采用ASCII代码)储存的。另一种是转义字符,即特殊字符常量。转移字符是C语言中表示字符的一种特殊形式,其
2017-02-12 14:41:57 850
原创 1085. Perfect Sequence (25) -- 二分法
题目地址https://www.patest.cn/contests/pat-a-practise/1085题目描述Given a sequence of positive integers and another positive integer p. The sequence is said to be a “perfect sequence” if M <= m * p where M and
2017-02-12 10:21:06 308
原创 1112. Stucked Keyboard (20) -- 字符串处理,使用map
题目地址https://www.patest.cn/contests/pat-a-practise/1112题目描述On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will app
2017-02-11 15:40:30 371
原创 1072. Gas Station (30) -- Dijkstra
题目地址https://www.patest.cn/contests/pat-a-practise/1072ac代码1(未优化)处理思路 1,2, … , n 表示n个hourse n + 1, n + 2, … , n+m 表示 m个gas使用Dijkstra算法 ,求每一个gas到所有hourse的最小距离,然后判断结果#include <cstdint>#include <cstdi
2017-02-10 20:28:24 365
转载 C++在类的成员函数中调用delete this
原文地址 http://blog.sina.com.cn/s/blog_4b4cf2af0100ywgv.html例子1 delete this后,调用成员函数 showA(), 使用this指针操作了 数据成员,值是不可预期的 func()是虚函数,需要用到虚函数表指针,释放this后,虚函数指针可能无效,这样造成程序崩溃。例子2 析构函数中调用delete this; delet
2017-02-09 18:12:05 2455
转载 C++ 构造函数,析构函数中能否调用虚函数?
原文地址 http://blog.csdn.net/to_xidianhph_youth/article/details/39134801题1题2 题3class Base{public: virtual int foo(int x) { return x * 10; } int foo(char x[14]) { r
2017-02-09 15:44:39 2246
原创 C++ 类成员函数的重载(overload),重写/覆盖(override),隐藏
C++ 类层次中的同名函数,有三种关系:重载(overload)重写、覆盖(override)隐藏(hide,oversee)重载c++函数重载相同的范围(在同一个类中)相同的函数名字,不同的参数列表,与返回值类型没有关系virutal关键字可有可无重写、覆盖覆盖值: 在派生类中覆盖基类中的同名函数,要求基类函数必须是虚函数,且 1. 与基类的虚函数有相同的参数列表 2. 与基类
2017-02-08 21:10:44 14789 1
原创 C++ static的作用,非类中,和类中的static
不考虑类 static 的三个作用作用1: 隐藏当同时编译多个文件时,所有未加static前缀的全局变量和函数都具有全局可见性。例如,同一模块中,一个a.c,一个main.c a.c中char a = 'A';void msg(){}在main.c中可以直接访问到,如果加上static, 那么将只能在本文件中访问到,而无法被该模块下的其他文件访问到作用2: static变量默认初始化为0* 包括
2017-02-07 17:15:22 2798
转载 1049. Counting Ones (30) 从1到n整数中1出现的次数
剑指offer,leetcode,PAT转载地址(下面的博文讲解的很清楚,容易明白) http://blog.csdn.net/yi_afly/article/details/52012593PAT题目联系 https://www.patest.cn/contests/pat-a-practise/1049 ac代码#include <cstdio>#include <memory>#in
2017-02-07 14:01:02 266
mvc servlet jdbc web框架
2015-06-26
wireshark tcp三次握手
2016-08-03
JavaScript基础教程
2016-02-05
java web session失效
2016-05-08
TA创建的收藏夹 TA关注的收藏夹
TA关注的人