Date:June 29th, 2022
Study Plan and Problem Number: LeetCode_75: Day 2
Problem 1:205 Isomorphijc Strings
Syntax:
- To check the size of string or vector, use '.size()' method
Algorithm & Structure:
- Use 'mapping' method to deal with the questions about pattern. It reduce the time complexity from O(n*n) = O(n²) to O(α*n)=O(n).
Bug:
- In double for loop, remember to check the dummy variables (e.g. i's and j's) in each case it appears. They are easily get tuggled and hard to debug.
Problem 2: 392 Is Subsequence
Syntax:
Algorithm&Structure:
Bug:
Conclusion:
- When the intuitive solution is O(n²), it may always possible to use some structures to allow the solution comes to O(α*n) = O(n). Mapping is successful since it avoids the looping of the second or even the third string or vector.
- Remember to double check the usage of dummy variables!
Next Plan:
- 2 problems in 75-Series
- 2 problems in Top Interview Questions.
种一棵树最好的时机是十年前 其次是现在。