https://www.gravatar.com/avatar/ab4373c6bd8c97aaf40c1042a5aad224?s=240&d=mp

2023.9.14~2023.9.17 Tokyo, Japan

Tokyo! Even though the trip was very rushed, it seemed to be enough for me. Even if I had extra time, I'd probably just roam around, see a few more landmarks and buildings, and enjoy more of the renowned local delicacies. Perhaps for every traveler, every city has its own advantages to admire.

1359. Count All Valid Pickup and Delivery Options

https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/ https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/submissions/1045563113/ class Solution { public: int countOrders(int n) { vector<int> dp(n + 1); dp[1] = 1; for(int i = 2; i <= n; ++i){ int tn = (2 * i - 1); int sn = (tn * (tn + 1)) / 2; dp[i] = (long long)dp[i - 1] * sn % 1000000007; } return dp[n]; } }; Looked Hint

2707. Extra Characters in a String

https://leetcode.com/problems/extra-characters-in-a-string/ https://leetcode.com/problems/extra-characters-in-a-string/submissions/1038162877/ class Solution { public: vector<int> ans; unordered_map<string, bool> mp; int minExtraChar(string s, vector<string>& dictionary) { ans.resize(s.size()+1, 0x3f3f3f3f); for(string a : dictionary) mp[a] = true; ans[s.size() - 1] = !mp[string(1, s.back())]; ans[s.size()] = 0; for(int i = s.size() - 2; i >= 0; --i){ for(int j = 1; j <= s.size() - i; ++j) { string tmp = s.substr(i, j); ans[i] = min(ans[i], (mp[tmp]?0:j) + ans[i+j]); } } return ans[0]; } };

1326. Minimum Number of Taps to Open to Water a Garden

https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden/ https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden/submissions/1036407008/ class Solution { public: int minTaps(int n, vector<int>& ranges) { vector<int> dp(n + 1, 0x3f3f3f3f); dp[0] = 0; for(int i = 0; i < ranges.size(); ++i) { int l = max(0, i - ranges[i]); int r = min(n, i + ranges[i]); for(int j = l; j <= r; ++j) { dp[j] = min(dp[j], dp[l] + 1); } } int ans = 0; for(int i = 0; i <= n; ++i) { if(dp[i] == 0x3f3f3f3f) { return -1; } ans = max(ans, dp[i]); } return ans; } };

2366. Minimum Replacements to Sort the Array

https://leetcode.com/problems/minimum-replacements-to-sort-the-array/description/ https://leetcode.com/problems/minimum-replacements-to-sort-the-array/submissions/1035547342/ class Solution { public: long long minimumReplacement(vector<int>& nums) { long long ans = 0; int Max = nums.back(); for(int i = nums.size() - 2; i >= 0; --i) { //cout << i << " max = " << Max << " num = " << nums[i] << endl; if(nums[i] <= Max) { Max = nums[i]; continue; } int divisor = nums[i]; int dividend = Max; int mod = divisor % dividend; int quotient = divisor / dividend; if(mod == 0) { ans += quotient - 1; continue; } ans += quotient; // binary search to find max Max int l = mod, r = Max; while(l <= r) { int mid = (l + r) >> 1; int gap = mid - mod; int times = gap / quotient; if(gap % quotient !

c++ lib or usage, which I hardly used but seen

cstdlib div div_t div(int numer, int denom); ldiv_t div(long int numer, long int denom); lldiv_t div (long long int numer, long long int denom); Returns the integral quotient and remainder of the division of numer by denom ( numer/denom ) as a structure of type div_t, ldiv_t or lldiv_t, which has two members: quot and rem. Only int version for c /* div example */ #include <stdio.h> /* printf */ #include <stdlib.