give character array task represent task CPU need letter represent different task Tasks order each task unit time for unit time CPU complete task idleHowever nonnegative integer n represent cooldown period task letter array n unit time tasksreturn number unit time CPU finish give task Example 1input task AAABBB n 2output 8explanation A B idle A b idle a BThere 2 unit time tasksexample 2input task AAABBB n 0output 6explanation on case permutation size 6 work n 0aaabbbabababbbbaaaand onexample 3input task AAAAAABCDEFG n 2output 16Explanation one possible solution isA b C a d e a F G a idle idle a idle idle A Constraints1 tasklength 104tasksi uppercase English letterThe integer n range 0 100