Vector和ArrayList以及LinkedList区别和联系,以及分别的应用场景? 1:Vector Vector的底层的实现其实是一个数组 protected Object[] elementData; 他是线程安全的,为什么呢? 由于经常使用的add()方法的源码添加synchronize ...
分类:
其他好文 时间:
2020-03-16 09:57:39
阅读次数:
49
要求 给只有0、1、2三个元素的数组排序 思路 方法1:遍历数组,利用辅助数组保存三个元素的个数,再写入(遍历两遍) 方法2:模拟三路快排,遍历一遍完成排序 实现 方法1 1 void sortColors(vector<int>& nums){ 2 int count[3] = {0}; 3 fo ...
分类:
其他好文 时间:
2020-03-16 09:52:30
阅读次数:
60
SVM(support vector machine)支持向量机. 1 间隔与支持向量 + 样本集 $D=\{(x_1, y_1), \cdots, (x_m, y_m)\}$, 其中 $x_i\in \mathbb{R}^d, y_i\in\{ 1, 1\}, i=1,\cdots,m$. + 划 ...
分类:
其他好文 时间:
2020-03-15 22:29:19
阅读次数:
82
1 #include<iostream> 2 #include<vector> 3 #pragma warning(disable:4996) 4 5 using namespace std; 6 7 struct Node 8 { 9 int data; 10 int next; 11 }; 12 ...
分类:
其他好文 时间:
2020-03-15 22:22:16
阅读次数:
51
1 //跟三数之和思想一样的,只不过多一层循环 2 class Solution 3 { 4 public: 5 vector<vector<int>> fourSum(vector<int>& nums, int target) 6 { 7 vector<vector<int>> res; 8 i ...
分类:
其他好文 时间:
2020-03-15 19:09:36
阅读次数:
55
1 //暴力求解 2 class Solution 3 { 4 public: 5 string longestCommonPrefix(vector<string>& strs) 6 { 7 if(strs.empty()) return ""; 8 int n = strs.size(); 9 ...
分类:
其他好文 时间:
2020-03-15 18:59:20
阅读次数:
55
1 class Solution 2 { 3 public: 4 int a[13] = {1,4,5,9,10,40,50,90,100,400,500,900,1000}; 5 vector<string> b = {"I","IV","V","IX","X","XL","L","XC","C" ...
分类:
其他好文 时间:
2020-03-15 18:58:46
阅读次数:
59
1.Vector和ArrayList以及LinkedList区别和联系,以及分别的应用场景 线程安全 Vector:与ArrayList一样,也是通过数组实现的,不同的它支持线程的同步,底层采用synchronized同步方法进行加锁,所以线程安全;即某一时刻只有一个线程能够写Vector,避免多线 ...
分类:
其他好文 时间:
2020-03-15 18:57:38
阅读次数:
69
1 // 312/313 始终会出现一种情况——>全0 2 3 // 后来引进了双指针算法 4 class Solution 5 { 6 public: 7 vector<vector<int>> threeSum(vector<int>& nums) 8 { 9 vector<vector<int ...
分类:
其他好文 时间:
2020-03-15 18:57:12
阅读次数:
62
1 //搞清楚各个变量的含义 2 //***忘记对数组进行排序,以至于一直卡在这里*** 3 class Solution 4 { 5 public: 6 int threeSumClosest(vector<int>& nums, int target) 7 { 8 int n = nums.si ...
分类:
其他好文 时间:
2020-03-15 18:55:39
阅读次数:
55