Use array of answers instead of O(n^2) loop

Change-Id: I0613914d34b83dee15a6063c407af1e64ed7d3a8
Merge "Use array of answers instead of O(n^2) loop"