Skip to content

Commit b678d62

Browse files
committed
Done with dailies
1 parent bad8662 commit b678d62

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

.vscode/tasks.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: g++ build active file",
6+
"command": "/usr/bin/g++",
7+
"args": [
8+
"-fdiagnostics-color=always",
9+
"-g",
10+
"${file}",
11+
"-o",
12+
"${fileDirname}/${fileBasenameNoExtension}"
13+
],
14+
"options": {
15+
"cwd": "${fileDirname}"
16+
},
17+
"problemMatcher": [
18+
"$gcc"
19+
],
20+
"group": {
21+
"kind": "build",
22+
"isDefault": true
23+
},
24+
"detail": "Task generated by Debugger."
25+
}
26+
],
27+
"version": "2.0.0"
28+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class Solution {
2+
public:
3+
int minFlips(int a, int b, int c)
4+
{
5+
int count = 0;
6+
int z = (a|b)^c;
7+
if(z==0)
8+
{
9+
return count;
10+
}
11+
count+=1; //initial one add
12+
13+
//Normal Count
14+
while(z&=z-1)
15+
{
16+
count+=1;
17+
}
18+
19+
//Jaha jaha 1 common waha ek aur extra add to yeh check karne ke liye ki kitte extra add karne hai
20+
z = a&b&((a|b)^c); //common 1(in a and b) that are changing waha ek extra add
21+
if(z==0)
22+
{
23+
return count;
24+
}
25+
else
26+
{
27+
count+=1; //initial one add of and
28+
while(z&=z-1)
29+
{
30+
count+=1;
31+
}
32+
}
33+
return count;
34+
35+
}
36+
};

0 commit comments

Comments
 (0)