Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPair solution for the 2018 AP Computer Science Exam -
public int numMatches() {
int cnt = 0;
for (WordPair wp: allPairs)
if (wp.getFirst().equals(wp.getSecond())
return cnt;
public WordPairList(String[] words) {
allPairs = new ArrayList<>();
for (int i=0; i<words.length; i++)
for (x=i+1; x<words.length; x++)
allPairs.add(new WordPair(words[i], words[x]);
Copy link

kidsfreej commented Apr 14, 2020

Error in the code. "i<words.length-1" is the answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment