diff --git a/Code/Java/Buy and sell stocks-one transaction allowed.java b/Code/Java/Buy and sell stocks-one transaction allowed.java new file mode 100644 index 000000000..e30bdc9cf --- /dev/null +++ b/Code/Java/Buy and sell stocks-one transaction allowed.java @@ -0,0 +1,60 @@ +import java.io.*; +import java.util.*; + +public class Main { + + public static void main(String[] args) throws Exception { + // write your code here + Scanner scn = new Scanner(System.in); // Taking inputs + int n = scn.nextInt(); + int[] prices = new int[n]; + for(int i=0;i overallProfit){ + overallProfit = profitIfSoldToday; + } + } + System.out.println(overallProfit); + } + +} +/* CONSTRAINTS */ +/* +0 <= n <= 20 +0 <= n1, n2, .. <= 10 +*/ + +/* SAMPLE INPUT */ + +/* +9 +11 +6 +7 +19 +4 +1 +6 +18 +4 +*/ + +/* SAMPLE OUTPUT*/ + +/* +17 +*/