leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1436.cpp (312B)


      1 class Solution {
      2   public:
      3     string destCity(vector<vector<string>> &paths) {
      4         unordered_map<string, int> um;
      5         for (auto &path : paths) {
      6             um[path[0]]--;
      7             um[path[1]]++;
      8         }
      9         for (auto &[k, v] : um)
     10             if (v == 1) return k;
     11         return "";
     12     }
     13 };