Algorithm Problem Source code