diff --git a/.idea/misc.xml b/.idea/misc.xml
index fdc35ea..512b2e9 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,5 @@
-
-
-
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/com/dota/binarySearch/_1146/SnapshotArray.java b/src/main/java/com/dota/binarySearch/_1146/SnapshotArray.java
new file mode 100644
index 0000000..e4e6ee6
--- /dev/null
+++ b/src/main/java/com/dota/binarySearch/_1146/SnapshotArray.java
@@ -0,0 +1,29 @@
+package com.dota.binarySearch._1146;
+
+import java.util.TreeMap;
+
+class SnapshotArray {
+ int cnt = 0;
+ TreeMap[] arr ;
+ int n;
+ public SnapshotArray(int length) {
+ arr = new TreeMap[length];
+ n = length;
+ for (int i = 0; i < n; i++) {
+ arr[i] = new TreeMap<>();
+ arr[i].put(0, 0);
+ }
+ }
+
+ public void set(int index, int val) {
+ arr[index].put(cnt, val);
+ }
+
+ public int snap() {
+ return cnt++;
+ }
+
+ public int get(int index, int snap_id) {
+ return arr[index].floorEntry(snap_id).getValue();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/dota/binarySearch/_981/TimeMap.java b/src/main/java/com/dota/binarySearch/_981/TimeMap.java
new file mode 100644
index 0000000..be3a338
--- /dev/null
+++ b/src/main/java/com/dota/binarySearch/_981/TimeMap.java
@@ -0,0 +1,43 @@
+package com.dota.binarySearch._981;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+class TimeMap {
+ Map> vmap;
+ Map> imap;
+ public TimeMap() {
+ vmap = new HashMap<>();
+ imap = new HashMap<>();
+ }
+
+ public void set(String key, String value, int timestamp) {
+ vmap.computeIfAbsent(key, k -> new ArrayList<>()).add(value);
+ imap.computeIfAbsent(key, k -> new ArrayList<>()).add(timestamp);
+ }
+
+ public String get(String key, int timestamp) {
+ var vList = vmap.get(key);
+ var iList = imap.get(key);
+ if (vList == null || iList == null) return "";
+ int l= 0, r = iList.size()-1;
+ while (l <= r) {
+ int mid = l + (r - l) / 2;
+ if (iList.get(mid)==timestamp) {
+ return vList.get(mid);
+ }
+ if (iList.get(mid)>timestamp) {
+ r = mid - 1;
+ } else {
+ l = mid + 1;
+ }
+ }
+ if (r < 0) {
+ return "";
+ }
+ return vList.get(r);
+ }
+}
+
\ No newline at end of file