filmov
tv
leetcode 869. reordered power of 2 - Mathematical approach with proofs

Показать описание
In this video, I'll try the solve the problem #869 reordered power of 2 from leetcode using a mathematical approach in order to be able to do a smart brute force.
Time complexity: logarithmic
Space complexity: Constant
The O(n!) naive solution is not elaborated.
0:00 Intro
0:33 Problem statement
1:00 Samples
3:24 General idea
7:50 Proof: The number of digits (x) of a number
14:07 Proof: The lowest integer (a) that contains (x) digits
15:37 Proof: The largest integer (b) that contains (x) digits
16:17 Proof: The lowest exponent (k1)
17:21 Proof: The largest exponent (k2)
17:44 Smart brute force pseudo code
18:05 Examples
25:12 Check if two integers have the same digits
30:41 C++ Code
Time complexity: logarithmic
Space complexity: Constant
The O(n!) naive solution is not elaborated.
0:00 Intro
0:33 Problem statement
1:00 Samples
3:24 General idea
7:50 Proof: The number of digits (x) of a number
14:07 Proof: The lowest integer (a) that contains (x) digits
15:37 Proof: The largest integer (b) that contains (x) digits
16:17 Proof: The lowest exponent (k1)
17:21 Proof: The largest exponent (k2)
17:44 Smart brute force pseudo code
18:05 Examples
25:12 Check if two integers have the same digits
30:41 C++ Code