## simple regex parser

From http://www.geeksforgeeks.org/forums/topic/implement-a-regular-expression-parser/: implement a simple regex parser. This is a brute force O(n2) solution that may have some rough edges, but works for most cases: …

From http://www.geeksforgeeks.org/forums/topic/implement-a-regular-expression-parser/: implement a simple regex parser. This is a brute force O(n2) solution that may have some rough edges, but works for most cases: …

From CareerCup.com. Find all combinations of 2 nodes which add up to a particular sum. Must have time complexity of O(n). My solution was O(nlog n), needed a hint to get the idea of using two simultaneous traversals (one in order, one reverse) to find all the…

From Cracking the Coding Interview: Implement a program to determine how many hits and pseudo-hits to return from a guess in mastermind. …

Some tricky pointer arithmetic. Turns out a really easy optimization if order doesn't matter much is to treat it like a single dimentional array of length d1 x d2 x d3 ... dn where d1 is the first dimention, etc. These two expressions are exactly equivalent in the way the memory…

Given a binary search tree and two nodes guaranteed to exist on the tree, find the lowest common ancestor they both share. My first attempt, which is nÃ¤ive but works, involves visiting the left and right subtree of each node to verify both nodes exist on one of them, then…

Trees it turns out are a lot harder than lists. For the first time I was clueless on a way forward without looking for a hint in the book. The problem is to just do a simple preorder traversal of a tree and print out every node. Recursively this is…

In C# and C this time, including cleanup code in the C version (no idea if this would score more points - it's not very practical since the program terminates immediately after). C: C#: …