GFG160 Day 8: Today's problem: Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0. Note: Stock must be bought before being sold. #gfg160 #geekstreak2024 #DrGViswanathan #100daysofcode #VITBhopal #VITBhopalLions GeeksforGeeks
Shubham Chaudhari’s Post
More Relevant Posts
-
GFG 160 : 160 Days of Problem-Solving. Day-8 of GFG 160 Stock Buy and Sell – Max one Transaction Allowed Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0. Note: Stock must be bought before being sold. GeeksforGeeks #gfg160 #geeksstreak2024 #DrGViswanathan Challenge #VITBhopal #VITBhopalLions #VIT
To view or add a comment, sign in
-
Day-8 Problem: Stock Buy and Sell – Max one Transaction Allowed Question: Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0. GeeksforGeeks #gfg160, #geekstreak2024, #gfgkare
To view or add a comment, sign in
-
GFG160 Day 7: Today's problem: The cost of stock on each day is given in an array price[]. Each day you may decide to either buy or sell the stock at price[i], you can even buy and sell the stock on the same day. Find the maximum profit that you can get. Note: A stock can only be sold if it has been bought previously and multiple stocks cannot be held on any given day. #gfg160 #geekstreak2024 #DrGViswanathan #100daysofcode #VITBhopal #VITBhopalLions GeeksforGeeks
To view or add a comment, sign in
-
07_DAY Stock Buy and Sell – Multiple Transaction Allowed || The cost of stock on each day is given in an array price[]. Each day you may decide to either buy or sell the stock at price[i], you can even buy and sell the stock on the same day. Find the maximum profit that you can get. class Solution { public int maximumProfit(int prices[]) { int ans =0; int n = prices.length; for(int i=1; i<n; i++){ if(prices[i] > prices[i-1]){ ans += prices[i]-prices[i-1]; } } return ans; } }; #gfg160 #geeksforgeeks160 #geekstreak2024
To view or add a comment, sign in
-
Day - 08 #08 of #160daysofproblemsolving #gfg160 #geekstreak2024 #geeksforgeeks Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0. Input: prices[] = [7, 10, 1, 3, 6, 9, 2] Output: 8 Explanation: You can buy the stock on day 2 at price = 1 and sell it on day 5 at price = 9. Hence, the profit is 8. #160daysofproblemsolving #gfg160 #geekstreak2024 #geeksforgeeks
To view or add a comment, sign in
-
Day 8 Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0. Stock Buy and Sell – Max one Transaction Allowed #gfg160 #gfgstreak2024 #geeksforgeeks
To view or add a comment, sign in
-
Day 7✨ Stock Buy and Sell – Multiple Transaction Allowed☘️ The cost of stock on each day is given in an array price[]. Each day you may decide to either buy or sell the stock at price[i], you can even buy and sell the stock on the same day. Find the maximum profit that you can get. Note: A stock can only be sold if it has been bought previously and multiple stocks cannot be held on any given day. #gfg160 #geekstreak2024 GeeksforGeeks
To view or add a comment, sign in
-
🔸#Day_8 of #gfg160 Challenge by GeeksforGeeks Problem: Stock Buy and Sell – Max one Transaction Allowed Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0. Note: Stock must be bought before being sold. #gfg160 #geekforgeeks #160DaysOfDSA #geekstreak2024
To view or add a comment, sign in
-
Day 8/160 of #GFG160! Given an array prices[] of length n, representing the prices of the stocks on different days. The task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell. If it is not possible to make a profit then return 0. Note: Stock must be bought before being sold. Example: Input: prices[] = [7, 10, 1, 3, 6, 9, 2] Output: 8 Explanation: You can buy the stock on day 2 at price = 1 and sell it on day 5 at price = 9. Hence, the profit is 8. #gfg160 #geekstreak2024 #womenintech
To view or add a comment, sign in
-
#Day 26challenges of day 31. Today's problem is-> #The cost of stock on each day is given in an array price[]. Each day you may decide to either buy or sell the stock at price[i], you can even buy and sell the stock on the same day. Find the maximum profit that you can get. Note: A stock can only be sold if it has been bought previously and multiple stocks cannot be held on any given day. Examples: Input: prices[] = [100, 180, 260, 310, 40, 535, 695] Output: 865 #gfg160 #geeksstreak
To view or add a comment, sign in