Skip to content

Commit 4e45d22

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents df5c393 + 10a9296 commit 4e45d22

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gkcs.tech

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Competitive-Programming
2+
3+
This project is contains data structures and algorithms relevant to competitive programming problems. Some of these data structures can be used with a copy/paste. Others may need tweaking or modification for custom use.
4+
5+
The package src/videos contains all code relevant to the youtube videos on https://www.youtube.com/channel/UCRPMAqdtSgd0Ipeef7iFsKw
6+
7+
Feel free to contribute, fork and discuss the code here on Github, the channel or Facebook (https://www.facebook.com/gkcs0).
8+
9+
Cheers!

_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-modernist

src/main/java/main/java/videos/GCD.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ private static int iterativeGcd(int a, int b) {
2828
}
2929

3030
private static int binaryGcd(int a, int b) {
31+
if (a < b) {
32+
int tempSwap = a;
33+
a = b;
34+
b = tempSwap;
35+
}
36+
3137
if (b == 0) {
3238
return a;
3339
}

src/main/java/main/java/videos/Tries.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static void main(String[] args) {
1414
final Trie trie = new Trie();
1515
setOfStrings.forEach(trie::insert);
1616
System.out.println(trie.query("psst"));
17+
System.out.println(trie.query("psstq"));
1718
trie.update("qqrs", "psst");
1819
System.out.println(trie.query("qqrs"));
1920
System.out.println(trie.query("psst"));
@@ -30,10 +31,11 @@ public Trie() {
3031
public int query(final String s) {
3132
TrieNode current = root;
3233
for (int i = 0; i < s.length(); i++) {
33-
if (current == null) {
34-
return 0;
35-
}
36-
current = current.next(s.charAt(i));
34+
if(current==null || current.next(s.charAt(i))==null) {
35+
return 0;
36+
}
37+
else
38+
current=current.next(s.charAt(i));
3739
}
3840
return current.terminating;
3941
}

0 commit comments

Comments
 (0)