Skip to content

Instantly share code, notes, and snippets.

@hkasera
Last active June 1, 2020 23:37
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 hkasera/14cce3e3aeb44b1331b5b682f7916c64 to your computer and use it in GitHub Desktop.
Save hkasera/14cce3e3aeb44b1331b5b682f7916c64 to your computer and use it in GitHub Desktop.
Two Sum problem variations
private boolean sumsToTarget(int[] arr, int k) {
for (int i = 0; i < arr.length; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] + arr[j] == k) {
return true;
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment