As reported: Epic Systems online assessment, 2026 — one of four programming questions: count the adjacent transpositions needed to turn a source string into a target string.
You are given two strings source and target of the same length that contain exactly the same characters with the same frequencies. In one transposition you swap two adjacent characters of source. Return the minimum number of transpositions needed to turn source into target.
Example 1
source = "GUM", target = "MUG"
Output: 3
GUM → GMU → MGU → MUG.
Example 2
source = "ABC", target = "ABC"
Output: 0
Example 3
source = "ABCD", target = "BACD"
Output: 1
Constraints: 1 <= source.length == target.length <= 10^5; both contain English letters; target is a rearrangement of source. The answer can exceed 2^31 - 1.
Code runner format: two JSON strings, one per line: source, then target. Implement countTranspositions(source, target) returning a 64-bit integer (long in Java, long long in C++, int64 in Go, int in Python, a number in JavaScript).