Herr Deng桑的教學blog
這是Herr Deng桑的教學blog,主要處理作業與班導事務,另外還有數位小品。
網頁
(移至...)
首頁
密碼學
程式設計Programming
APP
計算機概論
▼
2024年3月16日 星期六
Python dict C++陣列Prefix Sum解Leetcode 525 Contiguous Array
Python dict C++陣列Prefix Sum解Leetcode 525 Contiguous Array
使用 Prefix sum 來計算 n0 中的 0 和 n1 中的 1。 使用容器記錄n1-n0的索引。
hash表 (C++ unordered_map, Python dict) 用於此任務。
第二種方法是從第一種方法修改而來的陣列版本,速度很快。python這有提供。
‹
›
首頁
查看網路版