From 3ede08f6df156c22e898306231b83b153de02ea8 Mon Sep 17 00:00:00 2001 From: Abeel Ashraf Date: Mon, 17 Mar 2025 22:09:14 +0530 Subject: [PATCH 1/3] Added solution for Challenge-1(Two Sum) --- TwoSum/two_sum.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 TwoSum/two_sum.java diff --git a/TwoSum/two_sum.java b/TwoSum/two_sum.java new file mode 100644 index 0000000..b12ad40 --- /dev/null +++ b/TwoSum/two_sum.java @@ -0,0 +1,18 @@ +class Solution { + public int[] twoSum(int[] nums, int target) { + HashMap hashMap=new HashMap(); + int []index=new int[2]; + for(int i=0;i Date: Wed, 19 Mar 2025 11:25:35 +0530 Subject: [PATCH 2/3] Added solution for Challenge 2- Best Stock sell --- BuyStockSell/Solution.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 BuyStockSell/Solution.java diff --git a/BuyStockSell/Solution.java b/BuyStockSell/Solution.java new file mode 100644 index 0000000..b64cb5e --- /dev/null +++ b/BuyStockSell/Solution.java @@ -0,0 +1,12 @@ +class Solution { + public int maxProfit(int[] prices) { + int maxi=0; + int mini=prices[0]; + for(int i=1;i Date: Sun, 6 Apr 2025 10:34:44 +0530 Subject: [PATCH 3/3] Added solution for Conatins Duplicate --- ContainsDuplicate/Solution.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 ContainsDuplicate/Solution.java diff --git a/ContainsDuplicate/Solution.java b/ContainsDuplicate/Solution.java new file mode 100644 index 0000000..502a23b --- /dev/null +++ b/ContainsDuplicate/Solution.java @@ -0,0 +1,13 @@ +class Solution { + public boolean containsDuplicate(int[] nums) { + Set res=new HashSet<>(); + for(int i:nums){ + if(res.contains(i)){ + return true; + } + res.add(i); + } + return false; + + } +} \ No newline at end of file