Homepage
Open in app
Sign inGet started

Coding Memo

leetcode solutions and programming notes

  • Array
  • Backtracking / DP / Greedy
  • Heap / Linked List
  • Two Pointers / Binary Search
  • Tree / Graph
  • Backend
  • Go to the profile of PHIL
    PHIL
    Jul 8

    [Leetcode] Min Stack

    Use more space to improve time complexity.

    Description

    Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.

    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 16, 2022

    [Leetcode] N-Queens

    A complicated backtracking problem in matrix form.

    Description
    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 15, 2022

    [Leetcode] Longest Common Subsequence

    Classic two dimensional dp problem.

    Description

    Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.

    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 13, 2022

    [Leetcode Patterns] Backtracking

    Backtracking is used in specific cases of DFS. Global variable / parameter may be modified across different level of search. However, when search returns, the variable / parameter needs to be at original state for the new search, where backtracking should occur.

    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 9, 2022

    [Leetcode] Insert Delete GetRandom O(1)

    Combining hash table and in place manipulation in array.

    Description

    Implement the RandomizedSet class:

    • RandomizedSet() Initializes the RandomizedSet object.
    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 8, 2022

    [Leetcode] Range Sum Query — Immutable

    Basic example implementation of dynamic programming.

    Description

    Given an integer array nums, handle multiple queries of the following type:

    1. Calculate the sum of the elements of nums…
    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 7, 2022

    [Leetcode Pattern] Sliding Window

    Sliding windowe is a special kind of two pointers. This technique is often used to find extremum…

    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 6, 2022

    [Leetcode Pattern] Two Pointers

    Two pointers are very commonly used in leetcode problems. The purpose is mostly to turn nested loop…

    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 5, 2022

    [Leetcode Pattern] BFS Tree

    BFS in tree follows pretty fixed template.

    Basic Template

    Read more…
    Go to the profile of PHIL
    PHIL
    Jul 2, 2022

    [Leetcode] Trapping Rain Water

    While the concept is two pointers converging from opposite sides, the implementation is more in a dp form.

    Description

    Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how…

    Read more…
    About Coding MemoLatest StoriesArchiveAbout MediumTermsPrivacyTeams