自己写的代码,记录一下。分别记录了两种partition的方法。public class QuickSort { public static void quickSort(int[] nums, int start, int end) { if(start >= end) { ...
分类:
编程语言 时间:
2015-07-14 15:23:46
阅读次数:
111
Question:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a ca...
分类:
其他好文 时间:
2015-07-14 09:48:40
阅读次数:
118
leetcode 234: Palindrome Linked List
python, java, c++...
分类:
其他好文 时间:
2015-07-14 06:14:43
阅读次数:
262
简述:改变序列算法,参见http://www.cplusplus.com/reference/algorithm/?kw=algorithm/*template BidirectionalIterator partition (BidirectionalIterator first, Bidirec...
分类:
编程语言 时间:
2015-07-13 20:29:55
阅读次数:
112
Given a singly linked list, determine if it is a palindrome.
判断一个链表是不是回文的,一个比较简单的办法是把链表每个结点的值存在vector里,然后首尾比较,时间复杂度O(n),空间复杂度O(n)。
/**
* Definition for singly-linked list.
* struct ListNode {
* ...
分类:
其他好文 时间:
2015-07-13 18:46:53
阅读次数:
120
该函数官方的api,说的不是很明白:aggregate(zeroValue, seqOp, combOp)Aggregate the elements of each partition, and then the results for all the partitions, using a gi...
分类:
其他好文 时间:
2015-07-13 13:42:45
阅读次数:
155
leetcode: palindrome-number
分离出最左边和最右边的数
然后依次对比即可...
分类:
其他好文 时间:
2015-07-13 10:18:40
阅读次数:
95
125 Valid Palindrome链接:https://leetcode.com/problems/valid-palindrome/
问题描述:
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For exampl...
分类:
其他好文 时间:
2015-07-13 10:17:15
阅读次数:
145
该题目的要求是判断一个单链表是否是回文链表,题目的难度在于O(n)时间和O(1)空间的限制。
由于单链表不能反向访问,所以不能直接通过原来的链表来判断,解题的思路是首先对原来的链表的前半部分进行判断,然后进行判断(如链表为“12344321” 反转之后为“43214321”)。想到这一点之后的实现就非常简单了,完整的代码如下所示:
class Solution {
public:
Li...
分类:
其他好文 时间:
2015-07-12 17:27:31
阅读次数:
108
Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?https://leetco...
分类:
编程语言 时间:
2015-07-12 17:00:30
阅读次数:
261