summaryrefslogtreecommitdiff
path: root/AlgoDesignAndTechniqueEdxPython/tests/coin_change_dynamic_programmingTest.py
diff options
context:
space:
mode:
authorHaidong Ji2018-12-16 20:21:12 -0600
committerHaidong Ji2018-12-16 20:21:12 -0600
commit1d6a57ac37f0c56a7639c1124be5501f699f3027 (patch)
tree922a96bbb6cf6d39aff7d494500f8f0d1956a38f /AlgoDesignAndTechniqueEdxPython/tests/coin_change_dynamic_programmingTest.py
parent88a15736625e2847d5c479ceabf202ea6be1e75b (diff)
Closest pair done!
I thought it wouldn't be this hard after I worked it out in Java first, but once again it was fun and I learned a lot: 1. in all my previous exercises, my Python code performed better than my Java code. This is the first time that my Java code significantly outperforms my Python code: 0.92 seconds versus 7.93 seconds! My Java code did use more than twice the memory. 2. Good re-enforcement of Python list copying concept, versus aliasing. Don't forget the [:] (or [l:r]) magic! 3. list of (num, num) sort by first num by default, with proper tie breaking. To sort on the second num, do list.sort(key=lambda x: x[1]. Cleve use of lambda, and it also does proper tie breaking. 4. I forgot to put this into my Java program comments, that Java code gave me a good practice of comparator versus comparable interfaces, which was very nice. Fun stuff! Curious how much faster C++ program will be. I'll find out!
Diffstat (limited to 'AlgoDesignAndTechniqueEdxPython/tests/coin_change_dynamic_programmingTest.py')
0 files changed, 0 insertions, 0 deletions