3248.矩阵中的蛇
int finalPositionOfSnake(int n, char** commands, int commandsSize) {
int x=0;
for(int i=0;i<commandsSize;i++){
if(commands[i][0]=='U'){
x-=n;
}
if(commands[i][0]=='D'){
x+=n;
}
if(commands[i][0]=='L'){
x--;
}
if(commands[i][0]=='R'){
x++;
}
}
return x;
}
2859.计算K置位下标对应元素的和
int sumIndicesWithKSetBits(int* nums, int numsSize, int k){
int x=0;
for(int i=0;i<numsSize;i++){
int t=0;
int y=i;
while(y!=0){
if(y%2==1){
t++;
}
y/=2;
}
if(t==k){
x+=nums[i];
}
}
return x;
}