#include <bits/stdc++.h>
using namespace std;
int main()
{
string s1 = "Alice";
s1 +='\0';
s1 +='\0';
cout << s1.size() << endl; // output: 7
string s2 = "Alice";
s2 += "\0";
s2 += "\0";
cout << s2.size() << endl; // output: 5
}
Run Code Online (Sandbox Code Playgroud)
这里有什么问题?
请解释单引号和双引号在连接中的作用的区别。
std::lower_bound和函数的复杂度是多少std::upper_bound。
我知道万一std::set<int>是这样log(n),但我不知道std::vector<int>。
我正在使用向量 和 来实现最长递增子序列std::lower_bound。
这段代码的复杂度是多少?
int LIS2(vector<int> a) {
vector<int> v;
for (int i = 0; i < a.size(); i++) {
auto it = lower_bound(v.begin(), v.end(), a[i]);
if (it != v.end())
*it = a[i];
else
v.push_back(a[i]);
}
return v.size();
}
Run Code Online (Sandbox Code Playgroud)