0%
從 0 到 1:Discord Bot 開發之旅
更新於
分類於
程式專案
PHP 的堆結構:SplMaxHeap vs SplMinHeap 使用指南
更新於
分類於
技術筆記
在資料處理上常常會需要取得資料的最大值,但每次都用陣列一次一次找難免費時費力,
在 Leetcode 解題過程中發現 PHP 有對應程式庫能解決此問題,
便想藉這次機會整理相關使用方式順便釐清一遍自己的思路。
PHP 陣列操作的 10 個實用技巧
更新於
分類於
技術筆記
1146. Snapshot Array PHP解題
更新於
分類於
解題紀錄
題目說明
Implement a SnapshotArray that supports the following interface:
- SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0.
- void set(index, val) sets the element at the given index to be equal to val.
- int snap() takes a snapshot of the array and returns the snap_id: the total number of times we called snap() minus 1.
- int get(index, snap_id) returns the value at the given index, at the time we took the snapshot with the given snap_id