Skip to content

Instantly share code, notes, and snippets.

View nhuntwalker's full-sized avatar

Nicholas Hunt-Walker nhuntwalker

View GitHub Profile
Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0.
Ex:
input matrix = [
[0, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[1, 5, 0, 7, 33],
[6, 7, 8, 9, 10],
[6, 7, 8, 9, 10],
You're given a grid of 1's and 0's.
A cluster of 1's corresponds with every 1 that has 1 as a neighbor to the left, right, up, or down.
Return an array of the size of each cluster of 1's in the grid.
Example:
input = [
[1,1,1,0,0,0,0],
[1,1,0,0,0,0,1],
[0,0,0,0,1,0,1],
Add Linked Lists of Numbers
You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list.
Ex:
438 + 123 = 561
[ 8 ] -> [ 3 ] -> [ 4 ]
+
[ 3 ] -> [ 2 ] -> [ 1 ]
Write a function to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x.
[ 4 ] -> [ 3 ] -> [ 1 ] -> [ 2 ] -> [ 5 ]
x = 2.5
[ 1 ] -> [ 2 ] -> [ 4 ] -> [ 3 ] -> [ 5 ]
Email to: nicholas@codefellows.com by 9:50am
Write a function that takes in two linked lists and will return a boolean that tells me whether or not those linked lists merge or don't
These two merge:
[ 1 ] - [ 2 ] - [ 3 ] - [ 4 ]
|
[ A ] - [ B ] ----
These two also merge:
[ 1 ] -> [ 2 ] -> [ 3 ] -> [ 4 ]
^
'part' and 'rapt' are anagrams
'apple' and 'papel' are anagrams
"rail safety" and "fairy tales" are anagrams
'foo' and 'bar' are not anagrams
'too' and 'to' are not anagrams
'AAA' and 'aaa' are not anagrams
Write a function that will check if two strings are anagrams of each other. Assume the strings have at least one character. Return a boolean. Be case sensitive
email the link to your public gist: nicholas@codefellows.com
Write a function that will take a query string as an argument and return the key-value pairs as a dictionary.
query = ?one=1&two=2
parameters(query) => {'one': '1', 'two': '2'}
query = ?foods=butter&foods=cake&foods=chicken
parameters(query) => {'foods': ['butter', 'cake', 'chicken']}
query = ?username=codefellows&password=learnmorefaster&courses=code201&courses=code301&courses=code401-python&courses=code401-javascript&courses=code401-dotnet
parameters(query) =>
@nhuntwalker
nhuntwalker / thing.txt
Created May 24, 2017 18:36
looped list
[1] -> [2] -> [3] -
^ |
| v
-----------
write a function that takes a linked list as an argument and returns a boolean telling
whether or not that list has a loop in it.
email to: nicholas@codefellows.com
def func(arg):
Write a function that takes two arguments:
- a list of numbers (not necessarily sorted)
- a number
Return the lowest index that the given number can take within the input list,
if that list was sorted.
e.g. the_list = [1, 2, 3, 4, 5], the_number = 2.5
the lowest index it can take is 2