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 res=new HashSet<>(); + for(int i:nums){ + if(res.contains(i)){ + return true; + } + res.add(i); + } + return false; + + } +} \ No newline at end of file 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