I solved the problem for leetcode Here is my solution:
public class Solution {
public int NumberOfSteps(int num) {
int steps = 0;
while(num>0)
{
if(num % 2 == 0) num/=2;
else num--;
steps++;
}
return steps;
}
}
The analysis produces the following statistics: Runtime: 46 ms Memory Usage: 25.1 MB
Here is the solution from Discuss And his stats: Runtime: 24 ms Memory Usage: 25.1 MB
Explain, please, what is the difference?