Datasets:

ArXiv:
License:
File size: 406 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.*;
public class stock
{
    public static void main(String args[])
    {
        int arr[]={3,9,5,8,1,7,4,10},i,min=arr[0],profit=0;
        for(i=1;i<arr.length;i++)
        {
            if(min>arr[i])
                min=arr[i];      //minimum value till that day
            if(profit<(arr[i]-min))
                profit=arr[i]-min;
        }
        System.out.print(profit);
    }
}