Skip to content

eddygarcas/zig-coding-interview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zig Coding Interview Challenges

A comprehensive collection of coding interview problems implemented in Zig, covering essential algorithms and data structures commonly encountered in technical interviews.

🎯 Overview

This repository contains 18 coding challenges organized by problem category, each implemented with clean, well-documented Zig code. The solutions demonstrate various algorithmic approaches, optimization techniques, and Zig-specific features like comptime evaluation.

📁 Project Structure

Each challenge is organized in its own directory with the following structure:

challenge-name/
├── src/
│   └── main.zig          # Main implementation
├── build.zig             # Build configuration
└── build.zig.zon         # Package configuration

🧮 Challenge Categories

Arrays & Two Pointers

Mathematics & Bit Manipulation

Hash Tables & Hash Maps

Advanced Algorithms

🚀 Getting Started

Prerequisites

  • Zig (version 0.11.0 or later)

Running a Challenge

Navigate to any challenge directory and run:

# Build and run
zig build run

# Run tests
zig build test

# Build only
zig build

Example Usage

cd "14 - Hash: two sum"
zig build run

Expected output:

Positions 1 and 2

🔧 Key Zig Features Demonstrated

  • Memory Management: Arena allocators, manual memory management
  • Comptime Evaluation: Compile-time computations for performance
  • Error Handling: Zig's explicit error handling with try and !
  • Type System: Strong typing with type inference
  • Performance: Zero-cost abstractions and manual optimizations
  • Hash Maps: std.hash_map.AutoHashMap usage patterns
  • Slices vs Arrays: Different approaches to data handling

📊 Complexity Analysis

Each solution includes:

  • Time Complexity: Big O notation for runtime performance
  • Space Complexity: Memory usage analysis
  • Alternative Approaches: Multiple solution strategies where applicable

🎓 Learning Objectives

This collection helps you master:

  1. Algorithm Design Patterns

    • Two pointers technique
    • Sliding window
    • Binary search
    • Hash table optimization
  2. Zig Programming Concepts

    • Memory allocators
    • Comptime evaluation
    • Error handling
    • Performance optimization
  3. Interview Preparation

    • Common problem patterns
    • Optimization techniques
    • Code organization
    • Testing strategies

🤝 Contributing

Feel free to:

  • Add new challenges
  • Improve existing solutions
  • Add alternative implementations
  • Enhance documentation
  • Report issues or bugs

📝 License

This project is open source and available under the MIT License.

🔗 Resources


Happy Coding! 🎉

Each challenge is self-contained and can be studied independently. Start with the category that interests you most or follow the numerical order for a structured learning path.

About

Re-implement Golang coding interview using Zig

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages