--- tags: AC LeetCode 刷題讀書會 - 2023 --- # 2023/06/25(日) 每週 LeetCode 刷題 ## 刷題題號 - [121. Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/) ## 解題思路 You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. <pre style='background-color:#ggg'> 給予一個價格陣列,且為每一天對應的股票價格。 你希望透過選擇一天購買股票,同時在未來的一天出售該股票,以便獲得最大的利潤。 回傳在此交易中的最大利潤,如無法獲得任何利潤,則回傳0。 </pre> ## 回報格式 - 請 Fork 此 Replit 連結(https://replit.com/@AllenLi23/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock)後,進行程式碼解題,並於完成後更新到 Replit 中,再將連結貼至「解題分享區」來與大家交流做法。 解題分享區 --- 讀書會議流程: ex. 21:05開始 #簽到表: https://docs.google.com/spreadsheets/d/1gc16rrF-yZNs845z_nYrdgDIiSECOJok30dNLyQm69A/edit#gid=534323210 1. 題目說明。 2. 題目解析(BigO(n))。 4. 成員分享解題思路。 5. 問題與討論。 <!-- No.0 (請依序排序下去) name: name (回報範例) lighthouse: lighthouse Replit:https://replit.com/@AllenLi23/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock-Allen --> <!-- No.1 name: Kai lighthouse: pythonforeye@gmail.com Replit: https://replit.com/@Beginneraboutli/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock#index.js --> <!-- No.2 name: Jack Hung lighthouse: lhhungx@gmail.com Replit:https://replit.com/@LungHsuanHung/AC-LeetCode-Go-121-Best-Time-to-Buy-and-Sell-Stock#main.go --> <!-- No.3 name: vanessa lighthouse: mali7591@hotmail.com Replit:https://replit.com/@vanessalin3/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock#index.js --> <!-- No.4 name: bun lighthouse: bun.coding@hotmail.com Replit:https://replit.com/@Shu-YinChen/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock#index.js --> <!-- No.5 name: hengry lighthouse: henrychen.chc@gmail.com Replit:https://replit.com/@Chi-HengChen/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock#index.js --> <!-- No.6 name: Jerry lighthouse: jerry12011013@gmail.com Replit:https://replit.com/@Jerry-Chang975/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock#index.js --> <!-- No.7 name: Winnie lighthouse: yaysa903@gmail.com Replit:https://replit.com/@WinnieLin7/AC-LeetCode-Js-121-Best-Time-to-Buy-and-Sell-Stock#index.js -->