Friday, March 11, 2022

Leetcode algorithms: Read the problem and think

 March 11, 2022

10 more: 2019, 2033, 238, 1541, 1209, 2071, 296, 1244, 2065, 2081;

10 more: 406, 271, 1498, 735, 163, 1245, 1559, 247, 2025, 1197;

723, 2092, 62, 540, 1985    

296 Best meeting point 

Hard level - how to think the problem? BFS, each node has record of each node's shortest distance. All nodes with value 1 will start BFS together, if anyone position has all nodes 1 visited, then the sum of the distances will be the minimal one. 

1209Remove All Adjacent Duplicates in String II

Use stack -> data structure-> linear time complexity



No comments:

Post a Comment