Modified .gitignore to work in a clean environment
Added CMakeLists.txt to allow compilation with cmake
Implemented solution with limited memory consumption and solving problem with O(n) coplexity