AP CSA FRQ Guide
2016 FRQ 2: LogMessage
Parse log messages into machine and description fields, detect a whole word in a description, and remove matching messages from a system log.
Skills Tested
What this FRQ is really practicing
Review these topics before attempting the problem.
Starter Approach
How to begin with your own plan
- 1Constructor: split at the colon and store the two parts.
- 2containsWord: find whole-word matches, not just substrings.
- 3removeMessages: remove matching messages without skipping entries, and return them in their original order.
Attempt the problem before opening the solution.
Common Mistakes
Mistakes to watch for while writing
Self Check
Review questions before you submit
Splits the message at the colon.
indexOf(":") followed by substring is a common approach.
Checks word boundaries around the keyword.
A keyword inside another word should not count.
Removes matching messages without skipping elements.
Loop backward or adjust the index after removal.
Returns the removed messages in their original order.
A backward removal traversal must insert each removed item at the front of the returned list; forward traversal may append.
Practice Links
