摘要: 删除源文件注释语句的算法实现 面试某互联网公司,被问到“如何删除源文件中的注释语句?”,写了个很拙劣的算法,还没能考虑到“双引号中的//不用删除”这一环节。 写完后,面试官即说:“为什么不考虑用状态转换机呢?” 状态转换机?什么鬼?怎么用? 书到用时方恨少啊! 回去后赶紧网上搜索“状态转换机”、“删 阅读全文
posted @ 2016-10-14 11:49 HorseShoe2016 阅读(966) 评论(0) 推荐(0) 编辑
摘要: 一道容易出错的C++笔试题 求下面代码的输出内容: int main(int argc,char argv[]) { char str1[]="Hello"; char str2="World"; cout 解析: str1指向的是字符串 "Hello" 的首地址,但 str1 同时也是一个字符数组 阅读全文
posted @ 2016-09-21 18:08 HorseShoe2016 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库。 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以任意地登录和修改MySQL的信息。可以采用将MySQL对 外的端口封闭,并且停止Apache以及所有的用户进程 阅读全文
posted @ 2016-09-14 12:23 HorseShoe2016 阅读(154) 评论(0) 推荐(0) 编辑
摘要: C++类的大小 (i) 如下代码: include using namespace std; class CBase { }; class CDerive :public CBase { }; int main(int argc, char argv[]) { CDerive p[3]; cout 阅读全文
posted @ 2016-09-12 13:16 HorseShoe2016 阅读(186) 评论(0) 推荐(0) 编辑
摘要: C++类的数组中构造函数和析构函数的调用顺序(2) 对于如下的代码: include using namespace std; class CBase { private: static int count; public: int id; public: CBase() { id = CBase: 阅读全文
posted @ 2016-09-12 13:02 HorseShoe2016 阅读(2473) 评论(0) 推荐(0) 编辑
摘要: 基类和派生类:构造函数和析构函数的执行顺序 在Visual Studio中,新建控制台工程,构造类如下: include using namespace std; class CBase { public: CBase() { cout Test.exe CBase():Constructor CD 阅读全文
posted @ 2016-09-12 12:00 HorseShoe2016 阅读(4398) 评论(0) 推荐(0) 编辑
摘要: 在Android Studio中新建了一个 setting.xml 文件,布局好文件后,从 Text 界面切换到 Design 界面,显示了如下错误: 网上搜寻 The graphics preview in the layout editor may not be accurate ,还是没有解决 阅读全文
posted @ 2016-09-07 11:22 HorseShoe2016 阅读(2750) 评论(0) 推荐(0) 编辑
摘要: 395. Longest Substring with At least K Repeating Characters Find the length of the longest substring T of a given string (consists of lowercase letter 阅读全文
posted @ 2016-09-05 22:18 HorseShoe2016 阅读(2839) 评论(1) 推荐(0) 编辑
摘要: 394. Decode String Given an encoded string, return it's decoded string. The encoding rule is: , where the encoded_string inside the square brackets is 阅读全文
posted @ 2016-09-05 22:07 HorseShoe2016 阅读(948) 评论(0) 推荐(0) 编辑
摘要: 393. UTF 8 Validation A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: 1. For 1 byte character, the first bit is a 阅读全文
posted @ 2016-09-05 21:52 HorseShoe2016 阅读(662) 评论(0) 推荐(0) 编辑
摘要: 392. Is Subsequence Given a string s and a string t , check if s is subsequence of t . You may assume that there is only lower case English letters in 阅读全文
posted @ 2016-09-05 21:36 HorseShoe2016 阅读(1857) 评论(0) 推荐(0) 编辑
摘要: 5. Longest Palindromic Substring Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, a 阅读全文
posted @ 2016-09-03 20:11 HorseShoe2016 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 391. Perfect Rectangle Given N axis aligned rectangles where N 0, determine if they all together form an exact cover of a rectangular region. Each rec 阅读全文
posted @ 2016-09-01 19:58 HorseShoe2016 阅读(817) 评论(0) 推荐(0) 编辑
摘要: 390. Elimination Game There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afte 阅读全文
posted @ 2016-08-30 22:57 HorseShoe2016 阅读(975) 评论(1) 推荐(0) 编辑
摘要: 问题描述 今天用Android Studio开发了一个简单的调用摄像头的App,结果想调试的时候发现选择调试设备的对话框中,手机名称后面总是跟着一个[OFFLINE]的标识,只能选择启动AVD来进行调试,但手机摄像头的App在AVD中是无法调试的。 网上找了很多解决方案: 1. 说是 adb 的版本 阅读全文
posted @ 2016-08-29 11:55 HorseShoe2016 阅读(5614) 评论(1) 推荐(0) 编辑
摘要: 水平遍历二叉树 题目描述 对于一棵给定的二叉树: 1 / \ 2 3 / \ / \ 4 5 6 7 其水平遍历结果为: 1,2,3,4,5,6,7 算法分析 考虑使用队列来循环遍历该二叉树,首先将根节点放进队列中,循环判断队列是否为空,如果不为空, 则说明还有数据没有遍历到,所以取出队首节点,将队 阅读全文
posted @ 2016-08-22 16:25 HorseShoe2016 阅读(667) 评论(0) 推荐(0) 编辑
摘要: 中序遍历和后序遍历构造二叉树 题目描述 根据中序遍历和后序遍历构造二叉树 注意事项 你可以假设树中不存在相同数值的节点 样例 给出树的中序遍历: [1,2,3] 和后序遍历: [1,3,2] 返回如下的树: 2 / \ 1 3 算法分析: 给定同一课二叉树的中序和后序遍历数组,那么后序遍历数组的最后 阅读全文
posted @ 2016-08-22 16:05 HorseShoe2016 阅读(687) 评论(0) 推荐(0) 编辑
摘要: 子树 题目描述 有两个不同大小的二叉树:T1有上百万的节点;T2有好几百的节点。请设计一种算法,判定T2是否为T1的子树。 注意事项 若 T1 中存在从节点 n 开始的子树与 T2 相同,我们称 T2 是 T1 的子树。也就是说,如果在T1节点n处将树砍 断,砍断的部分将与T2完全相同。 样例 下面 阅读全文
posted @ 2016-08-22 15:58 HorseShoe2016 阅读(503) 评论(0) 推荐(0) 编辑
摘要: 等价二叉树 题目描述 检查两棵二叉树是否等价。等价意思是说,首先两棵二叉树必须拥有相同的结构,并且每个对应位置上的节点上的数据相等。 样例 1 1 / \ / \ 2 2 and 2 2 / / 4 4 这就是两棵等价的二叉树。 1 1 / \ / \ 2 3 and 2 3 / \ 4 4 算法分 阅读全文
posted @ 2016-08-22 15:49 HorseShoe2016 阅读(246) 评论(0) 推荐(0) 编辑
摘要: 二叉树的所有路径 题目描述 给定一棵二叉树,找从根节点到叶子节点的所有路径 样例 给出下面这课二叉树: 1 / \ 2 3 \ 5 所有根到叶子的路径为: [ "1 2 5", "1 3" ] 算法分析: 递归地处理二叉树,先将子树的所有路径求出,然后把根节点的数据贴到子路径的所有结果上 Java算 阅读全文
posted @ 2016-08-22 15:42 HorseShoe2016 阅读(943) 评论(0) 推荐(0) 编辑