Suppose we have a number n; we have to find the maximum number of characters we can enter using n operations where each operation is like
Inserting the character "x".
Copy all characters.
So, if the input is like n = 12, then the output will be 81.
To solve this, we will follow these steps
if n <= 4, then
v := 6, x := 3, i := 5, j := 0
while i is not same as n, do
v := v + x
i := i + 1, j := j + 1
if j is divisible by 3, then
x := integer of (x * 1.5)
otherwise when j is not divisible by 3, then
x := x * 2
Let us see the following implementation to get better understanding
class Solution: def solve(self, n): if n <= 4: return n v = 6 x = 3 i = 5 j = 0 while i != n: v += x i += 1 j += 1 if j % 3 == 0: x = int(x * 1.5) elif j % 3 == 1: pass else: x *= 2 return v ob = Solution() n = 12 print(ob.solve(n))