Home

Projective Geometry

Projection from 3D to 2D lost information length angles scale (cannot be recovered) Why? Euclidean vs. Projective Geometry Projective Geometry Lost: Angles, distance, ratio of distances Preserved: straightness We study of geometric properties that are invariant wrt projective transformations in projective geometr...

Read more

Merge k Sorted Lists

23. Merge k Sorted Lists Solutions - Divide and Conquer Use a dummy Node(0) to represent the first Node. When one of the lists has reached to the end, can directly append another list to the end. def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ l = len(lists) if l ...

Read more

Kth Smallest Element in a BST

230. Kth Smallest Element in a BST Solutions - In-order Traversal A helper function to traverse the tree in order. The function will be popped up from the stack, and thus its result is reversed. count-- for each ‘root’ node. When count == 0, we have found the result.

Read more

Implement Trie (Prefix Tree)

208. Implement Trie (Prefix Tree) Solutions Store words in dictionary whose key is the first character of words, and value is a list of words. startsWith() requires the first several characters to be known, we can use this information to narrow down the search space. Similar to 211. Add and Search Word - Data structure design

Read more

Add and Search Word - Data structure design

211. Add and Search Word - Data structure design Solutions Store words in dictionary whose key is length of words, and value is a list of words. search() requires length to be known, we can use this information to narrow down the search space to words with the required length.

Read more