Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 511 Bytes

multiple_length.md

File metadata and controls

17 lines (15 loc) · 511 Bytes

Multiple Length

  • one way was to get the product and then check the size of bits.
  • but this would ended up in TLE.
  • since we only need size of bit in the end.
  • therefore taken log with base 2.
int multipleLength(vector<int> &arr, int n) {
   double ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (double)log2(arr[i]);
    }
    int result = (int)(ans) + 1;
    return result;
}