look at https://velog.io/@whitehousechef/Leetcode-3405.-Count-the-Number-of-Arrays-with-K-Matching-Adjacent-Elements example and my explanation
comb formula is nCk and n!/k!x(n-k)!. The time is the minimum of k and n-k.
math.perm(n, k): O(k)
look at https://velog.io/@whitehousechef/Leetcode-3405.-Count-the-Number-of-Arrays-with-K-Matching-Adjacent-Elements example and my explanation
time is the exponent (power) so if it is like sth to power of n, then the time is n.
normally the data structure needed to store the required answer isnt counted as the main space complexity
https://velog.io/@whitehousechef/Leetcode-2411.-Smallest-Subarrays-With-Maximum-Bitwise-OR
Strings are immutable so when we append like that we are essentially making a new string by copying old content
s = new StringBuilder(s).append("world").toString();
this can be k^2 so use stringbuilder