Files
leetcode/greed/lcs01.h
2025-09-15 21:12:04 +08:00

17 lines
256 B
C++

int leastMinutes(int n){
int i = 1;
int j = 1;
while(j < n){
j <<= 1;
i++;
}
return i;
}
#include <cmath>
int leastMinutes(int n) {
if (n <= 0) return 0;
return static_cast<int>(std::ceil(std::log2(n))) + 1;
}