摘要:
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, ... 阅读全文
posted @ 2015-09-03 23:49
vincently
阅读(226)
评论(0)
推荐(0)
摘要:
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1相似题目:《剑指offer》面试题19/** * Definition for... 阅读全文
posted @ 2015-09-03 23:07
vincently
阅读(177)
评论(0)
推荐(0)
摘要:
题目来源:《剑指offer》面试题30 题目:输入n个整数,找出其中最小的k个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1、2、3、4. 解法一:利用快速排序Partition的思想来解决这个问题。如果基于数组的第k个数字来调整,使得比第k个数字小的所有数字都位... 阅读全文
posted @ 2015-09-03 22:55
vincently
阅读(248)
评论(0)
推荐(0)
摘要:
题目来源:《剑指offer》面试题31、《编程之美》2.14 题目:输入一个整形数组,数组里有正数也有负数。数组中一个或连续多个整数组成一个子数组。求所有子数组的和的最大值 解法一:假设id代表自序列的一个起点,j代表终点。如果a[i]是负的,那么它不可能代表最优子序列的起点,因为任何包含a... 阅读全文
posted @ 2015-09-03 21:34
vincently
阅读(193)
评论(0)
推荐(0)
摘要:
Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文
posted @ 2015-09-03 17:58
vincently
阅读(178)
评论(0)
推荐(0)
摘要:
Reverse a singly linked list. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ... 阅读全文
posted @ 2015-09-03 15:14
vincently
阅读(154)
评论(0)
推荐(0)
浙公网安备 33010602011771号