Skip to content

Instantly share code, notes, and snippets.

View neonbadger's full-sized avatar

Shijie F neonbadger

View GitHub Profile
"""
Hackerrank solution.
Print linked list in reverse.
"""
def ReversePrint(head):
print_list = []
"""
Hackerrank solution.
Delete a node given a position.
"""
# 0 1 2 3 4
# 0 1 3 4
# 1 2 3 4
"""
Hackerrank solution.
Insert a node at a specific position in a linked list.
"""
def InsertNth(head, data, position):
new_node = Node(data)
count = 0
"""
Hackerrank 2D Array solution.
Improvement: instead of start, find center
x x x
x
x x x
"""
@neonbadger
neonbadger / stdin.py
Last active July 15, 2018 15:45
Hackerrank stdin & stdout for python
"""
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())
@neonbadger
neonbadger / sherlock_and_squares.py
Created March 19, 2016 23:25
Hackerrank Solutions
"""
Hackerrank Solution for Sherlock & Squares
Print number of square integers between two numbers.
"""
import math
if __name__ == '__main__':
test_count = input()