---
# System prepended metadata

title: Leetcode 能力 check!

---

# Leetcode 能力 check!

## C++ 技巧

- [ ] **容器（Containers）**
  <details>
  <summary>內容</summary>
  
  - [ ] `vector` [check List 連結](https://hackmd.io/@DSArecorder/HyJQvoM5A)
  - [ ] `queue`
  - [ ] `priority_queue`
  - [ ] `deque` [check List 連結](https://hackmd.io/@DSArecorder/H1dR9oGcA)
  - [ ] `list`
  - [ ] `forward_list`
  - [ ] `array`
  - [ ] `set`
  - [ ] `unordered_set`
  - [ ] `map`
  - [ ] `unordered_map`
  - [ ] `multiset`
  - [ ] `multimap`
  - [ ] `pair`
  - [ ] `bitset`

  </details>

- [ ] **演算法（Algorithms）**
  <details>
  <summary>內容</summary>
  
    - [ ] `sort` [Cplusplus](https://www.cplusplus.com/reference/algorithm/sort/)
    - [ ] `find` [Cplusplus](https://www.cplusplus.com/reference/algorithm/find/)
    - [ ] `binary_search` [Cplusplus](https://www.cplusplus.com/reference/algorithm/binary_search/)
    - [ ] `count` [Cplusplus](https://www.cplusplus.com/reference/algorithm/count/)
    - [ ] `reverse` [Cplusplus](https://www.cplusplus.com/reference/algorithm/reverse/)
    - [ ] `shuffle` ("Shuffle" 是一個英語動詞，主要指將一組東西打亂或重新排列。) [Cplusplus](https://www.cplusplus.com/reference/algorithm/shuffle/)
    - [ ] `accumulate` [Cplusplus](https://www.cplusplus.com/reference/numeric/accumulate/)
    - [ ] `for_each` [Cplusplus](https://www.cplusplus.com/reference/algorithm/for_each/)
    - [ ] `transform` [Cplusplus](https://www.cplusplus.com/reference/algorithm/transform/)
  
  </details>

- [ ] **迭代器（Iterators）**
  <details>
  <summary>內容</summary>
  
  - [ ] `iterator`
  - [ ] `const_iterator`
  - [ ] `reverse_iterator`
  - [ ] `back_inserter`
  - [ ] `front_inserter`
  - [ ] `inserter`
  
  </details>

- [ ] **函式物件（Function Objects）**
  <details>
  <summary>內容</summary>
  
  - [ ] `std::function`
  - [ ] `std::bind`
  - [ ] `std::bind2nd`
  - [ ] `std::bind1st`
  - [ ] `std::less`
  - [ ] `std::greater`
  
  </details>

- [ ] **智能指標（Smart Pointers）**
  <details>
  <summary>內容</summary>
  
  - [ ] `std::unique_ptr`
  - [ ] `std::shared_ptr`
  - [ ] `std::weak_ptr`
  
  </details>

- [ ] **其他**
  <details>
  <summary>內容</summary>
  
  - [ ] `tuple`
  - [ ] `optional`
  - [ ] `variant`
  - [ ] `any`
  
  </details>

## 演算法技巧

1. Sliding Window
    1. left 是 sliding window 的 left boundary。
    2. window_sum 用於儲存目前 sliding window 內元素的總和。
    3. result 用於保存目前為止找到的最大總和。
    ```cpp!=
    #include <iostream>
    #include <vector>
    #include <algorithm>

    int slidingWindow(const std::vector<int>& nums, int k) {
        int left = 0;
        int window_sum = 0;
        int result = 0;

        // Slide the right boundary of the window across the array
        for (int right = 0; right < nums.size(); ++right) {
            // Add the current element to the window sum
            window_sum += nums[right];

            // If the window size exceeds k, shrink the window from the left
            if (right - left + 1 > k) {
                window_sum -= nums[left];
                ++left;
            }

            // Update the result with the maximum sum found so far
            result = std::max(result, window_sum);
        }

        return result;
    }

    int main() {
        std::vector<int> nums = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        int k = 3;
        std::cout << "Max sum of subarray of size " << k << " is " << slidingWindow(nums, k) << std::endl;
        return 0;
    }

    ```



## reference
1. [從零開始的競程介紹](https://hackmd.io/@LittlePants/Hyw_rueGK)
2. [【心得】講一些CPE、leetcode還有刷題的事情](https://forum.gamer.com.tw/C.php?bsn=60292&snA=8383)
3. [leetcode-master](https://github.com/youngyangyang04/leetcode-master?tab=readme-ov-file)
4. [LeetCode 刷1500題心路歷程](https://ikaminyou.medium.com/leetcode-%E5%88%B71500%E9%A1%8C%E5%BF%83%E8%B7%AF%E6%AD%B7%E7%A8%8B-8614284f03da)
5. [leetcode_problem_rating](https://zerotrac.github.io/leetcode_problem_rating/#/)
