iT邦幫忙

2025 iThome 鐵人賽

0
Software Development

轉職仔之Data Science and ai master後的持續精進技術之路系列 第 32

I have memorized it 875 進度依然過慢 & 煩惱的小書 還有為何依然是31篇

  • 分享至 

  • xImage
  •  

https://ithelp.ithome.com.tw/upload/images/20251024/20177944UxndVajqUF.jpg

https://ithelp.ithome.com.tw/upload/images/20251024/20177944tNpaCWKMW7.jpg

https://ithelp.ithome.com.tw/upload/images/20251024/201779446NRoFnRx9u.jpg

https://ithelp.ithome.com.tw/upload/images/20251024/20177944yUeYAjov0v.jpg

https://ithelp.ithome.com.tw/upload/images/20251024/20177944JW6XiXPWfT.jpg

class Solution { // 875 O(n log m) O(1)
public:
    int minEatingSpeed(vector<int>& p, int g) {
        int l = 1, r = *max_element(p.begin(), p.end());
        while (l < r) {
            int k = l + (r - l) / 2;
            long long m = 0;
            for (int x : p) {
                m += (x + k - 1) / k;
                if (m > g) break;
            }
            if (m <= g) r = k;
            else l = k + 1;
        }
        return l;
    }
};

上一篇
I have memorized it 162 進度實在過慢 & 有人鐵人賽中毒的嗎 希望繼續更至198 and 2118
系列文
轉職仔之Data Science and ai master後的持續精進技術之路32
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言