08 2014 档案

摘要:今天在某个群中看到有人问在流式的数据中如何动态的维护中位数的方法,因为之前看到同学的一个问题,当时他没答出来。但是后来了解到类似top(k),last(k)需要用到最大堆,最小堆一样,中位数需要利用双堆维护一下。 先复习一下,如果是静态的数据求取中位数的方法有哪些呢? (1)排序 ... 阅读全文
posted @ 2014-08-30 13:31 weixliu 阅读(897) 评论(0) 推荐(0)
摘要:今天学习到二叉树的时候,看到了二叉树的先序,后序,中序遍历方法。然而二叉树遍历方法递归实现十分简单,迭代版本实现起来些许复杂,就又上手试试二叉树的各种遍历方法以及实现版本,当是温习一遍之前了解到的实现方法。 三种遍历方法中递归实现难度相当,代码相当简略。 三种遍历方法中利用栈实现的迭代版本中... 阅读全文
posted @ 2014-08-29 22:49 weixliu 阅读(3596) 评论(0) 推荐(0)
摘要:MySQL的知识面试中还是经常被问到的,简单的使用似乎无法达到面试官的要求,很多问题会关于Mysql存储引擎,所以这里还是需要系统学习一下Mysql的一些知识,面试过程中游刃有余。MySQL体系结构MySQL是多个子系统构成的层次化的系统。a.Connectors:用来与客户端应用程序建立连接的... 阅读全文
posted @ 2014-08-29 11:04 weixliu 阅读(394) 评论(1) 推荐(0)
摘要:搜狐面试的感觉很独特,没有算法题,比较偏应用。针对我的项目刨根究底的问了一下,可能面试官刚好后台开发,所以针对简历里面的web服务器特别感兴趣,两个项目其实就是python中web框架的简单应用,被鄙视了一下。可是我学起来写起来也是费了些心力的呀。搜狐提供的职位说是后台开发,前端开发,移动开发。... 阅读全文
posted @ 2014-08-28 21:04 weixliu 阅读(1452) 评论(0) 推荐(0)
摘要:今天学习的时间虽然挺多的,但是总觉效率不高。其实今天没有按照计划进行EPI题目的浏览,白天去看了其他的书籍。准备找工作可能需要的状态是一定量经典的书,偶尔温习才可。书是看不完的,知识点也是固定的。所以从把手头的几本书在浏览完毕之后就要着手复习之前的知识啦。C++的知识,leetcode的题目,操... 阅读全文
posted @ 2014-08-28 11:12 weixliu 阅读(3577) 评论(0) 推荐(0)
摘要:链表的题目总体来说细节比较多,因为链表的题目在操作链表的过程中本身有些复杂,所以如果链表作为编程题出现的时候,多数情况下题目本身的思路可能不是很复杂,不要把题目往复杂的方向去思考就好了~这里的链表只是说单向链表,双向链表,跳表。树的链表表示形式不属于这个链表的范畴。1.合并两个有序的链表。额外空... 阅读全文
posted @ 2014-08-26 19:45 weixliu 阅读(1737) 评论(1) 推荐(1)
摘要:学习的速度有些慢,脑袋转动的频率有些不是很高。不过今天的效率我觉得还是可以,应该不能称效率吧,就是整个感觉不错,感觉自己补充了很多的知识。其实G家和F家败了之后不知道看看算法题对接下来的找工作帮助是否会很大,但是看算法题目也是提高解决问题能力的一种方式吧,锻炼思维。僵化的思维实在有些不能忍受。 ... 阅读全文
posted @ 2014-08-26 17:24 weixliu 阅读(552) 评论(1) 推荐(0)
摘要:1.关于奇偶校验的方法中,如何快速的求取一个64-bit的数字的奇偶校验位。(如果1的位数为奇数,则奇偶校验位为1,如果1的位数为偶数,则奇偶校验位为0) a.暴力枚举法采用一位一位进行计算,一位一位的移位,效率较低。int getParity(long long _64bitsnum) { ... 阅读全文
posted @ 2014-08-25 00:54 weixliu 阅读(701) 评论(0) 推荐(0)
摘要:今天有一个枚举的题目的代码是这样的: 重点在于maxXor这个函数的实现,枚举两个数字,其中maxr保存了最大值的 i 异或 j , 可是这个程序执行结果大大出乎意外-_-. 然后就把 i 异或 j 的结果临时保存在int,进行比较,程序正确的执行了。原来是被操作符优先级坑到了。位操作的优先级... 阅读全文
posted @ 2014-08-21 19:43 weixliu 阅读(398) 评论(0) 推荐(0)
摘要:之前在买书的时候凑单的时候买了一本《程序员的数学》,希望能够提升一下自己解决问题的能力,数学应该是最锻炼脑力的学科了。但是当我兴冲冲的去翻阅这本书的时候,展现在我面前的内容不是很符合我的要求~一句话,知识太过于基础。 我觉得这本书面向的读者更适合那些刚接触程序员的人,这样可以从数学的角度把他们... 阅读全文
posted @ 2014-08-21 15:51 weixliu 阅读(4889) 评论(0) 推荐(0)
摘要:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not... 阅读全文
posted @ 2014-08-20 13:32 weixliu 阅读(898) 评论(0) 推荐(0)
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文
posted @ 2014-08-20 13:25 weixliu 阅读(222) 评论(0) 推荐(0)
摘要:Sort a linked list using insertion sort.1st ( 3 tries)/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next... 阅读全文
posted @ 2014-08-20 13:24 weixliu 阅读(352) 评论(0) 推荐(0)
摘要:Sort a linked list inO(nlogn) time using constant space complexity.1st ( 7 tries)/** * Definition for singly-linked list. * struct ListNode { * in... 阅读全文
posted @ 2014-08-20 13:22 weixliu 阅读(344) 评论(0) 推荐(0)
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.1st (7 tries)class Solution {public: int maxPoin... 阅读全文
posted @ 2014-08-20 13:21 weixliu 阅读(180) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2014-08-20 13:19 weixliu 阅读(166) 评论(0) 推荐(0)
摘要:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the". click to show clarification.C... 阅读全文
posted @ 2014-08-20 13:18 weixliu 阅读(197) 评论(0) 推荐(0)
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文
posted @ 2014-08-20 13:16 weixliu 阅读(196) 评论(0) 推荐(0)
摘要:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文
posted @ 2014-08-20 13:13 weixliu 阅读(350) 评论(0) 推荐(0)
摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic... 阅读全文
posted @ 2014-08-20 13:11 weixliu 阅读(600) 评论(0) 推荐(0)
摘要:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2014-08-20 13:08 weixliu 阅读(203) 评论(0) 推荐(0)
摘要:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen... 阅读全文
posted @ 2014-08-20 13:06 weixliu 阅读(177) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest... 阅读全文
posted @ 2014-08-20 13:03 weixliu 阅读(988) 评论(1) 推荐(0)
摘要:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ... 阅读全文
posted @ 2014-08-20 13:00 weixliu 阅读(509) 评论(0) 推荐(0)
摘要:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function ... 阅读全文
posted @ 2014-08-20 12:56 weixliu 阅读(2193) 评论(0) 推荐(0)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2014-08-20 12:52 weixliu 阅读(194) 评论(0) 推荐(0)
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret... 阅读全文
posted @ 2014-08-20 12:47 weixliu 阅读(1244) 评论(0) 推荐(0)
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文
posted @ 2014-08-20 12:44 weixliu 阅读(124) 评论(0) 推荐(0)
摘要:最近两天在找工作的过程中颇受打击,两家高大上的公司看起来就是要收集世界上最聪明的人~,在参加G家的online test之前还天真的认为一不小心通过了怎么办呢?考完试之后才发现真的是想多了,关于题目看起来像是实际应用中确实存在的一些算法题目。 有些题目形成解决问题的思路都觉得挺难的,思考的过程... 阅读全文
posted @ 2014-08-19 08:05 weixliu 阅读(536) 评论(0) 推荐(0)
摘要:针对海量数据,可以使用的方法非常多,常见的方法有:Hash法,Bit-map法,Bloom filter法,数据库优化法,倒排索引法,外排序法,Trie树,堆,双层桶排序法(simhash法和多层划分法,实际上都是多机器分而治之的思想)以及mapreduce法。 Hash主要是用来进行”快速存... 阅读全文
posted @ 2014-08-14 16:07 weixliu 阅读(1118) 评论(0) 推荐(0)
摘要:程序,进程和线程。 程序,一组指令的有序集合。 进程,具有一定独立功能的程序关于某个数据集合上的一次运行活动,是系统进行资源分配和调度的一个独立单元。 线程,进程的一个实体,是CPU调度和分派的基本单元,是比进程更小的能独立运行的基本单元。本身基本上不拥有系统资源,只拥有一点在运行中必不可... 阅读全文
posted @ 2014-08-13 15:21 weixliu 阅读(1822) 评论(0) 推荐(0)
摘要:网络模型: C/S和B/S的区别,主要以下部分: (a)硬件要求不同,C/S一般建立在专用的网络上,是小范围的网络环境;而B/S一般构建在广域网上,不需要专门的网络硬件环境,只要能够接入网络即可。B/S架构应用中,客户端只需要能够运行浏览器即可。 (b)架构要求不同,C/S程序更加注重流... 阅读全文
posted @ 2014-08-13 11:21 weixliu 阅读(2003) 评论(0) 推荐(0)
摘要:关系数据库系统与文件数据库系统的区别如下: (a)关系数据库系统的主要特征是数据的结构化,而文件数据库系统是数据的非结构化。 (b)关系数据库系统中,用户看到的逻辑结构是二维表,而文件数据库系统中,基本元素是文件。 (c)文件数据库系统可以实现多媒体文件管理,支持C/S工作模式。 aci... 阅读全文
posted @ 2014-08-12 20:16 weixliu 阅读(2384) 评论(0) 推荐(0)
摘要:C++中,临时对象都是const类型的,由下面的程序测试可知。 另外const string &与string &两个参数类型可以进行函数重载,其实这就是类const与非const成员函数重载的机制,传入的是const引用(指针)于非const引用(指针)。编译可通过,执行结果hello wo... 阅读全文
posted @ 2014-08-12 11:23 weixliu 阅读(1664) 评论(0) 推荐(0)
摘要:摘选著名的互联网企业的面试笔试真题:1.extern的作用自己理解:应该需要区分extern在C语言中和C++语言中的作用,C语言中extern声明的函数和变量可以被该文件外部模块引用,C++语言中除了该作用还可以声明extern “C”声明一段代码编译连接的方法为C语言的方法。参考:其实exter... 阅读全文
posted @ 2014-08-11 10:57 weixliu 阅读(20607) 评论(4) 推荐(1)
摘要:单例模式:用来创建独一无二的,只能够有一个实例的对象。 单例模式的结构是设计模式中最简单的,但是想要完全实现一个线程安全的单例模式还是有很多陷阱的,所以面试的时候属于一个常见的考点~单例模式的应用场景:有一些对象其实只需要一个,比如:线程池,缓存,对话框,处理偏好设置和注册表的对象,日志对象,充当打... 阅读全文
posted @ 2014-08-09 11:32 weixliu 阅读(8438) 评论(0) 推荐(2)
摘要:今天参加了百度的面试,面试过程安排过程中出了些问题,上午面试完成后竟然要等到下午4点安排接下来的面试,安排的不是很紧凑,最好让每个面试者的连续面试安排在一起,面试挺消耗精力了。不过周五赶上百度的summer party,在大厅等待的时候看到很多美女-_-!百度的前台妹纸们真是很漂亮嘛。 一面:... 阅读全文
posted @ 2014-08-09 10:15 weixliu 阅读(9154) 评论(8) 推荐(5)