Portal/Notes πŸ“
Interview prep

Live Coding & Pair Programming

Persiapan live coding interview: pola soal yang sering keluar, strategi menjawab, cara komunikasi saat coding, dan checklist apa yang dinilai interviewer.

Format Umum

  • Durasi: 45-60 menit
  • Setup: CoderPad/HackerRank/VS Code Live Share, interviewer nonton sambil tanya
  • Fokus: Cara berpikir, bukan cuma hasil akhir
  • Ekspektasi: Kamu bisa jelasin每一ζ­₯ decision sambil nulis kode

Yang Dinilai Interviewer

  1. Problem decomposition β€” gimana kamu mecah masalah besar jadi langkah kecil
  2. Communication β€” bisa jelasin thought process sambil coding
  3. Trade-off awareness β€” sadar konsekuensi setiap keputusan teknis
  4. Error handling β€” handle edge case, bukan cuma happy path
  5. Code quality β€” naming, structure, readability (bukan cuma "works")
  6. Testing mindset β€” sebutin test case yang kepikiran, bahkan kalau gak ditulis

Pola Soal Fintech (Paling Sering)

1. Rate Limiter

Kenapa keluar: Setiap API gateway butuh ini. Fintech pake buat fraud prevention + API quota.

Yang diuji:

  • Paham token bucket vs sliding window vs fixed window
  • Concurrency safety (multiple goroutine requests)
  • Memory efficiency (cleanup data lama)
  • Time-based logic di Go (time.Tick, time.After)

2. Idempotency Key

Kenapa keluar: Payment gateway HARUS idempotent. Double charge = lawsuit.

Yang diuji:

  • Paham kenapa idempotency penting di distributed systems
  • Implementasi idempotency key dengan storage (Redis/DB)
  • Handling concurrent requests dengan key yang sama
  • Response caching untuk retry

3. Distributed Lock

Kenapa keluar: Mencegah double-processing di sistem terdistribusi.

Yang diuji:

  • Redis SET NX vs Redlock algorithm
  • TTL + auto-release untuk mencegah deadlock
  • Fencing token untuk mencegah race condition setelah lock expired
  • Trade-off: Redis vs etcd vs database advisory lock

4. LRU Cache

Kenapa keluar: Klasik, muncul di hampir semua technical interview.

Yang diuji:

  • Data structure choice: hashmap + doubly-linked list
  • Kenapa bukan single-linked list atau array
  • Time complexity: O(1) untuk get dan put
  • Concurrency: sync.Mutex vs sync.RWMutex

5. Worker Pool

Kenapa keluar: Go concurrency pattern wajib buat batch processing.

Yang diuji:

  • Goroutine management: spawn, reuse, cleanup
  • Channel patterns: fan-out, fan-in
  • Graceful shutdown dengan context cancellation
  • Backpressure handling

Strategi Live Coding

30 Detik Pertama β€” JANGAN LANGSUNG NGODING

  1. Tanya clarifying questions: "Apa maksimum request per detik?", "Apakah perlu persistent storage?", "Bagaimana kalau service restart?"
  2. Restate problem: "Jadi, kita perlu implementasi X yang handle Y dengan constraint Z."
  3. Sebutin approach: "Ada dua cara: A (simpler) dan B (more scalable). Saya mulai dari A dulu, lalu kita diskusi apakah perlu B."

Struktur Kode

// 1. Define types/interfaces dulu
type RateLimiter interface {
    Allow(key string) bool
}

// 2. Implement struct + constructor
type tokenBucket struct {
    // fields
}

func NewTokenBucket(rate int) *tokenBucket {
    return &tokenBucket{}
}

// 3. Implement method
func (tb *tokenBucket) Allow(key string) bool {
    // logic
}

// 4. (Optional) Test β€” sebutin aja
// "Saya akan test dengan: single request, burst request, concurrent request, expired token"

Cara Jawab "Ada yang mau di-improve?"

Selalu siap jawab:

  1. Concurrency: "Sekarang belum thread-safe, saya bisa tambah mutex di sini..."
  2. Memory: "Bisa tambah TTL + background cleanup goroutine..."
  3. Scalability: "Kalau perlu distributed, bisa ganti storage ke Redis..."
  4. Observability: "Bisa tambah metrics: request count, reject count, latency..."
Edit on GitHub

Last updated on

Live Coding & Pair Programming | Faisal Affan