Skip to content

Instantly share code, notes, and snippets.

View nhuntwalker's full-sized avatar

Nicholas Hunt-Walker nhuntwalker

View GitHub Profile
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
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 ]
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],
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],