摘要: Given an integer array, sort it in ascending order. Use selection sort, bubble sort, insertion sort or any O(n2) algorithm.分析bubble sort1234567891011121314151617181920public class Solution { /** ... 阅读全文
posted @ 2017-02-10 22:31 copperface 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, sort it in ascending order. Use quick sort, merge sort, heap sort or any O(nlogn) algorithm.分析Quick Sortindex 0 1 2 3 4 5 6 7 8 9 10 11 12 13A(key=3)4 1 2 1 5 1 3 2 3 6 2 1... 阅读全文
posted @ 2017-02-10 22:31 copperface 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 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, white and blue.Here, we will use the integers 0, 1... 阅读全文
posted @ 2017-02-10 21:01 copperface 阅读(182) 评论(0) 推荐(0) 编辑
摘要: Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The result can be in any ... 阅读全文
posted @ 2017-02-10 11:18 copperface 阅读(179) 评论(0) 推荐(0) 编辑