Tech ramblings

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…

2 easy string puzzles. From http://www.careercup.com/question?id=5642266903314432: Given a mapping configuration such as: 1:a 2:b ... 26:z And a string like "12632", print the number of different ways you can map such string to alphabet characters. For example, given "111" the answer is…

From http://www.programcreek.com/2013/01/leetcode-spiral-matrix-java/. Print a matrix in spiral order. My solution destroys the original matrix (makes it easy to handle matrixes that are not square), this would be a good idea to ask the interviewer if that's ok! In Python: …

From http://www.programcreek.com/2012/12/leetcode-word-ladder/. Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that only one letter can be changed at a time, and each intermediate word must exist in the dictionary. This one…

This is a rather specific problem and somewhat contrived. Found on careercup.com. There is an array of 3-tuple, in the form of (a, 1, 5). The first element in the tuple is the id, the second and third elements are both integers, and the third is always larger than…

Heap Sort In part 4 of MIT 6006 goes into heap data structures and heap sort. Heap sort runs in O(nlog n) time provided the array is already a heap and displays the heap invariant: that each parent node is greater than or equal to both its children. The…