Kattis Rank Climbing Notes
Martina DNA The core thinking is Sliding Window Algorithm. int findMinSubstringLength(const vector<int>& s, const unordered_map<int, int>& requiredCounts) { unordered_map<int, int> windowCounts; int minLength = INT_MAX; int left = 0, right = 0; int satisfied = 0; while (right < s.size()) { int rightInt = s[right]; if (requiredCounts.find(rightInt) != requiredCounts.end()) { windowCounts[rightInt]++; if (windowCounts[rightInt] == requiredCounts.at(rightInt)) { satisfied++; } } while (satisfied == requiredCounts.size()) { minLength = min(minLength, right - left...
Use of MapEntry in Java
I met Map.Entry for many times when I was fighting with Leetcode. However, I did not understand it and it always confused me. I studied it today and write down to record it for myself. (:Click here for java documention:) Map.Entry is a internal interface of Map. It provides more convenient method for outputing key-value pair. How do we output key-value pair of a Map generally? First, get all keys...
Haskell
Stack A modern, cross-platform build tool for Haskell code.
Download APache Maven on MacOS
I finally got maven installed, and the steps were generally easy, but I stepped in a few holes, I’ll record them. Download APache Maven Website📡: Apache-Maven Choose Binary zip archive and download it. Unzip the zip archive I unzip it into /Libaray on my computer. Configuration vi .bash_profile Add 2 lines into this profile export M2_HOME=/Library/apache-maven-3.8.7 // Or you can choose your...
Some basic algorithm
Difference between Dynamic programming and Greedy. Dynamic programming is kind of enumerating, but greedy not. Therefore, dynamic programming always take higher time complexity but greedy is always “cheaper”. Dynamic programming can always find optimal solution but greedy not. Difference between BFS, DFS and Dijkstra’s Algorithm.