# LeetCode

The following bit of code is essentially just an extension for myself that organizes GitBook's summary.md file to be coherent to order of leetcode problem sets.

```python
import collections
import re


def gitbook_clean_summary(in_file):
    """
    :type in_file: string
    :rtype: void
    """

    file_out = open("SUMMARY_SORTED.md", "w")

    with open(in_file, 'r') as file:
        lines = file.readlines()
        numbers = [int(re.search(r'\d+', line).group()) for line in lines]
        elements = dict([(line, number) for number, line in zip(lines, numbers)])
        sort_d = collections.OrderedDict(sorted(elements.items()))

    for key in sort_d:
        file_out.write('%s' % sort_d[key])

    file_out.close()


# note: SUMMARY.md must only contain 'LeetCode' parent folder
# detecting no number in lines will cause an exception to be thrown
gitbook_clean_summary("SUMMARY.md")
```

## Incomplete solutions

* 15
* 313
* 23
* 312
* 301
* 322
* 351
* 43
* 44
* 53
* 6 - time limited exceeded
* 54
* 42
* 140
* 512
