ITeye博客

2014 年文章归档

共 5 篇文章

Single Number II

Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 用one, two, three标记当前数出现一次、两次、三次。每处理一个数时分别计算与、异或、非,当前数字出现三个时前两个变量为1, 第3个变量为0;从而清除该数字;最后…

2014-02-19 15:26 · leetcode

Median of Two Sorted Arrays

http://oj.leetcode.com/problems/median-of-two-sorted-arrays/ 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 O(log (m+n)). 思路: (1)时间复杂度O(log(m+n)),联想到递归法; (2)问题形式化为:查找两个数组的第K大小的数findKth(A, m, B, n,…

2014-02-11 09:54 · leetcode

Two-Sum

问题: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2…

2014-02-10 14:35 · leetcode

Ubuntu latex

sudo apt-get install texlive sudo apt-get install texmaker // gui editor sudo apt-get install latex-cjk-all // for chinese (1) vim test.tex \documentclass{article} \begin{document} hello world \end{document} (2) latex test.tex // 编译 (3) xdvi test.dvi & // 预览内容 (4) dvipdf test.dvi // 转换成pdf

2014-01-16 12:37 · 软件安装及使用

Git Wiki

Create Git repository on server At home of user 'git'. git@server:~$ mkdir myproject.git git@server:~$ cd myproject.git git@server:~/myproject.git$ git init --bare #Create repository on server. Create a master branch for the server. At home of user 'git'. git@server:~$ mkdir initial.commit git@serv…

2014-01-10 10:24 · Linux