2017年5月8日
摘要: Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each elemen 阅读全文
posted @ 2017-05-08 22:20 无惧风云 阅读(165) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 //快速排序 4 void Quicksort(int a[], int low, int high) 5 { 6 if (low >= high) 7 return; 8 int first = low; 9 int last = high; 10 int ... 阅读全文
posted @ 2017-05-08 17:45 无惧风云 阅读(165) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 //冒泡排序 4 void BubbleSort(int a[], int n) 5 { 6 int i, j, t; 7 for (i = 0; i = i+1; j--) 10 { 11 if (a[j] 降序】 12 { 13... 阅读全文
posted @ 2017-05-08 17:22 无惧风云 阅读(144) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 //选择排序 4 void select_sort(int a[], int n) 5 { 6 int i, j, m,t; 7 for (i = 0; i a[j]) 13 m = j; 14 } 15 if (m != i) 1... 阅读全文
posted @ 2017-05-08 17:15 无惧风云 阅读(139) 评论(0) 推荐(0)
摘要: 1 #include 2 using namespace std; 3 //直接插入排序 4 void InsertSort(int a[], int n) 5 { 6 int i, j, key; 7 for (i = 1; i = 0 && a[j]>key) 12 { 13 a[j + 1] = a[j]; 14 ... 阅读全文
posted @ 2017-05-08 16:57 无惧风云 阅读(156) 评论(0) 推荐(0)
摘要: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 阅读全文
posted @ 2017-05-08 15:32 无惧风云 阅读(129) 评论(0) 推荐(0)
摘要: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr 阅读全文
posted @ 2017-05-08 09:19 无惧风云 阅读(138) 评论(0) 推荐(0)