View CodingInterviewPractice_2013_01_02.cs
Adam Lum
Coding for Interviews on Linked Lists
Implement a simple singly-linked list data structure.
Write a function to remove a list's 3rd from last element.
View CodingInterviewPractice_2012_12_24.cs
Adam Lum
Coding for Interviews on Merge Sort
Write a function that merges an array of already sorted arrays,
producing one large, still sorted array.
View CodingInterviewPractice_2012_12_17.cs
Adam Lum
Coding for Interviews on Binary Search Trees
Write a function that returns whether a given binary tree
is a valid binary search tree.
View transformer.rb
# Adam Lum's solution to RPCFN #8
require 'rubygems'
require 'hpricot'
require 'rexml/document'
include REXML
# Get the source file(s) via the command line argument, didn't see anything
# in the challenge instructions detailing this step.
View fair_distribution.rb
# Adam Lum's solution to RPCFN #6
# Definitely not the most elegant, efficient, or Computer Science-y
# way to handle this challenge, but it's _a_ solution to these small sets.
# (For the sake of my code, hopefully the hypothetical t-shirt printing
# company in the problem never owns more than 4 machines) :)
class FairDistribution
View maze.rb
# Adam Lum's solution to RPCFN #5
class Maze
attr_accessor :maze_array, :start_point, :end_point
def initialize(in_maze)
@start_point = []
@end_point = []
@maze_array = in_maze.split("\n")
(0..@maze_array.size - 1).each do |i|
View polynomial.rb
# Adam Lum's solution to RPCFN #4
class Polynomial
attr_accessor :coefficient_array
def initialize(in_coefficient_array)
if (in_coefficient_array.size < 2)
raise ArgumentError, "Need at least 2 coefficients."
@coefficient_array = in_coefficient_array
View short_circuit.rb
# Adam Lum's solution for RPCFN #3
INFINITY = 1 << 64
def dijkstra (graph, start, destination)
# Initialize
nodes = []
graph.each do |c|
nodes << c[0]
View average_time_of_day.rb
# Adam Lum's solution to RPCFN #2
require 'time'
SECONDS_TO_CHECK_FOR = 10800 # Assuming 3 hours is a decent difference check
def average_time_of_day(times)
count_greater = 0
View shift_subtitle.rb
# Adam Lum's solution for RPCFN #1
require 'optparse'
# Get the command line arguments
options = {} do |opts|
opts.banner = "Usage: shift_subtitle.rb [options] input_file output_file"
opts.on("--operation [OPERATION]") do |o|