Compare commits
No commits in common. "arrays" and "master" have entirely different histories.
@ -1,27 +1,20 @@
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.math.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template code to help you parse the standard input
|
||||||
|
* according to the problem statement.
|
||||||
|
**/
|
||||||
class Solution {
|
class Solution {
|
||||||
|
|
||||||
public static void main( String[] args ) {
|
public static void main( String[] args ) {
|
||||||
|
Scanner in = new Scanner( System.in );
|
||||||
// read values with in.next...() methods
|
// read values with in.next...() methods
|
||||||
var prices = new Scanner( System.in ).tokens()
|
|
||||||
.mapToInt( Integer::valueOf )
|
|
||||||
.toArray();
|
|
||||||
|
|
||||||
// code your solution here
|
// code your solution here
|
||||||
int maxProfit = 0;
|
|
||||||
for ( int index = 0; index < prices.length; index++ ) {
|
|
||||||
var currentPrice = prices[index];
|
|
||||||
|
|
||||||
for ( int rem = index + 1; rem < prices.length; rem++ ) {
|
|
||||||
var futurePrice = prices[rem];
|
|
||||||
var profit = futurePrice - currentPrice;
|
|
||||||
maxProfit = Math.max( profit, maxProfit );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write result with System.out.println()
|
// Write result with System.out.println()
|
||||||
System.out.println( maxProfit );
|
System.out.println( "value" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user