上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 23 下一页

2021年2月9日

摘要: A:水题,求数组中只出现一次的元素的和。 1 class Solution { 2 public: 3 int sumOfUnique(vector<int>& nums) { 4 unordered_map<int,int> m; 5 for(auto x:nums){ 6 m[x]++; 7 } 阅读全文
posted @ 2021-02-09 21:44 greenofyu 阅读(75) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/1416/ 给定一串序列,要找到异或值最大的子串。 在保证右端点最小的前提下保证长度最小。 对于异或的性质 a^b^a = b,可以将前缀和应用于该题。 这样的话只需要枚举左端点和右端点,但是时间复杂度为n^2,计算之后达 阅读全文
posted @ 2021-02-09 15:54 greenofyu 阅读(68) 评论(0) 推荐(0)
摘要: Trie树查找和插入的时间复杂度均为O(n)。 https://www.acwing.com/problem/content/837/ 1 #include<iostream> 2 using namespace std; 3 const int N=1e5+10;//输入字符串的总长度为1e5+1 阅读全文
posted @ 2021-02-09 11:40 greenofyu 阅读(88) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/427/ 水题。 unique函数是将相邻的相同的元素去除掉,返回的是最后一个元素的下一个迭代器,时间复杂度为n。 1 #include<algorithm> 2 #include<iostream> 3 using na 阅读全文
posted @ 2021-02-09 11:03 greenofyu 阅读(65) 评论(0) 推荐(0)

2021年2月8日

摘要: https://www.acwing.com/problem/content/481/ 给定从1~n编号的n个节点和他们各自的权值,构造出一颗中序遍历为1~n的得分最大的二叉树,输出其得分和前序遍历。 得分规则具体如下:如果根节点既有左子树又有右子树,那么得分=左子树*右子树+根节点权值 如果左子树 阅读全文
posted @ 2021-02-08 23:10 greenofyu 阅读(85) 评论(0) 推荐(0)

2021年2月7日

摘要: https://www.acwing.com/problem/content/419/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int max_time=0,max_day=0; 5 for(int i= 阅读全文
posted @ 2021-02-07 22:31 greenofyu 阅读(43) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/423/ 水题。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int a[10]; 5 for(int i=0;i<10;i++){ 6 阅读全文
posted @ 2021-02-07 22:30 greenofyu 阅读(50) 评论(0) 推荐(0)

2021年2月6日

摘要: https://www.acwing.com/problem/content/430/ 考察快速幂相关知识。 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 int k,n; 5 cin>>k>>n; 6 int res 阅读全文
posted @ 2021-02-06 20:11 greenofyu 阅读(48) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/435/ 1 #include<iostream> 2 using namespace std; 3 int main(void){ 4 string s; 5 cin>>s; 6 int res=0; 7 for(int 阅读全文
posted @ 2021-02-06 20:05 greenofyu 阅读(50) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/91/ 考察快速幂的知识; 1 #include<iostream> 2 using namespace std; 3 typedef long long LL; 4 LL ksm(LL a,LL b,LL p){ 5 L 阅读全文
posted @ 2021-02-06 19:52 greenofyu 阅读(48) 评论(0) 推荐(0)
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 23 下一页