When solving problems on Leetcode, we often utilize data structures from the STL. Here, I document some commonly used syntax.

string

  1. substring extraction
    1
    2
    3
    4
    5
    // return s[pos, pos+n)
    s.substr(pos, n)

    // return s[pos, s.size())
    s.substr(pos)

vector

  1. len
    1
    int len = vec.size();

map

unordered_map