File tree Expand file tree Collapse file tree 1 file changed +16
-16
lines changed
LeetcodeProblems/Algorithms/easy Expand file tree Collapse file tree 1 file changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -60,21 +60,21 @@ Count the number of 1s in the result of the XOR operation.
6060 * @return {number }
6161 */
6262var 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- }
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+ } ;
7979
8080module . exports . minChanges = minChanges ;
You can’t perform that action at this time.
0 commit comments