Skip to content

The notes which solve codeforce problems

taintpro98/algorithm-problem-notes

Repository files navigation

Algorithm

g++ -std=c++17 practice/cpp/template.cpp && ./a.out

Python

Golang

  • Khi cap = 1, thì buffered channel chứa được một giá trị và không block main goroutine. Trong khi đó unbuffered channel sẽ block ngay.
package main

func main() {
	bufferedChan := make(chan int, 1)
	unbufferedChan := make(chan int)

	bufferedChan <- 1   // OK
	unbufferedChan <- 1 // deadlock
}

Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

source $HOME/.cargo/env

cargo new todo_list

English

🧩 1. Xác nhận hiểu đề

  1. "Let me make sure I understand the problem correctly."
  2. "So, we are given [...], and we need to return [...], right?"

🔍 2. Làm rõ yêu cầu, hỏi constraints

  1. "What are the constraints on the input size?"
  2. "Can the input contain duplicates or negative numbers?"
  3. "Is the input guaranteed to be sorted?"

🧠 3. Trình bày hướng giải & lựa chọn cấu trúc

  1. "I’ll first try a brute-force approach to understand the problem."
  2. "I think we can optimize it using a hashmap to reduce the time complexity."
  3. "This problem reminds me of [...], I think a similar technique applies here."
  4. "We can use a two-pointer approach since the array is sorted."

🏗️ 4. Giải thích cách cài đặt

  1. "I’ll start by initializing [...]."
  2. "Then I’ll iterate through the array and do [...]."
  3. "At each step, I will check if [...]."
  4. "If the condition is met, I will return [...]."
  5. "Otherwise, I’ll continue the loop."

📈 5. Phân tích độ phức tạp

  1. "The time complexity is O(n) because we loop through the array once."
  2. "The space complexity is O(n) due to the extra storage used by the hashmap."

🚧 6. Xử lý edge case

  1. "Let’s think about the edge cases."
  2. "If the input is empty or has only one element, we should return null."
  3. "Another edge case is when [...], which we should handle explicitly."

🎯 7. Tổng kết & chốt lại

  1. "To summarize, I’m using [...], and this solution handles all edge cases with optimal time and space complexity."

About

The notes which solve codeforce problems

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published