This problem is straightforward. Generate all permutations of SS, check is TT is a subsequence and count how many swap occurred. If swap count is less or equal to KK then increment the answer. To generate all permutations, in C++C++ you can use std::next_permutation(). Total Complexity will be O(n!n2)O(n! * n^2).

Solution

Statistics

82% Solution Ratio
adnan_tokyEarliest, Jul '21
pathanFastest, 0.2s
ashikurrahmanLightest, 131 kB
antihashShortest, 1010B
Toph uses cookies. By continuing you agree to our Cookie Policy.