自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(7)
  • 收藏
  • 关注

原创 [2044. 统计按位或能得到最大值的子集数目]

(力扣)前提:这个数组的子集进行或运算能得到最大的数肯定是全部数一起或,秉承或运算不要白不要的原则。第一种方法:二进制枚举这种方法其实我觉得是为了引出下面两种更方便的方法提出的用二进制位来存储各个数是否加入或运算假如nums数组是n个数字,那么我们只需要遍历1<<16种情况每一种情况中,我们根据位数上的数是否是1来确定是否要加入或运算public int countMaxOrSubsets1(int[] nums) { int kind=1<&lt..

2022-03-16 00:07:24 122

原创 字符串hash

字符串hash[问题]:为什么使用131,或者131313hash[i]=hash[i-1]*131+'a';理解就是hash[i-1]的小变化对于131313得到的结果有更大的改变所以当出现错误的时候,就可以通过改变质数的方法来减小hash冲突[问题]:为什么要用long来存hash首先 如果是int当只要大于int就会溢出,几倍溢出就有可能发生hash冲突,所以可以使用long来减少hash冲突[推理]对于字符串s1s2s3s4s5对于s3s4hash[s3s

2021-12-23 22:19:34 327

原创 319. Bulb Switcher 灯泡开关 开还是关?

There are n bulbs that are initially off. You first turn on all the bulbs, thenyou turn off every second bulb.On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the ith round, you toggle every i bulb..

2021-11-15 15:31:24 408

原创 LeeCode 24 Swap Nodes in Pairs

Given alinked list, swap every two adjacent nodes and return its head. You must solve the problem withoutmodifying the values in the list's nodes (i.e., only nodes themselves may be changed.)来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/swap-node..

2021-11-01 10:21:39 74

原创 50.Pow(x,n)幂的快速求法

50.Pow(x,n)幂的快速求法递归Pow(x,n)实现 pow(x, n) ,即计算 x 的 n 次幂函数(即,xn)。class Solution {public: double myPow(double x, long long n ) { if(n>=0) return mi(x,n); else return 1.0/mi(x,-n); } double mi(double x

2021-05-09 15:31:13 100

原创 LeetCode1486.数组异或操作

LeetCode1486.数组异或操作题目链接给你两个整数,n 和 start 。数组 nums 定义为:nums[i] = start + 2*i(下标从 0 开始)且 n == nums.length 。请返回 nums 中所有元素按位异或(XOR)后得到的结果。模拟class Solution {public: int xorOperation(int n, int start) { int ans=0; for(int i=0;i<n;i

2021-05-07 21:57:43 98

原创 unordered_set:::2021-05-05

unordered_set的简单用法一.定义unordered_set<int> set;unordered_set<int> set2;set2=set1;二.容量操作set.empty();set.size();set.max_size();set.reserve(1000);//改变容器容量三.迭代器操作unordered_set<int>::iterator //头迭代器ite_begin=set.begin();//尾迭代器it

2021-05-05 15:18:35 63

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除