diff --git a/Submission/Ishan Srivastava/Best Time To Buy and Sell Stock/Screenshot.png b/Submission/Ishan Srivastava/Best Time To Buy and Sell Stock/Screenshot.png new file mode 100644 index 0000000..0749155 Binary files /dev/null and b/Submission/Ishan Srivastava/Best Time To Buy and Sell Stock/Screenshot.png differ diff --git a/Submission/Ishan Srivastava/Best Time To Buy and Sell Stock/Solution.java b/Submission/Ishan Srivastava/Best Time To Buy and Sell Stock/Solution.java new file mode 100644 index 0000000..c9364dc --- /dev/null +++ b/Submission/Ishan Srivastava/Best Time To Buy and Sell Stock/Solution.java @@ -0,0 +1,13 @@ +class Solution { + public int maxProfit(int[] prices) { + int maxProfit = 0; + int bestBuy = prices[0]; + for(int i=1;ibestBuy) + maxProfit = Math.max(maxProfit,prices[i]-bestBuy); + bestBuy = Math.min(bestBuy,prices[i]); + } + return maxProfit; + } +} \ No newline at end of file diff --git a/Submission/Ishan Srivastava/Plus One/Screenshot.png b/Submission/Ishan Srivastava/Plus One/Screenshot.png new file mode 100644 index 0000000..a084db5 Binary files /dev/null and b/Submission/Ishan Srivastava/Plus One/Screenshot.png differ diff --git a/Submission/Ishan Srivastava/Plus One/Solution.java b/Submission/Ishan Srivastava/Plus One/Solution.java new file mode 100644 index 0000000..6c8579f --- /dev/null +++ b/Submission/Ishan Srivastava/Plus One/Solution.java @@ -0,0 +1,30 @@ +class Solution { + public int[] plusOne(int[] digits) { + int carry = 0; + int res[] = new int[digits.length]; + digits[digits.length-1] = digits[digits.length-1]+1; + for(int i=digits.length-1;i>-1;i--) + { + int val = digits[i]+carry; + if(val>9) + { + val = val%10; + carry = 1; + } + else + carry = 0; + res[i] = val; + } + if(carry!=0) + { + int res1[] = new int[res.length+1]; + for(int i=res.length-1;i>-1;i--) + { + res1[i] = res[i]; + } + res1[0] = carry; + return res1; + } + return res; + } +} \ No newline at end of file