You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md
+53-30
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,11 @@ Since all subarrays are distinct, the total number of subarrays satisfying all t
79
79
80
80
<!-- solution:start -->
81
81
82
-
### Solution 1
82
+
### Solution 1: Enumeration + String Hashing
83
+
84
+
We can enumerate the left endpoint $i$ of the subarray, and then enumerate the right endpoint $j$ in the range $[i, n)$. During the enumeration of the right endpoint, we use double hashing to store the hash value of the subarray into a set. Finally, we return the size of the set.
85
+
86
+
The time complexity is $O(n^2)$, and the space complexity is $O(n^2)$. Here, $n$ is the length of the array.
83
87
84
88
<!-- tabs:start -->
85
89
@@ -88,15 +92,19 @@ Since all subarrays are distinct, the total number of subarrays satisfying all t
0 commit comments