Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf89242

Browse files
2 parents d8a31d3 + 0a8717d commit cf89242

File tree

14 files changed

+554
-88
lines changed

14 files changed

+554
-88
lines changed

‎PreffixSumSlidingWindow/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎PreffixSumSlidingWindow/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎PreffixSumSlidingWindow/.idea/workspace.xml

Lines changed: 293 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>
1.1 KB
Binary file not shown.

‎PreffixSumSlidingWindow/raw/links

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
sliding window algorithm
2+
http://www.geeksforgeeks.org/window-sliding-technique/
3+
http://www.geeksforgeeks.org/sliding-window-maximum-maximum-of-all-subarrays-of-size-k/
4+
https://www.nayuki.io/page/sliding-window-minimum-maximum-algorithm
5+
https://algorithmsandme.in/2014/03/15/heaps-sliding-window-algorithm/
6+
7+
8+
Problems
9+
https://www.hackerrank.com/contests/101hack51/challenges/charging-the-batteries/
10+
11+
prefix sums/sliding window
12+
https://discuss.leetcode.com/topic/87710/javascript-o-n-using-flexible-sliding-window-and-prefix-sums
13+
https://cs.stackexchange.com/questions/39529/efficient-way-to-calculate-sum-in-sliding-window
14+
https://cs.stackexchange.com/questions/64305/sliding-window-sum-greater-than-n-using-as-few-numbers-as-possible
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package problems;
2+
3+
public class SumOfSubset {
4+
5+
6+
public static int maxSumOfSubsetK(int [] set, int k) {
7+
int limit = set.length;
8+
if(k < limit)
9+
return -1;
10+
int acc = 0;
11+
for (int i=0; i<k ; i++) {
12+
acc += set[i];
13+
}
14+
int partial = acc;
15+
for (int i = k; i < limit ; i++) {
16+
partial = partial + set[i] - set[i-k];
17+
acc = Math.max(acc, partial);
18+
19+
}
20+
return acc;
21+
}
22+
23+
public static void test1() {
24+
int [][] set = {
25+
{5 , 2 , -1 , 0 , 3}
26+
,{100, 200, 300,400}
27+
,{1, 4, 2, 10, 23, 3, 1, 0, 20}
28+
,{4, 2, 10, 23}
29+
};
30+
System.out.println(maxSumOfSubsetK(set[2], 4));
31+
}
32+
33+
34+
35+
36+
public static void main(String[] args) {
37+
test1();
38+
}
39+
40+
}

‎UnionFind/.idea/workspace.xml

Lines changed: 78 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.
-1.1 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /