Skip to content

Instantly share code, notes, and snippets.

@ClassCubeGists
Last active May 18, 2018 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClassCubeGists/c08fd685d9a5da18ab4a6631eb765cbc to your computer and use it in GitHub Desktop.
Save ClassCubeGists/c08fd685d9a5da18ab4a6631eb765cbc to your computer and use it in GitHub Desktop.
WordPairList Solution - AP 2018 FRQ - https://clsc.be/26
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]);
}
public int numMatches() {
int cnt = 0;
for (WordPair wp: allPairs)
if (wp.getFirst().equals(wp.getSecond())
cnt++;
return cnt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment