kodingup.camp

Beranda/Siap Kerja US: Interview Teknis

Cara Berpikir Keras & Komunikasi

Modul 11 dari 119 menit bacaThinking Out Loud

Isi modul

    Kenapa ini penting

    Dua kandidat menulis solusi yang sama persis. Kandidat A diam 25 menit, lalu berkata "done". Kandidat B bertanya dua hal di awal, menyebut solusi brute force dan kompleksitasnya, mengusulkan optimasi, menulis kode sambil menjelaskan, lalu menguji dengan tiga test case dan menemukan satu bug sendiri. Hampir pasti B yang lolos. Ingat empat kriteria dari Tech Interview Handbook di modul 1: communication, problem solving, technical competency, testing. Dua dari empat itu hanya terlihat kalau kamu berbicara.

    Bagi banyak orang Indonesia, ini tantangan ganda: berpikir sambil berbicara dan dalam bahasa Inggris. Kabar baiknya, kosakata yang dibutuhkan terbatas dan bisa dilatih seperti latihan soal. Kamu tidak perlu aksen sempurna; kamu perlu struktur yang membuat interviewer bisa mengikuti pikiranmu, dan keberanian untuk berkata "Let me think about this for a moment" daripada diam tanpa penjelasan.

    Analogi: interviewer itu seperti navigator di sebelah sopir reli. Kalau kamu menyetir tanpa bicara, ia tidak bisa membantu saat kamu salah belok. Kalau kamu menyebutkan rencanamu, ia bisa memberi hint sebelum kamu masuk jurang. Banyak interviewer memang ingin membantu; beri mereka kesempatan.

    Konsep inti

    Framework UMPIRE

    CodePath merangkum kebiasaan pemecahan masalah dalam akronim UMPIRE:

    Huruf Langkah Yang kamu lakukan Frasa bahasa Inggris
    U Understand Ulangi soal dengan kata-katamu, tanya batasan, buat contoh termasuk edge case "Just to confirm my understanding..." / "Can the input be empty?"
    M Match Cocokkan dengan pola yang dikenal (hash map, two pointers, BFS, DP) "This looks like a sliding window problem because..."
    P Plan Sebut brute force + kompleksitas, lalu rencana optimal, tulis pseudocode singkat "The brute force would be O(n²). I think we can do better with a hash map."
    I Implement Tulis kode bersih sambil menjelaskan bagian penting "I'll write a helper for this part."
    R Review Telusuri kode dengan contoh, lacak nilai variabel "Let me trace through the example: i equals 0..."
    E Evaluate Nyatakan kompleksitas, kelemahan, dan kemungkinan perbaikan "This runs in O(n) time and O(n) space. If memory were tight, I could..."

    Tech Interview Handbook (coding interview cheatsheet) memberi urutan yang sejalan: perkenalan singkat, klarifikasi soal (jangan langsung coding, ajukan setidaknya 2-3 pertanyaan klarifikasi), diskusikan pendekatan dan trade-off serta kompleksitas lalu sepakati pendekatan, coding sambil berbicara, periksa pekerjaanmu sebelum menyatakan selesai, dan tutup dengan pertanyaan untuk interviewer. Kalimat dari handbook tersebut yang layak ditempel di dinding: jangan langsung mengumumkan bahwa kamu sudah selesai coding sebelum memeriksa bug, edge case, dan menelusuri test case.

    Pembagian waktu di ronde 45 menit (pola umum)

    Menit Kegiatan
    0-3 Perkenalan singkat
    3-10 Understand + Match (klarifikasi, contoh)
    10-15 Plan (brute force, optimasi, sepakati)
    15-32 Implement
    32-40 Review + Evaluate (test, perbaiki bug, kompleksitas)
    40-45 Pertanyaanmu untuk interviewer

    Bank frasa

    Klarifikasi - "Before I start, can I ask a few clarifying questions?" - "What's the expected size of the input?" / "Are the numbers sorted? Can there be duplicates or negatives?" - "Should I return the indices or the values?" / "If there's no valid answer, what should I return?"

    Menyampaikan rencana - "My first thought is a brute-force approach: check every pair, which is O(n²) time." - "We're doing repeated lookups, so a hash map could bring this down to O(n)." - "Does that approach sound reasonable before I start coding?"

    Saat buntu - "Let me think about this for a moment." (lalu benar-benar berpikir, maksimal 30-60 detik, lalu lanjut bicara) - "I'm considering two options here. The trade-off is..." - "I'm not sure about this edge case. Can I assume the input fits in memory?"

    Saat menerima hint - "That's a great point, so if I keep track of the last index, I don't need to restart the window." - Jangan defensif. Hint adalah hadiah, bukan hukuman.

    Testing - "Let me walk through a normal case, then the edge cases: an empty array, a single element, and duplicates." - "I found a bug: when the array has two zeros, my output is wrong. Let me fix that."

    Menutup - "If I had more time, I'd add input validation and write unit tests for these cases." - "What does a typical week look like for engineers on this team?"

    Latihan mock interview

    Membaca solusi tidak sama dengan latihan interview. Cara latihan yang efektif:

    1. Self-mock dengan rekaman: pilih soal, nyalakan timer 45 menit dan rekam layar + suara. Tonton ulang: berapa lama kamu diam? Apakah kamu menyebut kompleksitas? Apakah kamu menguji?
    2. Peer mock: bergantian jadi interviewer dan kandidat dengan teman. Interviewer memegang rubrik empat kriteria dan sengaja memberi soal yang ambigu.
    3. Mock dengan orang asing: platform mock interview (gratis atau berbayar) memberi tekanan yang lebih realistis. Tech Interview Handbook dan halaman behavioral-nya menyarankan mock interview dengan interviewer profesional.
    4. Latihan bahasa terpisah: setiap hari jelaskan satu solusi dengan suara dalam bahasa Inggris selama 3 menit, tanpa menulis kode.

    Rencana latihan 8-12 minggu

    Tech Interview Handbook memperkirakan sekitar 30 jam untuk persiapan minimum dan sekitar 100 jam untuk persiapan yang baik, dan menyarankan sekitar 3 bulan dengan 2-3 jam per hari untuk persiapan menyeluruh. Handbook itu juga menyarankan belajar per topik lalu langsung mengerjakan soal topik tersebut, dan merekomendasikan Grind 75 untuk menyusun jadwal soal. Rencana di bawah mengikuti prinsip itu dan urutan modul materi ini. Ini rencana contoh, sesuaikan dengan waktumu.

    Minggu Fokus Target
    1 Big-O, Array & Hash Map 10-12 soal mudah; jelaskan kompleksitas setiap soal dengan suara
    2 Two Pointers & Sliding Window 8-10 soal; hafal template window dinamis
    3 Stack, Queue, Linked List 8-10 soal; tulis heap dan queue dari nol tanpa catatan
    4 Tree (DFS/BFS, BST) 10 soal; mock pertama (rekam diri sendiri)
    5 Graph & grid, topological sort 8 soal; 1 mock dengan teman
    6 Binary search, heap, sorting 8-10 soal; tulis MinHeap dalam 10 menit
    7 DP dasar 8 soal 1D + 2 grid; ulang soal yang gagal di minggu 1-6
    8 Front-end: utility JS + 2 komponen React live debounce, throttle, Promise.all, emitter, deep clone, autocomplete, tabs
    9 System design + front-end system design 2 desain penuh (URL shortener, news feed) diucapkan dengan suara
    10 Behavioral (3-5 cerita STAR) + resume final 2 mock behavioral, perbaiki cerita
    11 Mock penuh tiap 2 hari, campur topik Evaluasi dengan rubrik, catat pola kesalahan
    12 Review lemah, istirahat cukup, mulai melamar/menjadwalkan Jangan belajar topik baru di 3 hari terakhir

    Kalau hanya punya 8 minggu, gabungkan minggu 2-3, 5-6, dan 10-11. Pola umum yang disarankan banyak sumber: ulang soal yang gagal setelah beberapa hari tanpa melihat solusi; kalau kamu masih bisa mengerjakannya, polanya sudah melekat.

    Contoh kode

    Dua alat latihan: mini test runner agar kebiasaan "test sebelum bilang selesai" terbentuk, dan contoh alur UMPIRE pada soal Product of Array Except Self (brute force → optimal), termasuk versi berbug yang ditemukan oleh test edge case.

    // Mini test runner, pakai ini saat latihan agar kebiasaan "test sebelum bilang selesai" terbentuk
    function check(fn, cases) {
      let pass = 0;
      for (const [args, expected] of cases) {
        const got = fn(...structuredClone(args));          // salin agar fungsi tidak merusak test case
        const ok = JSON.stringify(got) === JSON.stringify(expected);
        if (ok) pass++; else console.log(`  GAGAL ${fn.name}(${JSON.stringify(args).slice(1, -1)}) -> ${JSON.stringify(got)}, harusnya ${JSON.stringify(expected)}`);
      }
      console.log(`${fn.name}: ${pass}/${cases.length} lolos`);
    }
    
    // Soal: Product of Array Except Self (tanpa pembagian)
    // U: "Can the array contain zeros? Negative numbers?" -> ya, keduanya.
    // M: pola prefix/suffix (mirip prefix sum).
    // P (brute force): O(n^2)
    function productBrute(nums) {
      return nums.map((_, i) => nums.reduce((acc, x, j) => (j === i ? acc : acc * x), 1));
    }
    // P/I (optimal): prefix * suffix, O(n) waktu, O(1) ruang tambahan (di luar output)
    function productExceptSelf(nums) {
      const out = new Array(nums.length).fill(1);
      let prefix = 1;
      for (let i = 0; i < nums.length; i++) { out[i] = prefix; prefix *= nums[i]; }
      let suffix = 1;
      for (let i = nums.length - 1; i >= 0; i--) { out[i] *= suffix; suffix *= nums[i]; }
      return out;
    }
    // R: test normal + edge case (nol tunggal, nol ganda, dua elemen)
    const cases = [
      [[[1, 2, 3, 4]], [24, 12, 8, 6]],
      [[[-1, 1, 0, -3, 3]], [0, 0, 9, 0, 0]],
      [[[2, 3]], [3, 2]],
      [[[0, 0]], [0, 0]],
    ];
    check(productBrute, cases);
    check(productExceptSelf, cases);
    // → productBrute: 4/4 lolos
    // → productExceptSelf: 4/4 lolos
    
    // Versi bug yang sengaja dibuat: memakai pembagian dan lupa kasus nol ganda
    function productDivide(nums) { const total = nums.reduce((a, b) => a * b, 1); return nums.map(x => (x === 0 ? nums.filter(y => y !== 0).reduce((a, b) => a * b, 1) : total / x)); }
    check(productDivide, cases);
    // →   GAGAL productDivide([0,0]) -> [1,1], harusnya [0,0]
    // → productDivide: 3/4 lolos
    

    Contoh percakapan untuk bagian Review dan Evaluate di soal ini:

    Candidate: "Let me test the edge cases. With two zeros, every product should be zero... and my division-based version returns [1, 1]. That's a bug: when there are two zeros, the product of the others still contains a zero. That's actually why I prefer the prefix-suffix approach. It doesn't need division at all, handles zeros naturally, and runs in O(n) time with O(1) extra space besides the output."

    Interviewer: "Nice catch. What if the output array counted as extra space?"

    Candidate: "Then it would be O(n) space, since we need to return n values anyway. I don't think we can do better than that."

    Kesalahan umum

    1. Diam terlalu lama. Interviewer tidak bisa menilai pikiranmu. Cara benar: "Let me think for a moment", lalu ceritakan apa yang sedang kamu pertimbangkan.
    2. Langsung coding tanpa klarifikasi. Kamu bisa menyelesaikan soal yang salah. Cara benar: minimal 2-3 pertanyaan klarifikasi dan satu contoh yang disepakati.
    3. Menyembunyikan brute force karena malu. Brute force menunjukkan kamu paham soalnya dan memberi titik awal optimasi. Cara benar: sebut, beri kompleksitasnya, lalu tingkatkan.
    4. Mengumumkan "done" tanpa testing. Cara benar: telusuri satu contoh normal dan dua edge case sebelum berkata selesai.
    5. Belajar hanya dengan membaca solusi. Cara benar: kerjakan dengan timer, rekam diri, ulangi soal yang gagal beberapa hari kemudian.

    Latihan

    1. Mudah, Untuk soal "Given an array of integers, return the length of the longest strictly increasing contiguous subarray", tulis 4 pertanyaan klarifikasi dalam bahasa Inggris.
    2. Sedang, Rekam dirimu mengerjakan Two Sum (modul 3) dengan UMPIRE lengkap dalam 15 menit. Tulis transkrip singkat bagian Plan dan Evaluate dalam bahasa Inggris.
    3. Menantang, Kerjakan Merge Intervals (gabungkan interval yang tumpang tindih) dengan UMPIRE lengkap: pertanyaan klarifikasi, brute force, solusi optimal, kode, test (termasuk edge case), dan kompleksitas.
    Lihat solusi

    1. Contoh: - "Can the array be empty? What should I return in that case?" - "Does 'strictly increasing' mean equal neighbors break the streak?" - "Can there be negative numbers?" - "What's the maximum length of the array, roughly?"

    2. Contoh transkrip Plan: "The brute force is to check every pair with two nested loops, which is O(n²) time and O(1) space. Since we're repeatedly asking 'have I seen the number I need?', I can use a hash map from value to index. For each number, I check if target minus the number is already in the map; if yes, I return both indices, otherwise I store the current number. That's one pass, O(n) time and O(n) space. Does that sound good?" Evaluate: "This is O(n) time because each map operation is constant on average, and O(n) space for the map. The trade-off versus brute force is memory for speed. If the array were sorted, I could use two pointers with O(1) space instead."

    3.

    // U: "Are intervals sorted? Do [1,4] and [4,5] count as overlapping?" -> tidak terurut; ya, bersentuhan = tumpang tindih.
    // M: sort lalu sapu sekali (sweep).
    // P: brute force = bandingkan setiap pasangan berulang sampai tidak ada yang bisa digabung, O(n^2) atau lebih.
    //    optimal = sort berdasarkan awal, lalu gabung dengan interval terakhir di output.
    function merge(intervals) {
      const sorted = intervals.toSorted((a, b) => a[0] - b[0]);   // tidak merusak input
      const out = [];
      for (const [s, e] of sorted) {
        if (out.length && s <= out.at(-1)[1]) out.at(-1)[1] = Math.max(out.at(-1)[1], e);
        else out.push([s, e]);
      }
      return out;
    }
    // R: kasus normal, bersentuhan, belum terurut, kosong
    console.log(JSON.stringify(merge([[1, 3], [2, 6], [8, 10], [15, 18]])), JSON.stringify(merge([[1, 4], [4, 5]])), JSON.stringify(merge([[1, 4], [0, 4]])), JSON.stringify(merge([])));
    // → [[1,6],[8,10],[15,18]] [[1,5]] [[0,4]] []
    // E: O(n log n) waktu karena sort, O(n) ruang untuk salinan terurut dan output.
    

    Catatan: toSorted hanya menyalin array luar; elemen di dalamnya masih array interval asli. Kode di atas tetap tidak merusak input karena out.push([s, e]) membuat array baru, dan yang diubah oleh out.at(-1)[1] = ... hanya array baru tersebut. Kalau kamu menulis out.push(interval) lalu mengubahnya, input milik pemanggil ikut berubah. Menjelaskan detail seperti ini dengan suara adalah contoh "thinking out loud" yang baik.

    Ringkasan

    Video pendamping

    Kalau penjelasan di atas belum masuk, tonton ini. Video dari kanal YouTube pihak lain.

    How to NOT Fail a Technical InterviewFireship · Bahasa InggrisBuka di YouTube

    Kuis pemahaman

    Pilih satu jawaban per soal. Penjelasan muncul setelah kamu menjawab.