This file contains 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
""" | |
Hackerrank solution. | |
Print linked list in reverse. | |
""" | |
def ReversePrint(head): | |
print_list = [] | |
This file contains 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
""" | |
Hackerrank solution. | |
Delete a node given a position. | |
""" | |
# 0 1 2 3 4 | |
# 0 1 3 4 | |
# 1 2 3 4 |
This file contains 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
""" | |
Hackerrank solution. | |
Insert a node at a specific position in a linked list. | |
""" | |
def InsertNth(head, data, position): | |
new_node = Node(data) | |
count = 0 |
This file contains 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
""" | |
Hackerrank 2D Array solution. | |
Improvement: instead of start, find center | |
x x x | |
x | |
x x x | |
""" | |
This file contains 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
""" | |
Hackerrank: read from STDIN | |
raw_input: read a line from STDIN and returns a string | |
number per line: | |
n = int(raw_input()) | |
space-seperated numbers in line: | |
arr = map(int, raw_input().split()) |
This file contains 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
""" | |
Hackerrank Solution for Sherlock & Squares | |
Print number of square integers between two numbers. | |
""" | |
import math | |
if __name__ == '__main__': | |
test_count = input() |