Conversation

MahaleHarsh

I have removed the Math.max calculation and directly added profit only on days when the stock price increased simplifying the logic and improving readability.
This greedy approach accumulates profit efficiently by capturing only the upward price trends.

applied the reduce method to iteratively compute the LCM across all numbers in the array, combining each pair of results. Additionally, I used the Euclidean algorithm for GCD calculation, which optimizes the LCM computation by reducing the multiplication size
 removed the Math.max calculation and directly added profit only on days when the stock price increased, simplifying the logic and improving readability. This greedy approach accumulates profit efficiently by capturing only the upward price trends.
@Capobviouscmd

Is there any tutorial for java?

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.