A repository containing all my completed coding challenges from coding challenge websites such as Hackerrank, LeetCode or CodeEval. I do not own the rights to the questions and am just cataloging my submissions for the purposes of revision and as an exercise in learning git.
NOTE: This is a work in progress, any challenge that is listed has been completed but may still not yet be uploaded as I am making efforts to format all questions and keep the repo tidy.
def binary_search(items, goal):
if len(items) == 0:
return False
mid = len(items) // 2
if items[mid] == goal:
return True
elif items[mid] <= goal:
return binary_search(items[mid+1:], goal)
else:
return binary_search(items[:mid], goal)
- Solve Me First
- Simple Array Sum
- Compare the Triplets
- A Very Big Sum
- Diagonal Difference
- Plus Minus
- Staircase
- Mini-Max Sum
- Birthday Cake Candles
- Time Conversion
- Grading Students
- Apple and Orange
- Kangaroo
- Between Two Sets
- Breaking the Records
- Birthday Chocolate
- Divisible Sum Pairs
- Migratory Birds
- Day of the Programmer
- Bon Appétit
- Sock Merchant
- Drawing Book
- Counting Valleys
- Electronics Shop
- Cats and a Mouse
- Forming a Magic Square
- Picking Numbers
- Climbing the Leaderboard
- The Hurdle Race
- Designer PDF Viewer
- Utopian Tree
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
def get_data(self):
return self.data
def get_next(self):
return self.next
def set_data(self, new_data):
self.data = new_data
def set_next(self, new_next):
self.next = new_next
- Print the Elements of a Linked List
- Insert a Node at the Tail of a Linked List
- Insert a node at the head of a linked list
- Insert a node at a specific position in a linked list
- Delete a Node
- Print in Reverse
- Reverse a linked list
- Compare two linked lists
- Merge two sorted linked lists
- Get Node Value
- Delete duplicate-value nodes from a sorted linked list
- Cycle Detection
- Find Merge Point of Two Lists
- Inserting a Node Into a Sorted Doubly Linked List
- Reverse a doubly linked list
- Tree: Preorder Traversal
- Tree: Postorder Traversal
- Tree: Inorder Traversal
- Tree: Height of a Binary Tree
- Tree: Top View
- Tree: Level Order Traversal
- Binary Search Tree: Insertion
- Is This a Binary Search Tree?
class Days(object):
def __init__(self):
self.day = 0
def __iter__(self):
return self
def __next__(self):
if self.day == 30:
raise StopIteration
else:
self.day += 1
return "Day " + str(self.day)
days = Days()
for d in days:
print(d)
- Day 0: Hello, World.
- Day 1: Data Types
- Day 2: Operators
- Day 3: Intro to Conditional Statements
- Day 4: Class vs. Instance
- Day 5: Loops
- Day 6: Let's Review
- Day 7: Arrays
- Day 8: Dictionaries and Maps
- Day 9: Recursion
- Day 10: Binary Numbers
- Day 11: 2D Arrays
- Day 12: Inheritance
- Day 13: Abstract Classes
- Day 14: Scope
- Day 15: Linked List
- Day 16: Exceptions - String to Integer
- Day 17: More Exceptions
- Day 18: Queues and Stacks
- Day 19: Interfaces
- Day 20: Sorting
- Day 21: Generics
- Day 22: Binary Search Trees
- Day 23: BST Level-Order Traversal
- Day 24: More Linked Lists
- Day 25: Running Time and Complexity
- Day 26: Nested Logic
- Day 27: Testing
- Day 28: RegEx, Patterns, and Intro to Databases
- Day 29: Bitwise AND
class Interviewee(object):
def __init__(self, name, prep):
self.name = name
self.prep = prep
self.hired = False
def interview(self, problem):
difficulty = problem.get_difficulty()
if difficulty > self.prep:
self.hired = False
print("Not hired!")
else:
self.hired = True
print("Hired!")
def get_name(self):
return self.name
def study(self):
self.prep += 1
class Problem(object):
def __init__(self, difficulty, description):
self.difficulty = difficulty
self.description = description
def get_description(Self):
return self.description
def get_difficulty(self):
return self.difficulty
problem1 = Problem(5, "Reverse a binary search tree")
joshua = Interviewee("Joshua Vernon", 7)
joshua.interview(problem1)
problem2 = Problem(9, "Solve the Knapsack problem")
joshua.interview(problem2)
for _ in range(3):
joshua.study()
problem3 = Problem(9, "Solve the Coin Change problem")
joshua.interview(problem3)
- Arrays: Left Rotation
- Strings: Making Anagrams
- Hash Tables: Ransom Note
- Linked Lists: Detect a Cycle
- Stacks: Balanced Brackets
- Queues: A Tale of Two Stacks
- Trees: Is This a Binary Search Tree?
- Sorting: Bubble Sort
- Sorting: Comparator
print("Hello, World!")
- Say "Hello, World!" With Python
- Reading Raw Input
- Python If-Else
- Arithmetic Operators
- Python: Division
- Loops
- Write a function
- Print Function
- Lists
- Tuples
- List Comprehensions
- Find the Second Largest Number
- Nested Lists
- Finding the percentage
- sWAP cASE
- String Split and Join
- What's Your Name?
- Mutations
- Find a string
- String Validators
- Text Alignment
- Text Wrap
- Designer Door Mat
- String Formatting
- Alphabet Rangoli
- Capitalize!
- The Minion Game
- Merge the Tools!
- Introduction to Sets
- Symmetric Difference
- No Idea!
- Set .add()
- Set .discard(), .remove() & .pop()
- Set .union() Operation
- Set .intersection() Operation
- Set .difference() Operation
- Set .symmetric_difference() Operation
- Set Mutations
- The Captain's Room
- Check Subset
- Check Strict Superset
- Polar Coordinates
- Find Angle MBC
- Triangle Quest 2
- Mod Divmod
- Power - Mod Power
- Integers Come In All Sizes
- Triangle Quest
- itertools.product()
- itertools.permutations()
- itertools.combinations()
- itertools.combinations_with_replacement()
- Compress the String!
- Word Order
- Classes: Dealing with Complex Numbers
- Class 2 - Find the Torsional Angle
- Any or All
- ginortS
- Regex Substitution
System.out.println("Hello, World!");
- Welcome to Java!
- Java Stdin and Stdout I
- Java If-Else
- Java Stdin and Stdout II
- Java Output Formatting
- Java Loops I
- Java Loops II
- Java Datatypes
- Java End-of-file
- Java Static Initializer Block
- Java Int to String
- Java Date and Time
- Java Currency Formatter
std::cout << "Hello, World!" << std::endl;
- Say "Hello, World!" With C++
- Input and Output
- Basic Data Types
- Conditional Statements
- For Loop
- Functions
- Pointer
- Arrays Introduction