牛客600608245号
牛客600608245号
全部文章
分类
归档
标签
去牛客网
登录
/
注册
牛客600608245号的博客
全部文章
(共14篇)
题解 | #二进制取反#
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num string字符串 * @return string字符串 ...
2023-09-11
0
186
题解 | #数组中只出现一次的数(其它数出现k次)#
使用map,对重复出现的值进行+1操作,然后遍历map中的值为1的键即为要返回的 #include <algorithm> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 ...
2023-09-08
0
159
题解 | #反转数字#
注意反转后的结果可能会溢出,因此需要将num的数据类型修改为long #include <climits> #include <cmath> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返...
2023-09-08
0
134
题解 | #二进制中1的个数#
利用手动计算二进制的方法查找二进制中1的个数,注意输入为 -2147483648(即INT_MIN)的情况时,如果转为int型则会导致整数溢出,所以可以使用unsigned int来表示 class Solution { public: /** * 代码中的类名、方法名、参数名已经...
2023-09-07
0
172
题解 | #压缩字符串(一)#
利用结构体和栈,将不同的字符压入栈中,如果字符相同则将结构体的sum+1,查找完成后将栈反转,同时输出栈中字符和大于一的情况。 #include <algorithm> #include <stack> #include <string> class Soluti...
2023-09-07
0
192
题解 | #数字在升序数组中出现的次数#
利用map进行查找 #include <map> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型vec...
2023-09-07
0
148
题解 | #二进制求和#
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param A string字符串 * @param B string字符串 ...
2023-09-07
0
169
题解 | #位操作练习#
#include <iostream> using namespace std; int main() { int a, b; while(scanf("%d%d",&a,&b)!=EOF){ for(int i = 0;i < 16;i++){...
2023-03-10
1
127
题解 | #今年的第几天?#
#include <iostream> #include <string> using namespace std; bool isLeap(int year) { if (year % 400 == 0 || year % 100 == 0 || year % 4 =...
2023-03-02
0
174
题解 | #查找#
#include <cstring> #include <iostream> #include <algorithm> #include <map> using namespace std; bool isExit(int arr[], int x...
2023-03-02
0
128
首页
上一页
1
2
下一页
末页