Martin's space
  • |
  • 简体中文
  • 🏠 Home
  • 📒 Posts
  • 📁 Archives
  • 🏷️ Tags
  • 🔍 Search
  • 💭 About
Home » 🏷️ Tags

Algorithm

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...

Created: 2023-11-05 | Updated: 2023-11-05 | 103 Words | Reading Time: 1 mins | Martin
© 2025 Martin's space Powered by Hugo & PaperMod
辽 ICP 备 2022011010 号 -1
被访问了次 迎接了位客人