Re: [閒聊] 每日leetcode
※ 引述《sixB (6B)》之銘言:
: 1562.
: 看到今天是ez不想寫
: 然後發現昨天的是hard
: 阿不是啊
: hard 5行喔?
: 誰訂的 真的嗎0.0
: class Solution {
: public:
: int minNumberOperations(vector<int>& target) {
: int res = 0, last = 0;
: for(int i: target){
: res += max(0, i - last);
: last = i;
: }
: return res;
: }
: };
這題就想成爬樓梯
統計你總共上了幾層階梯
就突然變成easy了
這就是leetcode題目的神奇地方
題目敘述永遠是最難懂的
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.121.235.241 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1761934107.A.0BB.html
→
11/01 15:14,
1月前
, 1F
11/01 15:14, 1F
討論串 (同標題文章)
完整討論串 (本文為第 1542 之 1548 篇):