tantan的博客

Notes, ideas, and observations

思路: 先归并排序, 再寻找中间位置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution {
public:
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
int i=0,j=0;
int len1=nums1.size(),len2=nums2.size(),len=len1+len2;
int t, lastt;
while(i+j<=len/2){
lastt=t;
if(i<len1 && j< len2){
int n1=nums1[i];
int n2=nums2[j];
if(n1<n2){
t=n1;
i++;
}else{
t=n2;
j++;
}
}else if(i<len1){
t=nums1[i++];
}else{
t=nums2[j++];
}
cout<<i+j<<":"<<t<<endl;
}
return (len%2?t:(t+lastt)/2.0);
}
};

#C++ STL 中 unique 的用法

1
2
3
4
5
6
template <class ForwardIterator>
ForwardIterator unique ( ForwardIterator first, ForwardIterator last );

template <class ForwardIterator, class BinaryPredicate>
ForwardIterator unique ( ForwardIterator first, ForwardIterator last,
BinaryPredicate pred );

给定一个整数数组,判断是否存在重复元素。

如果任意一值在数组中出现至少两次,函数返回 true 。如果数组中每个元素都不相同,则返回 false 。

思路: 先差分, 然后把所有0和相邻同号的数字(之一)去掉, 剩下的元素数量+2既是最终答案

注意: 元素个数为0, 元素个数为1, 差分后有0出现

决定开始刷leetcode了

目标: 每天一道如果每日一题是easy, 就加一道hard 如果每日一题是easy, 就加一道medium

#Linux 内核提权

  • 获取内核版本

Java的ORM框架 vs Python的ORM框架

TODO: 待更新

Spring学习

#IoC容器

#前言

什么垃圾软件, 毁我人生!!

Visio 画图如何添加自定义连接点

在工具栏选中"连接点"

0%