摘要: 思路: 先判定符号,整型范围[-2^32,2^32] 取余除10操作,依次进行,越界返回0 Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321#defi... 阅读全文
posted @ 2016-04-18 21:22 Free_Open 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 思路:利用map >做值和指针的映射,最后将指针按值依次链接起来,时间复杂度O(N),空间O(N) Merge k sorted linked lists andreturn it as one sorted list. Analyze and describ... 阅读全文
posted @ 2016-04-18 18:01 Free_Open 阅读(88) 评论(0) 推荐(0) 编辑
摘要: 寻找一个数的数根,用了暴力破解的方式,时间复杂度比较高 暂未想到O(1)的方式Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.Fo... 阅读全文
posted @ 2016-04-18 17:19 Free_Open 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 字符串转整型,更新之后的leetcode题,需考虑各种情况, 测试过标准库的atoi函数,当字符串越界返回的值是错的, 而该题要求越界时的返回边界值,更加严谨。Implement atoi to convert a string to an integer.Hint: Carefu... 阅读全文
posted @ 2016-04-18 10:13 Free_Open 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two.class Solution {public: bool isPowerOfTwo(int n) { while(n)... 阅读全文
posted @ 2016-04-17 23:53 Free_Open 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> ... 阅读全文
posted @ 2016-04-17 23:37 Free_Open 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 运行命令:g++ -fopenmp xx.cpp -lgomp -lpthread -o xx.out 用例一: #include #include #include void test (int n) { for(int i = 0; i #include #include... 阅读全文
posted @ 2016-04-17 23:16 Free_Open 阅读(326) 评论(0) 推荐(0) 编辑
摘要:  为什么需要知道C/C++的内存布局和在哪可以可以找到想要的数据?知道内存布局对调试程序非常有帮助,可以知道程序执行时,到底做了什么,有助于写出干净的代码。本文的主要内容如下: 源文件转换为可执行文件 可执行程序组成及内存布局 数据存储类别 一个实例 总结 源文件转换为可执行文... 阅读全文
posted @ 2016-04-17 18:54 Free_Open 阅读(765) 评论(0) 推荐(0) 编辑
摘要: 先看一段代码#includeusing namespace std;#define n 510void sum(int a,int b){ cout<<a+b<<endl;}void init(int (*a)[n],int (*b)[n]){ for(int i=0;... 阅读全文
posted @ 2016-04-17 18:50 Free_Open 阅读(1218) 评论(0) 推荐(0) 编辑
摘要:  经常使用 top 命令了解进程信息,其中包括内存方面的信息。命令top帮助文档是这么解释各个字段的。 VIRT , Virtual Image (kb) RES, Resident size (kb) SHR, Shared Mem size (kb) %MEM, Memory usag... 阅读全文
posted @ 2016-04-17 18:29 Free_Open 阅读(2933) 评论(0) 推荐(0) 编辑