【文件属性】:
文件名称:leetcode答案-Algorithm:算法
文件大小:33KB
文件格式:ZIP
更新时间:2021-06-30 01:16:43
系统开源
leetcode
答案力码
每周回顾:
1.快速排序/合并排序
912
-
2.
总和为
K
的子数组的数量
560
-
3.
LIS
300
-
4.
Kadane
53
-
5.
子数组最大和不大于k
sorted_presum
=
[
0
]
#
add
0
to
handle
empty
list
case
ans
=
-
sys
.
maxsize
running_sum
=
0
for
num
in
arr
:
running_sum
+=
num
target_sum
=
running_sum
-
k
index
=
bisect_left
(
sorted_presum
,
target_sum
)
if
index
<
len
(
sorted_presum
):
#
if
index
==
len(sorted_presum)
it
means
all
the
previous
presum
is
smaller
than
the
target,
so
no
valid
subarray
whose
sum
is
no
greater
than
k
ans
=
m
【文件预览】:
Algorithm-master
----Skyline and Line sweep()
--------README.md(2KB)
----Sorting()
--------README.md(2KB)
----Interval Tree()
--------README.md(100B)
----KMP()
--------README.md(628B)
----Graph()
--------README.md(3KB)
----Union Find()
--------README.md(3KB)
----BackTrack()
--------README.md(673B)
----Greedy()
--------README.md(2KB)
----Buckets()
--------README.md(613B)
----Bit manipulation()
--------README.md(828B)
----String()
--------README.md(814B)
----DP()
--------README.md(15KB)
----DFS()
--------README.md(94B)
----TreeSet()
--------README.md(144B)
----Math()
--------README.md(1KB)
----Trie()
--------README.md(678B)
----Heap()
--------README.md(323B)
----Other()
--------README.md(4KB)
----README.md(3KB)
----Monotonic Queue()
--------README.md(247B)
----Permutation and Combination()
--------README.md(1KB)
----Geometry()
--------README.md(1KB)
----Number Theory()
--------README.md(666B)
----Intervals()
--------README.md(1KB)
----Fenwick Tree or Binary Indexed Tree()
--------README.md(2KB)
----BFS()
--------README.md(302B)
----Range Query()
--------README.md(403B)
----Binary Search()
--------README.md(1KB)
----Sliding Window()
--------README.md(1KB)
----Transform()
--------README.md(252B)
----Linked List()
--------README.md(432B)
----Counting()
--------README.md(257B)
----Time()
--------README.md(193B)
----Binary Search Tree()
--------README.md(195B)
----Stack()
--------README.md(527B)
----Sieve of Eratosthenes()
--------README.md(111B)