AP CSA FRQ Guide
2014 FRQ 1: ScrambleWord
Scramble a word by swapping selected adjacent characters and then update a list by replacing or removing words based on whether they change.
String Processing and List Mutation22 minute targetStringArrayListsubstringmutation
Skills Tested
What this FRQ is really practicing
StringArrayListsubstringmutation
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Part A: scan adjacent pairs and perform the prompt-specific swap rule.
- 2Part B: update list entries that change and remove entries that stay the same.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Swapping overlapping pairs.
Removing while moving forward without adjusting the index.
Using == to compare the original and scrambled words.
Self Check
Review questions before you submit
Scans adjacent characters.
The decision depends on character k and character k + 1.
Rebuilds the string after a swap.
Strings are immutable.
Uses set for changed words and remove for unchanged words.
The list-processing method both replaces and removes.
Avoids reusing a character immediately after a swap.
After swapping adjacent characters, advance past both positions.
Practice Links
