From a8082e8c7efc25f1afea1b5a3b77f0336e52cce0 Mon Sep 17 00:00:00 2001 From: Farhaan Nazirkhan <96138084+nfarhaan@users.noreply.github.com> Date: Wed, 12 Oct 2022 20:04:56 +0400 Subject: [PATCH] TwoSum solution This new solution breaks the loop once the target is found. --- Leetcode-Easy/1-TwoSum/TwoSum.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Leetcode-Easy/1-TwoSum/TwoSum.java diff --git a/Leetcode-Easy/1-TwoSum/TwoSum.java b/Leetcode-Easy/1-TwoSum/TwoSum.java new file mode 100644 index 0000000..db3ad8e --- /dev/null +++ b/Leetcode-Easy/1-TwoSum/TwoSum.java @@ -0,0 +1,15 @@ +class Solution { + public int[] twoSum(int[] nums, int target) { + int[] array = new int[2]; + for (int i=0; i