We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 822c709 commit 3df5f0eCopy full SHA for 3df5f0e
LeetcodeProblems/Algorithms/easy/Bit_Reverse_To_Make_Numbers_Equal.js
@@ -60,21 +60,21 @@ Count the number of 1s in the result of the XOR operation.
60
* @return {number}
61
*/
62
var minChanges = function bitChanges(n, k) {
63
- // Check if transformation is possible
64
- if ((n & k) !== k) {
65
- return -1;
66
- }
67
-
68
- // Calculate the number of changes
69
- let changes = 0;
70
- let diff = n ^ k;
71
72
- while (diff > 0) {
73
- changes += diff & 1;
74
- diff >>= 1;
75
76
77
- return changes;
78
-}
+ // Check if transformation is possible
+ if ((n & k) !== k) {
+ return -1;
+ }
+
+ // Calculate the number of changes
+ let changes = 0;
+ let diff = n ^ k;
+ while (diff > 0) {
+ changes += diff & 1;
+ diff >>= 1;
+ return changes;
+};
79
80
module.exports.minChanges = minChanges;
0 commit comments