This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go’s syntax is very much like C, you should be fine | |
// reading it. | |
// Defining Human type, it has a variable Name of type string. | |
// (Yes, type is mentioned after variable name) | |
type Human struct { | |
Name string | |
} | |
// Defining a method GetName on the type Human which |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the example is in Java | |
class Base { | |
private int i = 0; | |
void inc1() { | |
inc2(); // the change | |
} | |
void inc2() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the example is in Java | |
class Base { | |
private int i = 0; | |
void inc1() { | |
i++; | |
} | |
void inc2() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
W = "acabacacd" | |
T = "acfacabacabacacdk" | |
# this method is from above code snippet. | |
aux = creatAux(W) | |
# counter for word W | |
i = 0 | |
# counter for text T | |
j = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def createAux(W): | |
# initializing the array aux with 0's | |
aux = [0] * len(W) | |
# for index 0, it will always be 0 | |
# so starting from index 1 | |
i = 1 | |
# m can also be viewed as index of first mismatch | |
m = 0 | |
while i < len(W): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here is the working code of the naive approach. | |
def bruteSearch(W, T): | |
# edge case check | |
if W == "": | |
return -1 | |
# getting the length of the strings | |
wordLen = len(W) | |
textLen = len(T) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DoubleList(object): | |
head = None | |
tail = None | |
size = 0 | |
def append(self, data): | |
new_node = Node(data) | |
if self.head is None: | |
self.head = self.tail = new_node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DoubleList(object): | |
head = None | |
tail = None | |
size = 0 | |
def append(self, data): | |
new_node = Node(data) | |
if self.head is None: | |
self.head = self.tail = new_node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import random, math | |
outputdebug = False | |
def debug(msg): | |
if outputdebug: | |
print msg | |
class Node(): | |
def __init__(self, key): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Built application files | |
*.apk | |
*.ap_ | |
*.aab | |
# Files for the ART/Dalvik VM | |
*.dex | |
# Java class files | |
*.class |