unreasonably effective

you can be sloppy, as long as you are rigorous

  • LeetCode 871: Minimum Number of Refueling Stops

    link Dynamic Programming The optimal refueling would look like a subsequence of (start, stations, target). For each station, we can find how far we can go with different number of refuelings. Then the minimum number of refuelings that gets us to the target is the answer. Time: , space: . Greedy We refuel only if…

    tanvirdotzaman

    February 21, 2025
    Uncategorized
  • LeetCode 134: Gas Station

    link Time: , space: . For a gas station, the net (gas-cost) >= 0 means we can make it to the next station. Since sum does not depend on the order of the numbers being summed up (commutativity), this also holds for a sequence of gas stations. Therefore, the sum of the nets of a…

    tanvirdotzaman

    February 21, 2025
    Uncategorized
  • LeetCode 881: Boats to Save People

    link Blind alleys What works The best pairing for the heaviest person is the lightest person. If combining the weight of the lightest person does not work, the heaviest person must ride alone. So, we sort the weights and on each iteration try pairing the heaviest with the lightest. Time: , space: .

    tanvirdotzaman

    February 21, 2025
    Uncategorized
  • LeetCode 55: Jump Game

    link As long as all indices (possibly except last index) have positive jumps, we can reach the end. Therefore, only way we may fail to reach the end is: Like the the case below: We keep improving the maximum allowed index. If current index is beyond our reach, we cannot reach the last index. Time:…

    tanvirdotzaman

    February 20, 2025
    Uncategorized
  • LeetCode 81: Search in Rotated Sorted Array II

    link Time: , space: . If all numbers were distinct, we could find which side of pivot is on by comparing with as below. Here, with duplicates allowed, we reduce the problem to the all-distinct case by making sure .

    tanvirdotzaman

    February 20, 2025
    Uncategorized
  • LeetCode 410: Split Array Largest Sum

    link Time: , space: Observations: Time: , space: .

    tanvirdotzaman

    February 20, 2025
    Uncategorized
  • Pushing changes to github repo

    tanvirdotzaman

    February 19, 2025
    Uncategorized
  • Why simple questions in number theory feel inscrutable?

    Systematic methods in Calculus help solve huge swath of problems. On the other hand, reading through a book on Number Theory feels like every problem has been solved ad hoc, with ingenious insight, why? Guess: Something to do with how numbers are represented in human brain.

    tanvirdotzaman

    February 19, 2025
    Uncategorized
  • Genlife

    tanvirdotzaman

    February 8, 2025
    Uncategorized
  • মিসিরালি

    tanvirdotzaman

    February 8, 2025
    Uncategorized
Previous Page
1 … 25 26 27 28 29 30
Next Page

Blog at WordPress.com.

  • Subscribe Subscribed
    • unreasonably effective
    • Already have a WordPress.com account? Log in now.
    • unreasonably effective
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar