Skip to content

Latest commit

 

History

History

stock-exchange

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

STOCK EXCHANGE LOSSES

The "Stock Exchange Losses" puzzle on Codingame is a problem that involves finding the maximum loss in a series of stock prices. The goal is to determine the largest decrease (loss) between any two prices in a given list.

The problem provides you with the following information:

  • Input: The input consists of two lines. The first line contains an integer, N, representing the number of stock prices. The second line contains N space-separated integers, representing the stock prices in chronological order.

  • Output: You need to output a single integer, which represents the maximum loss among all possible pairs of stock prices.

To solve this puzzle, you need to analyze the given list of stock prices and identify the largest decrease between any two prices. This can be done by iterating over the list and comparing each price with the maximum price seen so far. If a lower price is encountered, you update the maximum loss if it is greater than the current maximum loss.

The solution strategy I described in the previous response provides a general approach to solving this problem. By following that strategy, you can calculate the maximum loss and obtain the correct output for the puzzle.