Add subarray sum equals K flashcards (LC 560, 974, 325)
This commit is contained in:
@@ -81,3 +81,19 @@ public:
|
||||
}
|
||||
};
|
||||
#+end_src
|
||||
|
||||
|
||||
* TODO study: why min doesn't work with Fenwick tree (no inverse, update breaks on increase)
|
||||
|
||||
* Binary search
|
||||
#+begin_src python
|
||||
def bs(a, x, l, r):
|
||||
if l >= r:
|
||||
return l
|
||||
|
||||
m = l + (r-l) // 2
|
||||
if (a[m] < x):
|
||||
return bs(a, x, m+1, r);
|
||||
else:
|
||||
return bs(a, x, l, m)
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user