You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k.
Find the maximum profit you can achieve. You may complete at most k transactions.
Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).
Example 1:
Input: k = 2, prices = [2,4,1]
Output: 2
Explanation: Buy on day 1 (price = 2) and sell on day 2 (price = 4), profit = 4-2 = 2.
Get notified about all off campus jobs/interviews and the process.
We are building our website and it will be back soon with lots of content till then subscribe us on youTube.
https://t.me/tech_geek1
My LinkedIn page: / techgeek1
Interview Preparation Sheet: • INTERVIEW PREPARATION SHEET - HASHEDI...
Link for Leetcode solutions: • Placements 2022
Link for placement series:
Placement 2022: • Placements 2022
Placement 2023: • Placements 2023
#leetcode #leetcodesolution
コメント