Phase 3: Advanced (52 problems)

PHASE: ADVANCED PROBLEMS

Total: 52 problems


Problem 35: Number Base Converter ⭐⭐⭐

Concepts: Methods, Math, Conversion Algorithms

What You'll Learn:

  • Converting between number bases

  • Using StringBuilder for efficiency

  • Understanding positional notation

Requirements: Implement conversions:

  1. Decimal to Binary

  2. Decimal to Octal

  3. Decimal to Hexadecimal

  4. Binary to Decimal

  5. Hexadecimal to Decimal

Bonus Challenges:

  • Any base to any base conversion

  • Handle fractional numbers

  • Add validation for invalid digits


🏁 Phase 1 Checkpoint: Mini-Project

Project: Smart Console Calculator

Duration: 2-3 days Concepts Integration: Everything from Phase 1

Requirements: Create a feature-rich calculator with:

  1. Basic Operations: +, -, *, /, %

  2. Scientific Functions: Power, Square Root, Factorial

  3. History: Store last 10 calculations

  4. Multiple Modes:

    • Basic Calculator

    • Scientific Calculator

    • Base Converter

    • Statistics Calculator (mean, median, mode)

  5. Error Handling: Division by zero, invalid input

  6. Menu System: Clean, user-friendly interface

Bonus Features:

  • Save/load calculation history to file

  • Memory functions (M+, M-, MR, MC)

  • Expression evaluation (e.g., "5 + 3 * 2")

  • Unit converter (temperature, length, weight)

Learning Goals:

  • Integrate all Phase 1 concepts

  • Practice code organization

  • Build confidence in program structure

  • Create something you can show in your portfolio

Success Criteria: ✅ All operations work correctly ✅ Clean, intuitive menu ✅ Proper error handling ✅ Code is well-organized in methods ✅ History feature works


📊 Phase 1 Progress Tracker

Track your completion:

Section 1.1: ☐☐☐☐☐☐☐☐☐☐ (0/10) Section 1.2: ☐☐☐☐☐☐☐☐☐☐ (0/10) Section 1.3: ☐☐☐☐☐ (0/5) Section 1.4: ☐☐☐☐☐☐☐☐☐☐ (0/10) Mini-Project: ☐ (0/1)

Total Phase 1: 0/36


🎯 Phase 1 Self-Assessment

Before moving to Phase 2, ensure you can:

✅ Write programs using variables, loops, and conditionals confidently ✅ Create and use methods with parameters and return values ✅ Work with arrays and perform basic operations ✅ Handle user input and validate data ✅ Debug simple logic errors ✅ Organize code into clear, reusable methods

Not confident in any area? Go back and practice those problems again!

Ready for Phase 2? Let's dive into Object-Oriented Programming! 🚀



📗 PHASE 2: OBJECT-ORIENTED PROGRAMMING MASTERY

Building Reusable, Maintainable Code (25 Problems)

Learning Goals: Design classes, implement inheritance and polymorphism, use interfaces effectively Estimated Time: 2-3 weeks (beginners) | 4-5 days (experienced) Job Readiness: 25% → 45%


Section 2.1: Classes & Objects (8 Problems)

Focus: Encapsulation, constructors, properties, access modifiers


Problem 46: Shape Hierarchy (Abstract Classes) ⭐⭐⭐

Concepts: Abstract Classes, Polymorphism, Interfaces

Requirements:

Create a List<Shape> and demonstrate polymorphism.

Bonus:

  • Add IDrawable interface

  • Implement comparison by area

  • Calculate total area of all shapes



Problem 52: IComparable Implementation ⭐⭐⭐

Concepts: Interfaces, Custom Sorting

Requirements:

Sort a List using built-in Sort().

Bonus: Implement IComparer for multiple sort criteria



Problem 53: IEnumerable Custom Collection ⭐⭐⭐

Concepts: Iterator Pattern, yield return

Requirements:

Use foreach on your custom collection.



Problem 56: Copy Constructor (Deep/Shallow) ⭐⭐⭐

Concepts: Object Cloning, Reference vs Value

Requirements: Demonstrate deep copy vs shallow copy:

Show how changing nested objects affects copies.



Problem 57: IDisposable Pattern ⭐⭐⭐

Concepts: Resource Management, using Statement

Requirements:

Use with using statement.



Problem 58: Singleton Pattern ⭐⭐⭐

Concepts: Design Patterns, Thread Safety

Requirements:

Bonus: Implement lazy initialization with Lazy



Problem 59: Factory Pattern ⭐⭐⭐

Concepts: Object Creation Patterns

Requirements:



Problem 60: Observer Pattern ⭐⭐⭐

Concepts: Event-Driven Design

Requirements:


🏁 Phase 2 Checkpoint: Mini-Project

Library Management System

Duration: 5-7 days Concepts: Full OOP Integration

Core Requirements:

  1. Classes:

    • Book (ISBN, Title, Author, Available)

    • Member (ID, Name, BooksCheckedOut)

    • Librarian (inherits from Member, additional privileges)

    • Library (manages books and members)

  2. Features:

    • Add/Remove books

    • Register members

    • Check out/Return books

    • Search books (by title, author, ISBN)

    • View member history

    • Fine calculation for late returns

  3. OOP Concepts to Apply:

    • Encapsulation (private fields, public properties)

    • Inheritance (Member → Librarian)

    • Polymorphism (different member types)

    • Interfaces (ISearchable, IReportable)

    • Exception handling

Bonus Features:

  • Implement reservation system

  • Multiple copies of same book

  • Category-based browsing

  • Save/load library data from file

  • Generate reports (most popular books, active members)


📊 Phase 2 Progress Tracker

Section 2.1: ☐☐☐☐☐☐☐☐ (0/8) Section 2.2: ☐☐☐☐☐☐☐☐ (0/8) Section 2.3: ☐☐☐☐☐☐☐☐☐ (0/9) Mini-Project: ☐ (0/1)

Total Phase 2: 0/26


🎯 Phase 2 Self-Assessment

Before moving to Phase 3, can you:

✅ Create classes with proper encapsulation? ✅ Use inheritance to avoid code duplication? ✅ Implement polymorphism effectively? ✅ Work with interfaces confidently? ✅ Apply basic design patterns? ✅ Explain when to use abstract classes vs interfaces?

Ready for Phase 3? Let's master collections! 📚



📙 PHASE 3: COLLECTIONS & DATA STRUCTURES

Mastering Data Organization (30 Problems)

Learning Goals: Choose and use appropriate data structures, optimize performance Estimated Time: 2-3 weeks (beginners) | 1 week (experienced) Job Readiness: 45% → 65%


Section 3.1: Array Fundamentals (10 Problems)


Problem 66: Merge Two Sorted Arrays ⭐⭐⭐


Problem 69: Two Sum Problem ⭐⭐⭐


Problem 70: Maximum Subarray Sum (Kadane's) ⭐⭐⭐


Section 3.2: Lists & Collections (10 Problems)


Problem 78: Dictionary Sorting ⭐⭐⭐


Problem 79: Group Data into Dictionary ⭐⭐⭐


Problem 80: Nested Collections ⭐⭐⭐


Section 3.3: Stacks, Queues & Advanced (10 Problems)


Problem 83: Balanced Parentheses Checker ⭐⭐⭐

Classic Stack Problem


Problem 85: Queue-Based Task Scheduler ⭐⭐⭐


Problem 86: Priority Queue Simulation ⭐⭐⭐


Problem 88: Circular Queue ⭐⭐⭐


Problem 89: Stack using Two Queues ⭐⭐⭐


Problem 92: Generic Repository Simulator ⭐⭐⭐

Concepts: Generic Classes, Type Constraints, Repository Pattern, CRUD Operations

What You'll Learn:

  • Creating generic classes

  • Type constraints (where T : class)

  • Repository design pattern

  • Generic collections usage

  • Predicate delegates with generics

Requirements: Create a generic Repository class that:

  1. Stores items of type T

  2. Supports CRUD operations

  3. Uses constraints to ensure T is a class

  4. Provides search/filter capabilities

Complete Implementation:

Type Constraint Explained:

Common Constraints:

Bonus Challenges:

  • ⭐⭐ Add pagination (GetPage method)

  • ⭐⭐⭐ Add IDisposable for cleanup

  • ⭐⭐⭐ Create IRepository interface

  • ⭐⭐⭐⭐ Add async methods (Task)

Real-World Usage:

  • Data access layers

  • Entity Framework patterns

  • Service layers

  • Generic utilities



Problem 99: LINQ Grouping ⭐⭐⭐

Concepts: GroupBy, Key, Group Operations, Nested Grouping

What You'll Learn:

  • Grouping data by key

  • Working with IGrouping<TKey, TElement>

  • Aggregating within groups

  • Multi-level grouping

  • Transforming grouped data

Requirements: Group and analyze collections:

  1. Group by single property

  2. Aggregate within groups

  3. Multi-level grouping

  4. Transform grouped results

Complete Implementation:

GroupBy Fundamentals:

Common Grouping Patterns:

Query Syntax:

Bonus Challenges:

  • ⭐⭐⭐ Group by date ranges (weeks, months)

  • ⭐⭐⭐ Implement pivot table functionality

  • ⭐⭐⭐⭐ Dynamic grouping based on user selection

  • ⭐⭐⭐⭐ Hierarchical grouping (3+ levels)

Real-World Usage:

  • Sales reports by region/product

  • Analytics dashboards

  • Data aggregation for charts

  • Organizing hierarchical data

  • Category summaries

Interview Tips: 💡 Know: "GroupBy returns IGrouping<TKey, TElement>" 💡 Explain: "Key property holds the grouping value" 💡 Common question: "Find top N per group" 💡 Mention performance for large datasets



Problem 100: LINQ Join Operations ⭐⭐⭐

Concepts: Join, GroupJoin, Inner Join, Left Outer Join, Multiple Joins

What You'll Learn:

  • Inner joins

  • Left outer joins

  • Group joins

  • Joining multiple collections

  • Method syntax vs Query syntax for joins

Requirements: Join related collections:

  1. Inner join (matching records only)

  2. Left outer join (all from left, matching from right)

  3. Multi-table joins

  4. Group join

Complete Implementation:

Join Types Comparison:

Join Syntax Templates:

Bonus Challenges:

  • ⭐⭐⭐ Implement right outer join

  • ⭐⭐⭐ Implement full outer join

  • ⭐⭐⭐⭐ Join on multiple conditions

  • ⭐⭐⭐⭐ Self-join (employees to managers)

Real-World Usage:

  • Database query results

  • Combining data from multiple sources

  • Master-detail relationships

  • Order systems

  • Reporting

Interview Tips: 💡 Know difference: Join vs GroupJoin 💡 Explain: "Left join uses DefaultIfEmpty()" 💡 Common question: "How to implement right/full outer join?" 💡 Mention performance considerations


[Due to length, continuing with remaining LINQ problems 101-106 in next message...]

Section 4.2 Progress: 4/10 complete

Should I continue with the remaining 6 LINQ problems?


Problem 101: LINQ with Complex Objects ⭐⭐⭐

Concepts: Nested Objects, Navigation Properties, SelectMany, Flattening

What You'll Learn:

  • Working with nested collections

  • SelectMany for flattening

  • Navigating object hierarchies

  • Querying related data

  • Projection with complex types

Requirements: Query hierarchical data structures:

  1. Access nested collections

  2. Flatten hierarchical data

  3. Filter at multiple levels

  4. Aggregate nested data

Complete Implementation:

SelectMany Explained:

Bonus Challenges:

  • ⭐⭐⭐ Query JSON-like nested structures

  • ⭐⭐⭐ Implement tree traversal with LINQ

  • ⭐⭐⭐⭐ Build query builder for nested data

  • ⭐⭐⭐⭐ Performance optimize deep nesting



Problem 104: LINQ with Custom Comparers ⭐⭐⭐

Concepts: IEqualityComparer, IComparer, Custom Sorting, Distinct with Comparer

What You'll Learn:

  • Creating custom comparison logic

  • IEqualityComparer for Distinct, Union, Except

  • IComparer for sorting

  • Case-insensitive comparisons

  • Complex object comparison

Requirements: Implement custom comparers for:

  1. Case-insensitive string comparison

  2. Custom object equality

  3. Natural number sorting (1, 2, 10 vs 1, 10, 2)

  4. Multi-property sorting

Complete Implementation:

When to Use Custom Comparers:

Bonus Challenges:

  • ⭐⭐⭐ Create multi-property comparer

  • ⭐⭐⭐ Implement version number comparer (1.0.0 vs 1.0.10)

  • ⭐⭐⭐⭐ Build configurable comparer (runtime property selection)



Problem 105: LINQ Performance Optimization ⭐⭐⭐

Concepts: Deferred Execution, Materialization, Query Optimization, Best Practices

What You'll Learn:

  • Deferred vs immediate execution

  • When to use ToList(), ToArray()

  • Avoiding multiple enumeration

  • Filter before sorting

  • Database query optimization

  • Performance profiling

Requirements: Optimize LINQ queries for performance:

  1. Understand deferred execution

  2. Avoid common performance pitfalls

  3. Measure query performance

  4. Apply optimization techniques

Complete Implementation:

Performance Checklist:

Bonus Challenges:

  • ⭐⭐⭐ Benchmark LINQ vs loops

  • ⭐⭐⭐ Profile memory usage

  • ⭐⭐⭐⭐ Optimize Entity Framework queries

  • ⭐⭐⭐⭐ Build performance monitoring



Problem 106: LINQ Data Pipeline ⭐⭐⭐

Concepts: Chaining Operations, ETL Process, Data Transformation, Integration

What You'll Learn:

  • Building data pipelines

  • Chaining multiple LINQ operations

  • Transform data through stages

  • Error handling in pipelines

  • Logging and monitoring

Requirements: Build a complete data processing pipeline:

  1. Extract data from source

  2. Transform with multiple operations

  3. Load into destination format

  4. Error handling

  5. Progress reporting

Complete Implementation:

Pipeline Patterns:

Bonus Challenges:

  • ⭐⭐⭐ Add retry logic for failures

  • ⭐⭐⭐ Implement batch processing

  • ⭐⭐⭐⭐ Build async pipeline with Task

  • ⭐⭐⭐⭐ Add cancellation token support

Real-World Usage:

  • Data migration

  • ETL processes

  • Log processing

  • Report generation

  • Data cleansing


✅ Section 4.2 COMPLETE!

LINQ Mastery (10/10 Problems) 🎉

What You've Mastered:

  • ✅ Filtering and sorting (Where, OrderBy)

  • ✅ Aggregations (Sum, Average, Count, Max, Min)

  • ✅ Grouping data (GroupBy)

  • ✅ Joining collections (Join, GroupJoin)

  • ✅ Complex objects and nesting (SelectMany)

  • ✅ Projections and transformations (Select)

  • ✅ Both syntaxes (Method and Query)

  • ✅ Custom comparers

  • ✅ Performance optimization

  • ✅ Complete data pipelines

🔥 You now have the #1 most important C# job skill!


🎯 Phase 4 Progress

Section 4.1: Generics & Constraints (6/6) ✅ Section 4.2: LINQ Mastery (10/10) ✅ Section 4.3: Delegates, Events & Lambdas (0/9) ⏸️

Total Phase 4: 16/25 (64%)


🚀 Next: Section 4.3 - Delegates, Events & Lambdas

The final piece of modern C# programming:

  • Event-driven architecture

  • Callback patterns

  • Lambda expressions

  • Func, Action, Predicate

  • Real-world event systems

Ready to complete Phase 4? 🎯


Problem 111: Custom Event with EventArgs ⭐⭐⭐

Concepts: Custom EventArgs, Data Passing, Event Design, Best Practices

What You'll Learn:

  • Creating custom EventArgs classes

  • Passing data through events

  • Immutable event data

  • Event naming conventions

  • Strong typing for events

Requirements: Build a stock trading system with custom events:

  1. PriceChangedEventArgs with old/new price

  2. TradeExecutedEventArgs with details

  3. AlertTriggeredEventArgs with conditions

  4. Proper event raising pattern

Complete Implementation:

EventArgs Best Practices:

Bonus Challenges:

  • ⭐⭐⭐ Add cancellable events (CancelEventArgs)

  • ⭐⭐⭐ Implement event history/replay

  • ⭐⭐⭐⭐ Build event sourcing pattern

  • ⭐⭐⭐⭐ Create event aggregator



Problem 114: Event-Based Timer ⭐⭐⭐

Concepts: Events, Threading, Timers, Event Lifecycle, Cleanup

What You'll Learn:

  • Creating timer with events

  • Event subscription lifecycle

  • Proper event unsubscription

  • Timer cleanup

  • Multiple subscribers

Requirements: Build a countdown timer with events:

  1. Tick event (every second)

  2. Complete event

  3. Cancelled event

  4. Progress reporting

  5. Multiple subscribers

Complete Implementation:

Event Subscription Lifecycle:

Memory Leak Prevention:

Bonus Challenges:

  • ⭐⭐⭐ Add pause/resume functionality

  • ⭐⭐⭐ Support multiple timers

  • ⭐⭐⭐⭐ Create alarm clock with snooze

  • ⭐⭐⭐⭐ Build Pomodoro timer



Problem 115: Notification System (Complete Integration) ⭐⭐⭐

Concepts: INTEGRATION OF ALL CONCEPTS, Event-Driven Architecture, Observer Pattern

What You'll Learn:

  • Combining delegates, events, lambdas

  • Observer pattern implementation

  • Multi-channel notifications

  • Priority handling

  • Real-world event system

Requirements: Build a complete notification system integrating:

  1. Multiple notification channels (Email, SMS, Push)

  2. Priority levels

  3. Event-driven architecture

  4. Filtering with lambda expressions

  5. Async notifications

Complete Implementation:

Architecture Diagram:

Concepts Integrated:

Bonus Challenges:

  • ⭐⭐⭐ Add rate limiting

  • ⭐⭐⭐ Implement retry logic

  • ⭐⭐⭐⭐ Make it fully async

  • ⭐⭐⭐⭐ Add message queuing

Real-World Usage:

  • Push notification systems

  • Email marketing platforms

  • SMS gateways

  • Alert systems

  • Event-driven microservices


🎉 SECTION 4.3 COMPLETE!

Delegates, Events & Lambdas (9/9 Problems)


✅ PHASE 4 COMPLETE!!!

All 25 Problems Fully Expanded 🏆

Section 4.1: Generics & Constraints (6/6) ✅ Section 4.2: LINQ Mastery (10/10) ✅ Section 4.3: Delegates, Events & Lambdas (9/9) ✅


🎓 Phase 4 Achievement Summary

You Now Master:

  • ✅ Generic programming (type safety + reusability)

  • ✅ LINQ (THE most important C# skill)

  • ✅ Delegates (function pointers + callbacks)

  • ✅ Events (publisher-subscriber pattern)

  • ✅ Lambda expressions (modern C# syntax)

  • ✅ Event-driven architecture

  • ✅ Observer pattern

  • ✅ Functional programming concepts

Job Readiness: 85% 🚀

Skills Remaining:

  • Async/Await (Phase 5) - Critical

  • File I/O & JSON (Phase 6) - Essential

  • Exception Handling (Phase 6) - Production-ready


📊 Overall Progress

Phase
Problems
Status
Job Impact

Phase 1

35

✅ 100%

Foundation

Phase 2

25

✅ 100%

OOP Skills

Phase 3

30

✅ 100%

Data Skills

Phase 4

25

✅ 100%

Modern C#

Phase 5

20

⏸️ 0%

Async Skills

Phase 6

15

⏸️ 0%

Integration

Fully Expanded: 115 / 208 problems (55%)


Problem 117: Thread Synchronization (Lock) ⭐⭐⭐

Concepts: Race Conditions, lock Keyword, Monitor, Thread Safety, Critical Sections

What You'll Learn:

  • What race conditions are

  • Why synchronization is needed

  • Using lock keyword

  • Monitor class

  • Critical sections

  • Deadlock risks

Requirements: Demonstrate thread synchronization:

  1. Show race condition without lock

  2. Fix with lock keyword

  3. Use Monitor class

  4. Show deadlock scenario

  5. Compare synchronized vs unsynchronized

Complete Implementation:

Race Condition Explained:

lock Keyword:

Monitor vs lock:

Deadlock Example:

Bonus Challenges:

  • ⭐⭐⭐ Implement reader-writer lock

  • ⭐⭐⭐ Create lock-free counter using Interlocked

  • ⭐⭐⭐⭐ Build thread-safe collection

  • ⭐⭐⭐⭐ Detect and prevent deadlocks

Real-World Usage:

  • Thread-safe collections

  • Database connection pools

  • Cache implementations

  • Singleton patterns (thread-safe)

  • Resource management

Interview Tips: 💡 Explain: "Race condition = multiple threads accessing shared data" 💡 Know: "lock prevents race conditions" 💡 Mention: "Always lock on private object" 💡 Important: "Deadlock = circular wait for locks" 💡 Common question: "How to make thread-safe?"



Problem 118: ThreadPool Usage ⭐⭐⭐

Concepts: ThreadPool, QueueUserWorkItem, Managed Thread Pool, Performance

What You'll Learn:

  • What ThreadPool is

  • When to use ThreadPool vs manual threads

  • QueueUserWorkItem method

  • ThreadPool configuration

  • Performance benefits

  • Limitations of ThreadPool

Requirements: Use ThreadPool for concurrent operations:

  1. Queue multiple work items

  2. Compare with manual threads

  3. Show performance benefits

  4. Demonstrate thread reuse

  5. Handle work item completion

Complete Implementation:

ThreadPool Benefits:

When to Use:

ThreadPool Limitations:

Bonus Challenges:

  • ⭐⭐⭐ Configure ThreadPool min/max threads

  • ⭐⭐⭐ Monitor ThreadPool saturation

  • ⭐⭐⭐⭐ Build custom thread pool

  • ⭐⭐⭐⭐ Compare ThreadPool vs Task.Run



Problem 119: Multithreaded Counter ⭐⭐⭐

Concepts: Interlocked, Atomic Operations, Lock-Free Programming

What You'll Learn:

  • Atomic operations

  • Interlocked class

  • Lock-free thread safety

  • Performance comparison

  • When to use Interlocked vs lock

Requirements: Implement thread-safe counters:

  1. Unsafe counter (race condition)

  2. Locked counter (thread-safe)

  3. Interlocked counter (lock-free)

  4. Performance comparison

  5. Various Interlocked operations

Complete Implementation:

Interlocked vs Lock:

When to Use Each:

Available Operations:

Bonus Challenges:

  • ⭐⭐⭐ Build lock-free stack

  • ⭐⭐⭐⭐ Implement lock-free queue

  • ⭐⭐⭐⭐ Create ABA problem demonstration

  • ⭐⭐⭐⭐ Build spin-wait with Interlocked



Problem 124: Task Continuation ⭐⭐⭐

Concepts: ContinueWith, Task Chaining, Continuation Options, Error Handling in Continuations

What You'll Learn:

  • Chaining tasks with ContinueWith

  • Continuation options

  • Error handling in chains

  • Success/failure continuations

  • Multiple continuations

Complete Implementation:

Continuation Options:

ContinueWith vs await:

Bonus Challenges:

  • ⭐⭐⭐ Build retry logic with continuations

  • ⭐⭐⭐ Create conditional pipeline

  • ⭐⭐⭐⭐ Implement saga pattern

  • ⭐⭐⭐⭐ Build workflow engine



Problem 125: Parallel Task Execution ⭐⭐⭐

Concepts: Task.WhenAll, Task.WhenAny, Parallel Execution, Aggregation

What You'll Learn:

  • Running tasks in parallel

  • WhenAll for multiple tasks

  • WhenAny for fastest result

  • Handling multiple results

  • Error handling in parallel tasks

Complete Implementation:

WhenAll vs WhenAny:

Exception Handling:

Bonus Challenges:

  • ⭐⭐⭐ Implement timeout for WhenAny

  • ⭐⭐⭐ Build parallel downloader

  • ⭐⭐⭐⭐ Create load balancer

  • ⭐⭐⭐⭐ Implement circuit breaker



Problem 126: Task Cancellation ⭐⭐⭐

Concepts: CancellationToken, CancellationTokenSource, Cooperative Cancellation

What You'll Learn:

  • Cancelling long-running tasks

  • CancellationToken usage

  • Cooperative cancellation

  • Timeouts

  • Cleanup after cancellation

Complete Implementation:

Cancellation Pattern:

Two Ways to Check Cancellation:

Timeout Pattern:

Bonus Challenges:

  • ⭐⭐⭐ Implement graceful shutdown

  • ⭐⭐⭐ Build cancellable download manager

  • ⭐⭐⭐⭐ Create cancellable pipeline

  • ⭐⭐⭐⭐ Implement cancellation with retry



Problem 127: Task Exception Handling ⭐⭐⭐

Concepts: AggregateException, Exception Propagation, Fault Handling

[Complete working implementation with exception handling patterns]

Key Pattern:



Problem 128: Progress Reporting ⭐⭐⭐

Concepts: IProgress, Progress, Reporting from Tasks

[Complete working implementation with progress reporting]

Key Pattern:



Problem 131: Async File Operations ⭐⭐⭐

Concepts: Async I/O, StreamReader/Writer, FileStream Async Methods, Non-Blocking I/O

What You'll Learn:

  • Async file reading and writing

  • StreamReader/Writer async methods

  • FileStream async operations

  • Benefits of async I/O

  • Large file processing without blocking

Requirements: Implement async file operations:

  1. Read file asynchronously

  2. Write file asynchronously

  3. Process large files

  4. Copy files without blocking

  5. Measure performance improvement

Complete Implementation:

Async I/O Methods:

Why Async I/O Matters:

Bonus Challenges:

  • ⭐⭐⭐ Build async log file processor

  • ⭐⭐⭐ Create async CSV parser

  • ⭐⭐⭐⭐ Implement async file watcher

  • ⭐⭐⭐⭐ Build async backup system



Problem 132: Parallel URL Fetcher ⭐⭐⭐

Concepts: HttpClient, Async HTTP, Parallel Downloads, Error Handling, Real Async I/O

What You'll Learn:

  • HttpClient for async HTTP requests

  • Downloading multiple URLs in parallel

  • Error handling in parallel operations

  • HttpClient best practices

  • Measuring download performance

Requirements: Build parallel URL fetcher:

  1. Download single URL

  2. Download multiple URLs in parallel

  3. Handle HTTP errors

  4. Measure download times

  5. Save downloaded content

Complete Implementation:

HttpClient Best Practices:

HttpClient Methods:

Bonus Challenges:

  • ⭐⭐⭐ Add retry logic with exponential backoff

  • ⭐⭐⭐ Implement download resume

  • ⭐⭐⭐⭐ Build web scraper

  • ⭐⭐⭐⭐ Create HTTP load tester



Problem 133: Parallel.For Demo ⭐⭐⭐

Concepts: Parallel.For, Parallel.ForEach, Data Parallelism, Partitioning

What You'll Learn:

  • Parallel.For for loop parallelism

  • Parallel.ForEach for collection processing

  • ParallelOptions for control

  • Performance comparison

  • When to use parallelism

Complete Implementation:

Parallel.For Patterns:

When to Use:

Bonus Challenges:

  • ⭐⭐⭐ Build parallel image processor

  • ⭐⭐⭐ Create parallel data transformer

  • ⭐⭐⭐⭐ Implement parallel merge sort

  • ⭐⭐⭐⭐ Build parallel search engine



Problem 134: PLINQ Performance Test ⭐⭐⭐

Concepts: PLINQ (Parallel LINQ), AsParallel(), Performance Optimization, When to Use

What You'll Learn:

  • PLINQ (Parallel LINQ)

  • AsParallel() method

  • Performance comparison

  • When PLINQ helps

  • PLINQ pitfalls

Complete Implementation:

PLINQ Usage:

Performance Comparison:

Bonus Challenges:

  • ⭐⭐⭐ Benchmark PLINQ vs LINQ

  • ⭐⭐⭐ Build PLINQ data analyzer

  • ⭐⭐⭐⭐ Create adaptive query engine

  • ⭐⭐⭐⭐ Implement custom partitioner



Problem 154: Longest Substring Without Repeating Characters ⭐⭐⭐

Problem Statement:

Given a string s, find the length of the longest substring without repeating characters.

Examples:

Constraints:

  • 0 ≤ s.length ≤ 5 × 10⁴

  • s consists of English letters, digits, symbols, and spaces


Approach 1: Brute Force

Concept:

  • Check all possible substrings

  • For each, verify if all characters are unique

Complexity:

  • Time: O(n³)

  • Space: O(min(n, m)) where m is character set size

Too slow!


Approach 2: Sliding Window with HashSet (Optimal)

Key Insight:

  • Use two pointers (left and right)

  • Expand window by moving right

  • Contract window when duplicate found

  • Track maximum length seen

Concept:

  • HashSet stores characters in current window

  • When duplicate found, remove from left until no duplicate

  • Update max length at each step

Complexity:

  • Time: O(n) - each character visited at most twice

  • Space: O(min(n, m)) - HashSet size

Hints:


Approach 3: Sliding Window with Dictionary (Optimized)

Concept:

  • Store character → last seen index

  • When duplicate found, jump left pointer directly

Complexity:

  • Time: O(n) - single pass

  • Space: O(min(n, m))

Hints:


Test Cases:

Common Mistakes:

  • Not handling empty string

  • Off-by-one errors with left pointer

  • Forgetting to update maxLength

  • Not using Math.Max when moving left pointer

Interview Tips:

  • Start by explaining brute force (shows understanding)

  • Draw the sliding window movement

  • Explain why each character is visited at most twice

  • Mention the optimization with Dictionary



Problem 158: String Permutations ⭐⭐⭐

Problem Statement:

Given a string s, return all possible permutations of its characters.

Examples:

Constraints:

  • 1 ≤ s.length ≤ 8

  • s consists of unique lowercase English letters


Approach: Backtracking

Key Insight:

  • For each position, try every remaining character

  • Recurse for rest of positions

  • Backtrack when done

Concept:

  • Fix first character, permute rest

  • Swap characters to try different first characters

  • Recursively build permutations

Complexity:

  • Time: O(n × n!) - n! permutations, n to build each

  • Space: O(n!) - storing all permutations

Hints:


Test Cases:

Interview Tips:

  • Draw the recursion tree

  • Explain backtracking concept

  • Mention time complexity (factorial!)

  • Discuss duplicate handling (if chars not unique)



Problem 161: Implement atoi (String to Integer) ⭐⭐⭐

Problem Statement:

Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer.

Algorithm:

  1. Read in and ignore leading whitespace

  2. Check if next character is '-' or '+' (determines sign)

  3. Read digits until non-digit or end of input

  4. Convert to integer

  5. Clamp to [−2³¹, 2³¹ − 1]

Examples:


Approach: State Machine

Concept:

  • Trim whitespace

  • Handle sign

  • Build number digit by digit

  • Check for overflow

Complexity:

  • Time: O(n)

  • Space: O(1)

Hints:


Test Cases:

Common Mistakes:

  • Not handling overflow correctly

  • Not stopping at first non-digit

  • Not handling '+' sign

  • Not handling leading zeros

Interview Tips:

  • This tests edge case handling

  • Use long to detect overflow

  • Be thorough with test cases

  • Ask about leading zeros, multiple signs, etc.



Problem 164: Three Sum ⭐⭐⭐

Problem Statement:

Given an integer array nums, return all triplets [nums[i], nums[j], nums[k]] such that:

  • i != j, i != k, and j != k

  • nums[i] + nums[j] + nums[k] = 0

The solution set must not contain duplicate triplets.

Examples:

Constraints:

  • 3 ≤ nums.length ≤ 3000

  • -10⁵ ≤ nums[i] ≤ 10⁵


Approach: Sort + Two Pointers

Key Insight:

  • Fix one number, find two others that sum to its negative

  • This becomes Two Sum problem for each fixed number!

Concept:

  1. Sort the array

  2. For each number (as first number):

    • Use two pointers for remaining array

    • Find pairs that sum to -(first number)

  3. Skip duplicates to avoid duplicate triplets

Complexity:

  • Time: O(n²) - O(n log n) sort + O(n²) for nested loops

  • Space: O(1) excluding output

Hints:


Test Cases:

Common Mistakes:

  • Not sorting first

  • Not skipping duplicates (causes duplicate triplets)

  • Off-by-one errors with pointers

  • Forgetting edge cases (all zeros, all same numbers)

Interview Tips:

  • Explain it builds on Two Sum

  • Draw the pointer movement

  • Emphasize duplicate handling

  • Mention Four Sum as follow-up



Problem 165: Subarray with Given Sum ⭐⭐⭐

Problem Statement:

Given an array of positive integers and a target sum, find a continuous subarray that sums to the target. Return the start and end indices.

Examples:

Constraints:

  • Array contains only positive integers

  • 1 ≤ arr.length ≤ 10⁵


Approach: Sliding Window

Key Insight:

  • Since all numbers are positive, we can use sliding window

  • If sum too small → expand window (add right)

  • If sum too large → shrink window (remove left)

Concept:

  • Two pointers: left and right

  • Maintain current sum

  • Adjust window based on sum comparison

Complexity:

  • Time: O(n) - each element added and removed at most once

  • Space: O(1)

Hints:


What if array has negative numbers?

  • Sliding window doesn't work!

  • Need different approach: prefix sum + hash map

  • Time: O(n), Space: O(n)


Test Cases:

Interview Tips:

  • Clarify if array has negatives (changes approach!)

  • Explain sliding window technique

  • Mention it works for positive numbers only

  • Discuss prefix sum approach for negatives



Problem 166: Equilibrium Index ⭐⭐⭐

Problem Statement:

Find an index where the sum of elements on the left equals the sum of elements on the right.

Examples:


Approach: Prefix Sum

Key Insight:

  • leftSum + arr[i] + rightSum = totalSum

  • If leftSum = rightSum, then:

    • leftSum = (totalSum - arr[i]) / 2

Concept:

  1. Calculate total sum

  2. Iterate, maintaining left sum

  3. Right sum = total - left - current

  4. Check if left == right

Complexity:

  • Time: O(n)

  • Space: O(1)

Hints:


Test Cases:

Interview Tips:

  • Explain prefix sum concept

  • Mention two-pass vs one-pass

  • Discuss edge case: single element



Problem 169: Sort 0s, 1s, 2s (Dutch Flag) ⭐⭐⭐

Problem Statement:

Given an array containing only 0s, 1s, and 2s, sort it in-place without using sort function.

Examples:


Approach 1: Counting

Concept:

  • Count occurrences of 0, 1, 2

  • Overwrite array with counts

Complexity:

  • Time: O(n)

  • Space: O(1)

Hints:


Approach 2: Dutch National Flag (Single Pass)

Key Insight:

  • Three pointers: low (next position for 0), mid (current), high (next position for 2)

  • Partition array into three sections

Concept:

  • 0s go to low region

  • 2s go to high region

  • 1s stay in middle

Complexity:

  • Time: O(n) - single pass

  • Space: O(1)

Hints:


Test Cases:

Interview Tips:

  • Show both approaches

  • Dutch flag is more elegant (single pass)

  • Explain why we don't increment mid when swapping with high

  • Mention this generalizes to k colors



Problem 170: Find Majority Element ⭐⭐⭐

Problem Statement:

Given an array, find the element that appears more than ⌊n/2⌋ times. You may assume such element always exists.

Examples:


Approach 1: Hash Map

Concept:

  • Count frequencies

  • Find element with count > n/2

Complexity:

  • Time: O(n)

  • Space: O(n)


Approach 2: Boyer-Moore Voting Algorithm (Optimal)

Key Insight:

  • Majority element appears more than all others combined

  • Cancel out different elements

  • Remaining is majority

Concept:

  • Candidate and count

  • If same as candidate, count++

  • If different, count--

  • If count = 0, new candidate

Complexity:

  • Time: O(n)

  • Space: O(1)

Hints:


Why this works:

  • Majority element survives cancellation

  • Even if all others team up, majority wins!


Test Cases:

Interview Tips:

  • Explain both approaches

  • Boyer-Moore is brilliant but non-obvious

  • Walk through example showing cancellation

  • This is a classic algorithm!



Problem 171: Kth Largest Element ⭐⭐⭐

Problem Statement:

Find the kth largest element in an unsorted array. Note that it is the kth largest element in sorted order, not the kth distinct element.

Examples:


Approach 1: Sort

Concept:

  • Sort array

  • Return element at index (length - k)

Complexity:

  • Time: O(n log n)

  • Space: O(1)


Approach 2: Min Heap of Size K

Concept:

  • Maintain heap of k largest elements

  • Top of heap is kth largest

Complexity:

  • Time: O(n log k)

  • Space: O(k)

Hints:


Approach 3: QuickSelect (Optimal)

Concept:

  • Like QuickSort but only recurse on one side

  • Partition array, check if pivot is kth largest

Complexity:

  • Time: O(n) average, O(n²) worst

  • Space: O(1)

This is advanced - mention but implementation is tricky


Test Cases:

Interview Tips:

  • Start with sort approach (simple)

  • Then min heap (better for small k)

  • Mention QuickSelect (optimal but complex)

  • Ask: "Do you want me to implement QuickSelect?"



Problem 173: Merge Intervals ⭐⭐⭐

Problem Statement:

Given a collection of intervals, merge all overlapping intervals.

Examples:


Approach: Sort + Merge

Key Insight:

  • Sort intervals by start time

  • Merge consecutive overlapping intervals

Concept:

  1. Sort by start time

  2. Iterate, checking if current overlaps with previous

  3. If overlaps, merge (extend end)

  4. If not, add previous and start new interval

Complexity:

  • Time: O(n log n) - sorting

  • Space: O(n) - output

Hints:


Test Cases:

Interview Tips:

  • Always sort first!

  • Draw timeline visualization

  • Handle edge case: one interval inside another

  • Mention insert interval as follow-up



Last updated