摘要: 快排```pythondef quicksort(L,low,high): if low =L[low] and low=0 and L[j]>key: L[j+1] = L[j] j -= 1 L[j+1] = key retu... 阅读全文
posted @ 2015-03-06 18:48 sonic0214 阅读(253) 评论(0) 推荐(0) 编辑
摘要: 问题描述: Given an array of integers, every element appears three times except for one. Find that single one. 参考出现两次的,也是需要异或运算,问题是现在得判断出现三次归零的运算。需要两个... 阅读全文
posted @ 2015-03-06 17:02 sonic0214 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 问题描述: Given an array of integers, every element appears twice except for one. Find that single one.每个元素出现两次,主要考察异或运算。一开始考虑到两两相消,但忘记存储时是用01存储,可以用异... 阅读全文
posted @ 2015-03-06 12:25 sonic0214 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 问题描述: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may... 阅读全文
posted @ 2015-03-06 12:15 sonic0214 阅读(81) 评论(0) 推荐(0) 编辑