dp
of length n + 1
with dp[i] = i
for all i
.dp
array starting from index 1 up to n - 3
.i
, consider the operations of Ctrl-A, Ctrl-C, and then Ctrl-V up to four times.dp[j]
where j = i + 3 + number_of_pastes
.dp[j]
is updated with the maximum value by comparing it with the newly calculated number of 'A's.dp
array, return dp[n]
as the answer.