Single Number II

https://oj.leetcode.com/proble…,承前,http://zrj.me/archives/1344,这个题目是每个数字出现三次,要求找出只出现一次的数字: 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 ……

阅读全文

Linux bash explode string

想要对一个很长的行根据分隔符断开,搜了一下,这次万能的 stackoverflow 居然没有合适的答案,于是只能自己搞,想了想,其实很简单,这么写就可以了 head part-00079 -n 1 | sed "s/\t/\r\n/g" 其实就是 sed,这个思路可以自由发挥的空间很大,想实现什么效果都简单

阅读全文

Single Number

来看这个题,https://oj.leetcode.com/proble…: Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 第一反应就是异或,唯一需要确认的就是异……

阅读全文

Linked List Cycle

所谓拳不离手曲不离口,算法和基础不能丢。 话说三藏师徒四人辞别女儿国,再上西行路,今天来到。。。啊呸,扯远了。。 今天来看这个,https://oj.leetcode.com/proble…,题目是这么说的 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 这题原……

阅读全文