American Airlines Interview Question

Anagram and problem similar to max sum