TuSimple | OA | count of good strings

Given n, find number of strings of length n, such that string contains at least 2'a', 1'b', 1'c'

if n<=3 there's no such valid string
if n==4, we will have aabc, aacb, abac,.... there are 12 such string, so return 12
if n==5, we have aabca, aabcb,...

n<=10^5

string only contains lowercase letters a-z
Comments (1)