As reported: JPMorgan Chase SWE 3 cohort hiring online assessment (Oct 2025), question 1: the minimum number of operations to make the second half of a string an anagram of the first half, where one operation changes one character into another.
Given a string s, split it into two halves of equal length: s[0 .. n/2 − 1] and s[n/2 .. n − 1]. In one operation you may change any character of the second half into any other letter. Return the minimum number of operations needed to make the second half an anagram of the first half (the same letters with the same counts, in any order). If s has odd length, return -1.
Example 1
s = "aaabbb" -> 3 change all of "bbb" to "aaa"
Example 2
s = "ab" -> 1 change "b" to "a"
Example 3
s = "abc" -> -1 odd length cannot be split
Constraints: 1 ≤ s.length ≤ 10^5; s consists of lowercase English letters.
Code runner format: one line holding s as a JSON string. Implement minChangesToAnagram(s); the harness prints the number of operations.