xqn2017

导航

上一页 1 ··· 3 4 5 6 7 8 9 下一页

2017年12月11日 #

【剑指offer】从尾到头翻转打印单链表

摘要: #include #include #include using namespace std; struct ListNode { int m_Value; ListNode *next; }; void ReversePrint(ListNode* pHead) { std::stack s; ListNode *pTemp = pHead; if(NULL == pHead... 阅读全文

posted @ 2017-12-11 18:19 xqn2017 阅读(239) 评论(0) 推荐(0)

python文件打包成exe

摘要: 将自己写的python文件压缩成exe有两种方法: 1、使用pyinstaller step1:安装pyinstaller,在cmd窗口使用pip install pyinstaller安装 step2:cd 到你的文件目录cd D:\py\python testcases\Slice step3: 阅读全文

posted @ 2017-12-11 09:51 xqn2017 阅读(4130) 评论(0) 推荐(0)

python实现根据文件关键字进行切分为多个文件

摘要: 来源:在工作过程中,需要统计一些trace信息,也就是一些打点信息,而打点是通过关键字进行的,因此对一个很大的文件进行分析时,想把两个打点之间的内容单独拷贝出来进行分析 阅读全文

posted @ 2017-12-11 09:50 xqn2017 阅读(4242) 评论(0) 推荐(0)

快速排序、插入排序、归并排序

摘要: 其中插入排序和快速排序均属于内排序,而归并排序则是外排序,由于归并排序使用了外部内存,用空间换取了时间,所以归并排序的时间复杂度最坏和最好都为O(N*logN),快速排序最好为O(N*logN),最坏为O(N^2); 阅读全文

posted @ 2017-12-11 09:49 xqn2017 阅读(292) 评论(0) 推荐(0)

python实现单链表的翻转

摘要: 解释一下rev函数的实现过程: line 9-11是将原链表的第一个节点变成了新链表的最后一个节点,同时将原链表的第二个节点保存在cur中 line13-16就是从原链表的第二个节点开始遍历到最后一个节点,将所有节点翻转一遍 以翻转第二个节点为例 temp = cur.next是将cur的下一个节点 阅读全文

posted @ 2017-12-11 09:48 xqn2017 阅读(3426) 评论(0) 推荐(1)

寻找最大连续子串和以及寻找最长数字串

摘要: '''寻找最大连续子串和''' def find_max_sub_sum(data): if not data: return None sub = data[0] submax = data[0] for i in range(1, len(data)): sub = max(sub+data[i], data[i]) submax = max(submax, sub) ... 阅读全文

posted @ 2017-12-11 09:45 xqn2017 阅读(850) 评论(0) 推荐(0)

寻找最长公共子串

摘要: 上述的实现方法对s和t串进行逐个字符比较,其中循环有三层,复杂度为o(n^3),《大话数据结构》里有一个逐步改进的KMP算法,以后再补充吧 阅读全文

posted @ 2017-12-11 09:44 xqn2017 阅读(224) 评论(0) 推荐(0)

半精度浮点数取5bit指数位

摘要: 半精度浮点是指用16bit表示一个浮点数,最高1bit为符号位,中间5bit为指数a,低10bit为尾数b Value = (符号位)(1+b/1024)*(2^(a-16)) 程序很简单,用pyinstaller -F getExp.py压缩成getExp.exe(见另一篇博客py文件打包成exe 阅读全文

posted @ 2017-12-11 08:59 xqn2017 阅读(1919) 评论(0) 推荐(0)

2017年12月8日 #

88. Merge Sorted Array

摘要: 原文题目: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (si 阅读全文

posted @ 2017-12-08 19:21 xqn2017 阅读(153) 评论(0) 推荐(0)

70. Climbing Stairs

摘要: 原文题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can 阅读全文

posted @ 2017-12-08 19:20 xqn2017 阅读(160) 评论(0) 推荐(0)

69. Sqrt(x)

摘要: 原文题目: Implement int sqrt(int x). Compute and return the square root of x. 读题: 题目就是求x的开根号,很重要的一点是返回值是整数,而不是浮点数,因此这个开根号其实只是接近实际开根号的值的整数而已,并不是精确的开根号,因此可以 阅读全文

posted @ 2017-12-08 19:20 xqn2017 阅读(167) 评论(0) 推荐(0)

100. Same Tree

摘要: 原文题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally ident 阅读全文

posted @ 2017-12-08 19:19 xqn2017 阅读(155) 评论(0) 推荐(0)

101. Symmetric Tree

摘要: 本题判断一个二叉树是否为对称树 题目链接: 101. Symmetric Tree 阅读全文

posted @ 2017-12-08 19:18 xqn2017 阅读(130) 评论(0) 推荐(0)

102/107. Binary Tree Level Order Traversal/II

摘要: 原文题目: 102. Binary Tree Level Order Traversal 107. Binary Tree Level Order Traversal II 读题: 102. 层序遍历二叉树,每一层作为一个数组,从上到下输出 107.层序遍历二叉树,每一层作为一个数组,反过来从下到上 阅读全文

posted @ 2017-12-08 19:17 xqn2017 阅读(140) 评论(0) 推荐(0)

110. Balanced Binary Tree

摘要: 原文链接: 110. Balanced Binary Tree 读题: 判断是否为平衡二叉树,平衡二叉树的定义是每个节点的左右子树的高度差不超过1,显然需要通过求高度,也就是树的深度差来判断。 阅读全文

posted @ 2017-12-08 19:16 xqn2017 阅读(99) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 9 下一页