📱 Học IELTS miễn phí: App IELTS 6.0
Giới Thiệu
Bạn giải được bài thuật toán, code chạy đúng, nhưng khi interviewer hỏi:
“Can you walk me through your solution?”
Bạn ấp úng, nói lộn xộn, và kết quả… không như mong đợi. 😓
Trong technical interview, viết code đúng chỉ là 50%. Phần còn lại là khả năng explain — giải thích rõ ràng tại sao bạn chọn approach đó, code hoạt động thế nào, và trade-off là gì.
Bài viết này sẽ giúp bạn:
- 🧠 Nắm 5 bước explain code chuyên nghiệp
- 💬 Có 15+ mẫu câu dùng ngay khi trình bày
- 📝 Xem script mẫu explain cho bài toán thực tế
- 📖 Học từ vựng technical interview với phiên âm IPA
Từ Vựng Explain Code
| English | IPA | Tiếng Việt |
|---|---|---|
| walk through | /wɔːk θruː/ | giải thích từng bước |
| approach | /əˈproʊtʃ/ | cách tiếp cận |
| iterate | /ˈɪtəreɪt/ | lặp qua (mảng, danh sách) |
| traverse | /trəˈvɜːrs/ | duyệt (cây, đồ thị) |
| initialize | /ɪˈnɪʃəlaɪz/ | khởi tạo (biến, giá trị ban đầu) |
| base case | /beɪs keɪs/ | trường hợp cơ sở (đệ quy) |
| recursive call | /rɪˈkɜːrsɪv kɔːl/ | gọi đệ quy |
| time complexity | /taɪm kəmˈplɛksɪti/ | độ phức tạp thời gian |
| space complexity | /speɪs kəmˈplɛksɪti/ | độ phức tạp bộ nhớ |
| trade-off | /ˈtreɪd ɒf/ | sự đánh đổi |
| edge case | /ɛdʒ keɪs/ | trường hợp biên |
| brute force | /bruːt fɔːrs/ | cách giải thô (thử tất cả) |
| optimize | /ˈɒptɪmaɪz/ | tối ưu hóa |
| readability | /ˌriːdəˈbɪlɪti/ | tính dễ đọc (code) |
| pseudocode | /ˈsuːdoʊkoʊd/ | mã giả |
| dry run | /draɪ rʌn/ | chạy thử bằng tay |
5 Bước Explain Code Chuyên Nghiệp
Bước 1: Restate The Problem — Nhắc lại bài toán
Trước khi code, hãy tóm tắt lại bài toán bằng lời của bạn. Điều này chứng minh bạn hiểu đúng yêu cầu.
Mẫu câu:
| English | Tiếng Việt |
|---|---|
| So if I understand correctly, we need to… | Nếu em hiểu đúng, mình cần… |
| The problem is asking us to find/return… | Bài toán yêu cầu tìm/trả về… |
| Let me clarify — the input is… and the expected output is… | Để em xác nhận — đầu vào là… và kết quả mong muốn là… |
| Are there any constraints I should consider? | Có ràng buộc nào em cần lưu ý không? |
Ví dụ:
“So if I understand correctly, we need to find the two numbers in the array that add up to the target value, and return their indices.”
Bước 2: Explain Your Approach — Trình bày cách tiếp cận
Trước khi viết code, hãy nói cách bạn định giải. Interviewer muốn thấy tư duy, không chỉ kết quả.
Mẫu câu:
| English | Tiếng Việt |
|---|---|
| My initial thought is to use… | Ý tưởng ban đầu của em là dùng… |
| A brute force approach would be…, but we can optimize by… | Cách brute force sẽ là…, nhưng mình có thể tối ưu bằng… |
| I’m thinking of using a hash map to reduce the time complexity to O(n). | Em nghĩ sẽ dùng hash map để giảm time complexity xuống O(n). |
| The key insight here is that… | Điểm mấu chốt ở đây là… |
| Let me outline my approach before coding. | Để em trình bày approach trước khi code. |
Ví dụ:
“A brute force approach would be to check every pair using two nested loops — that’s O(n²). But we can optimize by using a hash map. As we iterate through the array, we store each number and its index. For each number, we check if the complement (target minus current number) already exists in the map.”
Bước 3: Walk Through The Code — Giải thích từng phần
Khi viết code (hoặc sau khi viết xong), hãy giải thích từng block logic.
Mẫu câu:
| English | Tiếng Việt |
|---|---|
| First, I initialize a hash map to store… | Đầu tiên, em khởi tạo hash map để lưu… |
| Then, I iterate through the array… | Sau đó, em lặp qua mảng… |
| This condition checks whether… | Điều kiện này kiểm tra xem… |
| If the complement exists, we return… | Nếu complement tồn tại, mình trả về… |
| Otherwise, we add the current number to the map. | Nếu không, mình thêm số hiện tại vào map. |
| Here I’m using a two-pointer technique because… | Ở đây em dùng kỹ thuật hai con trỏ vì… |
Tip: Đừng đọc code theo từng dòng như máy. Hãy giải thích theo logic blocks — mỗi block làm gì và tại sao.
Bước 4: Analyze Complexity — Phân tích độ phức tạp
Interviewer luôn hỏi về time & space complexity. Chuẩn bị sẵn câu trả lời.
Mẫu câu:
| English | Tiếng Việt |
|---|---|
| The time complexity is O(n) because we traverse the array once. | Time complexity là O(n) vì mình duyệt mảng một lần. |
| The space complexity is O(n) due to the hash map. | Space complexity là O(n) do hash map. |
| This is a trade-off between time and space. | Đây là sự đánh đổi giữa thời gian và bộ nhớ. |
| Compared to the brute force O(n²), this is significantly faster. | So với brute force O(n²), cách này nhanh hơn đáng kể. |
Bước 5: Handle Edge Cases — Xử lý trường hợp đặc biệt
Chủ động nêu edge cases thể hiện bạn tư duy kỹ lưỡng.
Mẫu câu:
| English | Tiếng Việt |
|---|---|
| Let me consider some edge cases. | Để em xét một số edge cases. |
| What if the array is empty? | Nếu mảng rỗng thì sao? |
| What if there are duplicate values? | Nếu có giá trị trùng lặp thì sao? |
| I should also handle the case where no solution exists. | Em cũng cần xử lý trường hợp không có đáp án. |
| This solution handles negative numbers as well. | Solution này cũng xử lý được số âm. |
Script Mẫu: Explain Bài Two Sum
Đây là bài toán kinh điển trong interview. Xem cách explain từ đầu đến cuối:
Đề bài
Given an array of integers and a target, return indices of the two numbers that add up to the target.
Script trả lời
Bước 1 — Restate: “So we’re given an array of integers and a target sum. We need to find two numbers whose sum equals the target and return their indices. I’ll assume there’s exactly one valid solution.”
Bước 2 — Approach: “My initial thought is a brute force solution with two nested loops — checking every pair. That would be O(n²). But we can do better. I’ll use a hash map to store numbers we’ve seen so far. For each number, I check if its complement — that is, target minus the current number — is already in the map. This gives us O(n) time.”
Bước 3 — Walk through: “Let me code this up. First, I initialize an empty hash map. Then I iterate through the array with the index. For each number, I calculate the complement. If the complement is in the map, I return both indices. Otherwise, I store the current number with its index in the map.”
| |
Bước 4 — Complexity: “Time complexity is O(n) — we iterate through the array once. Space complexity is also O(n) for the hash map. This is a significant improvement over the brute force O(n²) approach.”
Bước 5 — Edge cases: “Edge cases to consider: an empty array returns an empty result, duplicate values work fine because we check the map before inserting, and this handles negative numbers as well.”
10 Mẫu Câu “Filler” Khi Cần Thời Gian Suy Nghĩ
Trong interview, im lặng quá lâu gây ấn tượng xấu. Dùng các câu này để câu giờ chuyên nghiệp:
| English | Khi nào dùng |
|---|---|
| Let me think about this for a moment. | Cần thời gian suy nghĩ |
| That’s a great question — let me consider… | Câu hỏi khó, cần xử lý |
| I’m going to think out loud here… | Muốn nói ra suy nghĩ |
| Let me trace through an example to verify. | Muốn dry run kiểm tra |
| One possible approach is… let me see if there’s a better one. | Có idea nhưng muốn tối ưu |
| I’m not 100% sure about this edge case, but… | Chưa chắc, muốn thảo luận |
| Let me refactor this to make it cleaner. | Muốn sửa code cho đẹp |
| Actually, wait — I think there’s a better way. | Vừa nghĩ ra cách tốt hơn |
| Can I use [library/method]? | Hỏi xem có được dùng không |
| Let me step back and reconsider the approach. | Muốn thay đổi hướng giải |
Những Lỗi Thường Gặp Khi Explain Code
❌ Lỗi 1: Đọc code từng dòng
Sai: “Line 1: I define a function. Line 2: I create a variable. Line 3: I start a for loop…”
Đúng: Giải thích theo logic blocks và tại sao bạn chọn cách đó.
❌ Lỗi 2: Code xong mới giải thích
Sai: Viết xong cả đống code rồi mới quay lại explain.
Đúng: Nói approach trước khi code. Giải thích trong khi code.
❌ Lỗi 3: Quên phân tích complexity
Sai: Interviewer phải hỏi mới nói.
Đúng: Chủ động nêu time & space complexity sau khi code xong.
❌ Lỗi 4: Im lặng quá lâu
Sai: Im lặng 2-3 phút khi suy nghĩ.
Đúng: Think out loud — nói ra suy nghĩ dù chưa hoàn chỉnh.
❌ Lỗi 5: Không hỏi clarifying questions
Sai: Nhảy vào code ngay.
Đúng: Hỏi về constraints, input range, expected output format.
Practice — Tự Luyện
Bài tập 1: Explain bài Reverse String
Viết solution và explain theo 5 bước. Dùng ít nhất 5 mẫu câu từ bài này.
| |
💡 Gợi ý script explain
“So we need to reverse the string in-place. I’ll use a two-pointer technique — one starting at the beginning, one at the end. I swap the characters at both pointers and move them toward the center. Time complexity is O(n/2) which simplifies to O(n). Space complexity is O(1) since we’re swapping in-place. Edge cases: empty string and single character string both work correctly since the while loop won’t execute.”
Bài tập 2: Tự explain một function bạn viết gần đây
Chọn một function từ project thực tế của bạn. Record bản thân explain bằng tiếng Anh. Nghe lại và cải thiện.
Bài tập 3: Mock Interview
Nhờ bạn bè cho 1 bài LeetCode random. Solve + explain trong 20 phút. Focus vào communicate rõ ràng, không chỉ code đúng.
Tổng Kết
| Bước | Mục đích | Thời gian |
|---|---|---|
| 1. Restate | Chứng minh hiểu đề | 1-2 phút |
| 2. Approach | Trình bày tư duy | 2-3 phút |
| 3. Walk through | Giải thích code | 5-10 phút |
| 4. Complexity | Phân tích hiệu suất | 1-2 phút |
| 5. Edge cases | Tư duy kỹ lưỡng | 1-2 phút |
Nhớ: Technical interview không chỉ test code — mà test cả communication skills. Một developer giải thích rõ ràng luôn ghi điểm hơn một developer code nhanh nhưng nói không ai hiểu.
Luyện tập explain code hàng ngày — khi review code, khi pair programming, khi viết PR description. Đó là kỹ năng dùng được cả đời! 💪
Bài tiếp theo: Remote Work Communication — Email & Chat Tiếng Anh — giao tiếp hiệu quả khi làm việc từ xa.