Tuple Checking

Input is denoted by a string A

  • Your task is to find the number of tuples of 4 distinct indices modulo 109 + 7 (i,j,k,l) such that (Ai,Aj,Ak,Al) = (A,W,A,B)

Example Case

Input: A = "AWABAB" Output: 12

Case 1-2

Input: The input is too long! Access both case inputs here.

Submit Here