summaryrefslogtreecommitdiff
path: root/PlaygroundCpp
AgeCommit message (Collapse)Author
2018-12-17coin change Dynamic Programming done!Haidong Ji
2018-12-17Closest Pair done in C++!Haidong Ji
Finally Divide and Conquer section is finished. A lot of work but so much fun! A few take aways: 1. Be careful when copying code over from Java to C++. Java does parameter passing through reference as default, but I forgot to add "&" in C++ code, which caused my code not passing earlier; 2. Avoid unnecessary calculation. For example, the sqrt calculation is not necessary, until the last step. Avoiding that in my Python code saved a lot of time. 3. It seems that preallocate vector size, if you know beforehand, is a good idea. Woohoo, onto the next section!
2018-12-09Organize lottery done!Haidong Ji
2018-11-28Inversion count done!Haidong Ji
Worked out the algo earlier, but the challenge was to learn to use vector in C++ and vector slicing. I got bad allocation error initially due to misunderstanding that the end is not inclusive: that is, vector.begin() + m reaches vector.begin() + m-1.
2018-11-23Improved QuickSort done!Haidong Ji
2018-11-16Majority Element finally done!Haidong Ji
Wow, it took awhile to finish. Work has been busy and I haven't had time to hack...
2018-10-10Binary search done!Haidong Ji
It was interesting that int in jave has a bigger range than int in C++ Java: https://cs.fit.edu/~ryan/java/language/java-data.html C++: https://stackoverflow.com/questions/1819189/what-range-of-values-can-integer-types-store-in-c I used vector<int> initially, which failed on grader's test case 17/36. Changing that to vector<long> fixed it! Also interesting that recursive approach appears to be slightly faster with slighter bigger memory usage.
2018-10-03Largest number aka maximize salary done!Haidong Ji
2018-09-28Maximize num of places of prize done!Haidong Ji
More practice with C++ vector.
2018-09-27Covering segments/Collecting Signature done!Haidong Ji
Really fun to implement it in C++. Learned std::sort, std::unique, == overloading for struct for std::unique to work. Good stuff!
2018-09-07max dot product doneHaidong Ji
also known as maximize online ad revenue in exercise pdf file.
2018-09-07Fractional Knapsack done.Haidong Ji
Good exercise. Learned C++ vector usage, and the ASSERT_NEAR macro for testing floats/doubles. Lots of fun.
2018-09-02Changing money done.Haidong Ji
I noticed that in this case, it was really simple, because I pretty much copied the code from Java.
2018-08-29Fixing merging errorsHaidong Ji
2018-08-29Partial Fib sum last digit done for C++Haidong Ji
This concludes the second module of Algorithmic Design and Techniques from edX. I had a lot of fun doing it. It's challenging and I learned a lot!
2018-08-28Fib sum last digit done!Haidong Ji
2018-08-26Huge Fib mod M done!Haidong Ji
This was so much fun! I'm glad I did it with Python, Java, and C++, in that order. I learned so much through the process: typing, overflow, BigInteger, and ended up not needing BigInteger! Yay!!!
2018-08-19LCM done!Haidong Ji
2018-08-19GCD done!Haidong Ji
2018-08-16Got googletest going and fib last digit done!Haidong Ji
2018-08-13First optimized Fibonacci done!Haidong Ji
2018-08-07Max Pairwise Product implemented!Haidong Ji
2018-08-06Initial commit.Haidong Ji