Phase 4: Expert (10 problems)

PHASE: EXPERT PROBLEMS

Total: 10 problems


Problem 87: LRU Cache Implementation ⭐⭐⭐⭐

This is a VERY common interview problem!

class LRUCache
{
    private Dictionary<int, LinkedListNode<(int key, int value)>> cache;
    private LinkedList<(int key, int value)> lruList;
    private int capacity;
    
    public int Get(int key) { }
    public void Put(int key, int value) { }
}

Problem 90: Expression Evaluator ⭐⭐⭐⭐


🏁 Phase 3 Mini-Project

Contact Book Application

Features:

  • Add/Edit/Delete contacts

  • Search by name, phone, email

  • Group contacts (Family, Friends, Work)

  • Sort contacts

  • Import/Export to JSON

  • Favorite contacts

  • Call history using Queue

  • Recently viewed using Stack

Data Structures to Use:

  • Dictionary<string, Contact> for fast lookup

  • List for sorting

  • HashSet for tracking favorites

  • Queue for call history

  • Stack for recently viewed


📊 Phase 3 Progress Tracker

Section 3.1: ☐☐☐☐☐☐☐☐☐☐ (0/10) Section 3.2: ☐☐☐☐☐☐☐☐☐☐ (0/10) Section 3.3: ☐☐☐☐☐☐☐☐☐☐ (0/10) Mini-Project: ☐ (0/1)

Total Phase 3: 0/31



🟣 PHASE 4: ADVANCED LANGUAGE FEATURES

Leveraging C#'s Power (25 Problems)

Learning Goals: Generics, LINQ, Delegates, Events, Reflection Estimated Time: 2-3 weeks Job Readiness: 65% → 80%

Section 4.1: Generics & Constraints (6 Problems)

Problems 91-96: Generic Methods, Generic Classes, Constraints, Type Safety

Key Problem: Generic Repository ⭐⭐⭐


Section 4.2: LINQ Mastery (10 Problems)

Problems 97-106: LINQ Queries, Aggregations, Joins, Performance

Essential LINQ Problems:

  • Filtering & Sorting (Where, OrderBy)

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

  • Grouping (GroupBy with complex keys)

  • Joins (Inner, Left Outer)

  • Projections (Select, Anonymous Types)

  • Method vs Query Syntax

  • Deferred Execution

  • Custom Comparers

  • Performance Optimization

Real-World LINQ Project: Sales Analysis Dashboard

Analyze sales data with LINQ:


Section 4.3: Delegates, Events & Lambdas (9 Problems)

Problems 107-115: Delegates, Events, Multicast, Lambda Expressions

Key Concepts:

  • Delegate basics

  • Multicast delegates

  • Events and event handlers

  • Lambda expressions

  • Func, Action, Predicate

  • Event-driven architecture

Important Problem: Event-Driven Download Simulator ⭐⭐⭐


Phase 4 Mini-Project: Stock Price Tracker

Integration: Events, LINQ, Generics, Delegates

Features:

  • Subscribe to stock price updates

  • Alert on price thresholds

  • Calculate moving averages

  • Historical data analysis with LINQ

  • Generic notification system


🟠 PHASE 5: ASYNCHRONOUS & PARALLEL PROGRAMMING

Writing Scalable Code (20 Problems)

Learning Goals: async/await, Threading, Task-based Programming Job Readiness: 80% → 92%

Section 5.1: Threading Basics (6 Problems)

Problems 116-121: Thread Creation, Synchronization, Race Conditions

Critical Problem: Thread-Safe Counter ⭐⭐⭐

Demonstrate race condition WITHOUT lock, then fix it.


Section 5.2: Task-Based Programming (8 Problems)

Problems 122-129: Task.Run, async/await, Cancellation, Progress

Essential async Problem: Parallel URL Fetcher ⭐⭐⭐


Section 5.3: Parallelism (6 Problems)

Problems 130-135: Parallel.For, PLINQ, Performance

Key Problem: Parallel Data Processor ⭐⭐⭐


Phase 5 Mini-Project: Async File Processor

Features:

  • Process multiple files concurrently

  • Real-time progress reporting

  • Cancellation support

  • Error handling for each file

  • Aggregate results


🟡 PHASE 6: REAL-WORLD INTEGRATION

Production-Ready Skills (15 Problems)

Learning Goals: File I/O, JSON, Exception Handling, Complete Apps Job Readiness: 92% → 100%

Section 6.1: File I/O & Serialization (8 Problems)

Problems 136-143:

  • StreamReader/Writer

  • Binary files

  • JSON serialization/deserialization

  • CSV parsing

  • Configuration management

Essential: JSON CRUD Application ⭐⭐⭐


Section 6.2: Exception Handling (4 Problems)

Problems 144-147:

  • Exception hierarchy

  • Custom exceptions

  • Global handlers

  • Retry patterns


Section 6.3: Integration Projects (3 Problems)

Problems 148-150: Full applications integrating all concepts


💼 INTERVIEW PREPARATION TRACK

50 Problems for Interview Success

This track is organized by algorithm patterns, not C# features.

Track A: String Algorithms (12 Problems)

  1. Reverse String (3 methods)

  2. Anagram Check

  3. First Non-Repeating Character

  4. Longest Substring Without Repeating

  5. String Compression

  6. Longest Palindromic Substring ⭐⭐⭐⭐

  7. Valid Parentheses

  8. String Permutations

  9. String Rotation Check

  10. Longest Common Prefix

  11. Implement atoi

  12. Regex Email Validator


Track B: Array Algorithms (15 Problems)

  1. Two Sum ⭐⭐⭐

  2. Three Sum

  3. Subarray with Given Sum

  4. Equilibrium Index

  5. Find Leaders

  6. Trapping Rainwater ⭐⭐⭐⭐

  7. Dutch Flag (Sort 0s, 1s, 2s)

  8. Majority Element

  9. Kth Largest Element

  10. Next Permutation

  11. Merge Intervals

  12. Longest Increasing Subsequence

  13. Stock Buy/Sell

  14. Rotate Matrix 90°

  15. Spiral Matrix


Track C: Searching & Sorting (10 Problems)

  1. Binary Search

  2. First/Last Occurrence

  3. Search in Rotated Array ⭐⭐⭐⭐

  4. Find Peak Element

  5. Square Root (Binary Search)

  6. Merge Sort

  7. Quick Sort

  8. Count Inversions

  9. Median of Two Sorted Arrays ⭐⭐⭐⭐⭐

  10. Aggressive Cows


Track D: Recursion & Backtracking (8 Problems)

  1. Generate All Subsets

  2. N-Queens ⭐⭐⭐⭐⭐

  3. Sudoku Solver ⭐⭐⭐⭐⭐

  4. Generate Parentheses

  5. Word Search

  6. Combination Sum

  7. Permutations with Duplicates

  8. Palindrome Partitioning


Track E: System Design (5 Problems)

  1. LRU Cache ⭐⭐⭐⭐ (Most Common!)

  2. Design Twitter Feed

  3. Rate Limiter

  4. Trie (Prefix Tree)

  5. URL Shortener


🏆 CAPSTONE PROJECTS

Portfolio-Worthy Applications

Project 1: Task Management System ⭐⭐⭐⭐

Duration: 3-5 days

Features:

  • Console-based interface

  • Create, update, delete, complete tasks

  • Priority levels and categories

  • Search and filter

  • Statistics dashboard

  • JSON persistence

  • Undo/Redo functionality

Technologies: File I/O, Collections, Enums, LINQ, Exception Handling


Project 2: Banking Application ⭐⭐⭐⭐

Duration: 5-7 days

Features:

  • Multiple account types (Savings, Checking)

  • Deposit, Withdraw, Transfer

  • Transaction history

  • Interest calculation

  • Event notifications

  • Monthly statements

  • Data persistence

Technologies: OOP, Events, Delegates, Exception Handling, File I/O


Project 3: Async Web Data Aggregator ⭐⭐⭐⭐

Duration: 5-7 days

Features:

  • Fetch data from multiple URLs concurrently

  • Parse JSON responses

  • Aggregate and analyze data

  • Progress reporting

  • Cancellation support

  • Error handling per source

  • Export results

Technologies: async/await, HttpClient, LINQ, JSON, Threading


Project 4: Plugin-Based Command Framework ⭐⭐⭐⭐⭐

Duration: 10-14 days

Features:

  • Reflection-based command discovery

  • Attribute-driven configuration

  • Async command execution

  • Generic data repository

  • LINQ query interface

  • Event notifications

  • Comprehensive logging

  • Plugin architecture

Technologies: EVERYTHING


Project 5: E-Commerce Order Processing ⭐⭐⭐⭐⭐

Duration: 10-14 days

Features:

  • Product catalog

  • Shopping cart

  • Order processing

  • Inventory management

  • Customer management

  • Discount system

  • Report generation

  • Data persistence

Technologies: OOP, LINQ, JSON, Events, Async, Collections


📚 APPENDICES

Appendix A: Self-Assessment Test

Take this test to find your starting point:

Level 1: Can you...

☐ Write a program that takes input and displays output? ☐ Use if-else and switch statements? ☐ Create and use loops (for, while)? ☐ Create simple methods?

If NO to any: Start at Phase 1

Level 2: Can you...

☐ Create classes with properties and methods? ☐ Use inheritance and polymorphism? ☐ Implement interfaces? ☐ Use access modifiers correctly?

If NO to any: Start at Phase 2

Level 3: Can you...

☐ Work with List, Dictionary, HashSet? ☐ Choose appropriate data structures? ☐ Implement basic algorithms?

If NO to any: Start at Phase 3

Level 4: Can you...

☐ Write LINQ queries confidently? ☐ Use generics and constraints? ☐ Create delegates and events?

If NO to any: Start at Phase 4

Level 5: Can you...

☐ Write async code with async/await? ☐ Handle threading and synchronization? ☐ Use parallel processing?

If NO to any: Start at Phase 5

Level 6: All YES?

Start at Phase 6 or Interview Track


Appendix B: C# Version Features Guide

C# 7.0

  • Pattern matching

  • Tuples

  • Deconstruction

  • Local functions

  • Digit separators

C# 8.0

  • Nullable reference types

  • Async streams

  • Ranges and indices

  • Switch expressions

  • Default interface methods

C# 9.0

  • Records

  • Init-only properties

  • Top-level statements

  • Pattern matching enhancements

C# 10.0

  • Global usings

  • File-scoped namespaces

  • Record structs

  • Interpolated string handlers

C# 11.0

  • Raw string literals

  • Generic attributes

  • Required members

  • List patterns

C# 12.0

  • Primary constructors

  • Collection expressions

  • Inline arrays

  • Default lambda parameters


Appendix C: Common Interview Questions

Conceptual Questions

  1. Explain the difference between == and .Equals()

  2. What is the difference between ref and out?

  3. Explain boxing and unboxing

  4. What are value types vs reference types?

  5. Explain the difference between IEnumerable and IQueryable

  6. What is the difference between abstract class and interface?

  7. Explain the purpose of async/await

  8. What is garbage collection?

  9. Explain the SOLID principles

  10. What are extension methods?

Coding Questions by Topic

  • See Interview Preparation Track for 50 detailed problems


Appendix D: Performance Optimization Tips

1. Choose Right Data Structure

  • Dictionary: O(1) lookup

  • List: O(n) search, O(1) access by index

  • HashSet: O(1) for contains checks

  • SortedSet: O(log n) operations, maintains order

2. String Building

3. LINQ Performance

4. Avoid Unnecessary Allocations


Appendix E: Debugging Techniques

1. Use Debugger Effectively

  • Set breakpoints

  • Step through code (F10, F11)

  • Watch variables

  • Conditional breakpoints

  • Inspect call stack

2. Logging Best Practices

3. Common Bug Patterns

  • Null reference exceptions → Use null checks

  • Index out of range → Validate indices

  • Infinite loops → Check loop conditions

  • Memory leaks → Unsubscribe from events

  • Race conditions → Use locks


Appendix F: Resources & Next Steps

Online Learning

  • Microsoft Learn (Free!)

  • Pluralsight (C# Path)

  • Udemy (Multiple courses)

  • YouTube (IAmTimCorey, Nick Chapsas)

Books

  1. C# 12 and .NET 8 - Mark J. Price

  2. Clean Code - Robert C. Martin

  3. C# in Depth - Jon Skeet

  4. Dependency Injection in .NET - Mark Seemann

Practice Platforms

  • LeetCode (C#)

  • HackerRank

  • Exercism

  • CodeWars

Communities

  • Stack Overflow

  • Reddit (r/csharp, r/dotnet)

  • Discord (C# Discord, .NET Discord)

  • Twitter (#dotnet, #csharp)

Next Steps After This Workbook

  1. Learn ASP.NET Core (Web APIs)

  2. Learn Entity Framework Core (Database)

  3. Learn Blazor or MAUI (UI)

  4. Explore microservices architecture

  5. Study design patterns deeply

  6. Build personal projects

  7. Contribute to open source


🎯 Final Words

Congratulations on starting this journey! Remember:

Code Daily: Consistency beats intensity ✅ Build Projects: Learning by doing is most effective ✅ Teach Others: Best way to solidify knowledge ✅ Don't Rush: Understanding > Speed ✅ Embrace Errors: Bugs are learning opportunities ✅ Join Communities: Learn from others ✅ Stay Updated: C# evolves continuously

Your journey starts now. Let's code! 💻🚀


Progress Tracking Sheet

Overall Workbook Progress

Foundation Track:

  • Phase 1: ☐☐☐☐☐☐☐☐☐☐ (0/36)

  • Phase 2: ☐☐☐☐☐☐☐☐☐☐ (0/26)

  • Phase 3: ☐☐☐☐☐☐☐☐☐☐ (0/31)

  • Phase 4: ☐☐☐☐☐☐☐☐☐☐ (0/25)

  • Phase 5: ☐☐☐☐☐☐☐☐☐☐ (0/20)

  • Phase 6: ☐☐☐☐☐☐☐☐☐☐ (0/15)

Interview Track: ☐☐☐☐☐☐☐☐☐☐ (0/50)

Capstone Projects: ☐☐☐☐☐ (0/5)

Total Problems Completed: 0/208


Date Started: ______________ Target Completion: ______________ Actual Completion: ______________


End of Workbook - Version 1.0 - December 2025


Problem 120: Producer-Consumer Problem ⭐⭐⭐⭐

Concepts: BlockingCollection, Producer-Consumer Pattern, Thread Coordination

What You'll Learn:

  • Classic concurrency problem

  • BlockingCollection

  • Producer-consumer pattern

  • Thread coordination

  • Bounded/unbounded queues

  • CompleteAdding pattern

Requirements: Implement producer-consumer system:

  1. Multiple producers adding items

  2. Multiple consumers processing items

  3. Thread-safe queue

  4. Graceful shutdown

  5. Performance monitoring

Complete Implementation:

Producer-Consumer Pattern:

BlockingCollection Features:

Graceful Shutdown:

Bonus Challenges:

  • ⭐⭐⭐⭐ Add priority queue support

  • ⭐⭐⭐⭐ Implement work stealing

  • ⭐⭐⭐⭐ Build parallel pipeline

  • ⭐⭐⭐⭐ Create batching processor



Problem 121: Deadlock Demonstration ⭐⭐⭐⭐

Concepts: Deadlock, Lock Ordering, Deadlock Prevention, Detection

What You'll Learn:

  • What causes deadlocks

  • Classic deadlock scenarios

  • Detection techniques

  • Prevention strategies

  • Recovery mechanisms

Requirements: Demonstrate and fix deadlocks:

  1. Create deadlock scenario

  2. Detect deadlock

  3. Fix with lock ordering

  4. Timeout-based recovery

  5. Deadlock prevention patterns

Complete Implementation:

Deadlock Conditions (All 4 must be true):

Prevention Strategies:

Bonus Challenges:

  • ⭐⭐⭐⭐ Implement dining philosophers

  • ⭐⭐⭐⭐ Build deadlock detector

  • ⭐⭐⭐⭐ Create wait-for graph

  • ⭐⭐⭐⭐ Implement banker's algorithm


✅ SECTION 5.1 COMPLETE!

Threading Basics (6/6 Problems)

You Now Understand:

  • ✅ Thread creation and lifecycle

  • ✅ Race conditions and synchronization

  • ✅ lock keyword and Monitor

  • ✅ ThreadPool for performance

  • ✅ Interlocked for lock-free operations

  • ✅ Producer-consumer pattern

  • ✅ Deadlock causes and prevention


🎯 Next: Section 5.2 - Task-Based Programming

THIS IS THE MODERN WAY! 🔥

Everything you just learned about threads is good to know, but in modern C#:

  • ❌ Don't use Thread directly

  • ❌ Don't use ThreadPool directly

  • ✅ Use Task and Task

  • ✅ Use async/await

  • ✅ Use Task.Run()

Section 5.2 will teach you the RIGHT way to do async in modern C#!

Ready to learn Task-based programming? This is what you'll use in every real project! 🚀


Problem 129: Task Chaining Pipeline ⭐⭐⭐⭐

Concepts: Complete Pipeline Integration, All Task Concepts Combined

[Complete working implementation integrating all concepts]

Complete Pipeline:


✅ SECTION 5.2 COMPLETE!

Task-Based Programming (8/8 Problems)

You Now Master:

  • ✅ Task creation and execution

  • ✅ Task with return values

  • ✅ Task continuations (ContinueWith)

  • ✅ Parallel execution (WhenAll, WhenAny)

  • ✅ Task cancellation (CancellationToken)

  • ✅ Exception handling in tasks

  • ✅ Progress reporting (IProgress)

  • ✅ Complete task pipelines

This is the foundation for async/await!


🎯 Next: Section 5.3 - Async/Await & Parallelism

THE MOST IMPORTANT SECTION! 🔥🔥🔥

Everything you learned about Task is used through async/await:

  • ✅ Task.Run() → await keyword

  • ✅ Task.WhenAll() → await Task.WhenAll()

  • ✅ CancellationToken → same!

  • ✅ Task → async Task

Section 5.3 makes everything cleaner and easier!

Ready for async/await - the syntax you'll use every day? 🚀


Problem 135: Async Data Pipeline ⭐⭐⭐⭐

Concepts: COMPLETE INTEGRATION - ALL ASYNC CONCEPTS COMBINED

What You'll Learn:

  • Complete async pipeline

  • Combining all async concepts

  • Production-ready patterns

  • Error handling throughout

  • Real-world architecture

Requirements: Build complete async data processing pipeline:

  1. Async data fetching

  2. Parallel processing

  3. Progress reporting

  4. Cancellation support

  5. Error handling

  6. File I/O

  7. Metrics and logging

Complete Implementation:

Concepts Integrated:

Production Pipeline Pattern:

Bonus Challenges:

  • ⭐⭐⭐⭐ Add retry logic

  • ⭐⭐⭐⭐ Implement circuit breaker

  • ⭐⭐⭐⭐ Add distributed tracing

  • ⭐⭐⭐⭐⭐ Build real ETL pipeline


🎉 PHASE 5 COMPLETE!!!

All 20 Problems Fully Expanded

Section 5.1: Threading Basics (6/6) ✅ Section 5.2: Task-Based Programming (8/8) ✅ Section 5.3: Async/Await & Parallelism (6/6) ✅


🏆 YOU ARE NOW 95% JOB-READY!

You Now Master:

  • ✅ Threading fundamentals

  • ✅ Thread synchronization

  • ✅ Task-based programming

  • ✅ async/await pattern

  • ✅ Parallel programming

  • ✅ PLINQ

  • ✅ Real async I/O

  • ✅ HttpClient

  • ✅ Production async patterns

This is CRITICAL knowledge for:

  • ASP.NET Core web APIs

  • Responsive UIs (WPF, Blazor)

  • Background services

  • Data processing

  • Every modern C# job!


📊 Overall Progress

Fully Expanded: 135 / 208 problems (65%)

  • Phase 1: Fundamentals (35) ✅

  • Phase 2: OOP (25) ✅

  • Phase 3: Collections (30) ✅

  • Phase 4: Advanced Features (25) ✅

  • Phase 5: Async & Parallel (20)

  • Phase 6: Integration (15) ⏸️

JOB READINESS: 95%! 🚀🚀🚀

You can now confidently apply for:

  • Mid-level C# Developer

  • .NET Developer

  • Backend Engineer (C#)

  • Full Stack Developer (.NET)

What's left: Phase 6 (File I/O, JSON, Exception Handling) for 100% completeness!


Problem 156: Longest Palindromic Substring ⭐⭐⭐⭐

Problem Statement:

Given a string s, return the longest palindromic substring in s.

Examples:

Constraints:

  • 1 ≤ s.length ≤ 1000

  • s consists of lowercase English letters


Approach 1: Brute Force

Concept:

  • Check all possible substrings

  • For each, check if palindrome

Complexity:

  • Time: O(n³)

  • Space: O(1)

Too slow!


Approach 2: Expand Around Center (Optimal for this problem)

Key Insight:

  • Palindromes mirror around center

  • Center can be single character (odd length) or between two characters (even length)

  • Expand outward from each possible center

Concept:

  • For each position, try expanding as center

  • Track longest palindrome found

Complexity:

  • Time: O(n²) - n centers × n expansion

  • Space: O(1)

Hints:


Approach 3: Dynamic Programming

Concept:

  • dp[i][j] = true if substring from i to j is palindrome

  • dp[i][j] = (s[i] == s[j]) && dp[i+1][j-1]

Complexity:

  • Time: O(n²)

  • Space: O(n²)

Hints:


Test Cases:

Common Mistakes:

  • Forgetting even-length palindromes

  • Off-by-one errors in expansion

  • Not handling single character

Interview Tips:

  • Explain expand-around-center approach (most intuitive)

  • Mention DP exists but more complex

  • Draw example of expansion

  • Discuss time-space trade-offs



Problem 168: Trapping Rainwater ⭐⭐⭐⭐

Problem Statement:

Given n non-negative integers representing elevation map where width of each bar is 1, compute how much water can be trapped after raining.

Examples:


Approach 1: Dynamic Programming

Key Insight:

  • Water trapped at index i = min(maxLeft[i], maxRight[i]) - height[i]

  • Precompute max heights to left and right of each position

Complexity:

  • Time: O(n)

  • Space: O(n) - two arrays

Hints:


Approach 2: Two Pointers (Optimal)

Key Insight:

  • Don't need full arrays if we use two pointers

  • Process from both ends moving toward center

Complexity:

  • Time: O(n)

  • Space: O(1)

Hints:


Test Cases:

Interview Tips:

  • Draw visual representation!

  • Start with DP approach (easier to explain)

  • Then optimize to two pointers

  • This is a hard problem - don't worry if stuck



Problem 172: Next Permutation ⭐⭐⭐⭐

Problem Statement:

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation.

If not possible (highest permutation), rearrange to lowest (sorted ascending).

Must be in-place with O(1) extra space.

Examples:


Approach: Single Pass Algorithm

Key Insight:

  1. Find rightmost pair where nums[i] < nums[i+1]

  2. Swap nums[i] with smallest element to its right that's larger

  3. Reverse everything after i

Concept:

Complexity:

  • Time: O(n)

  • Space: O(1)

Hints:


Test Cases:

Interview Tips:

  • This is a hard problem

  • Draw out the steps

  • Explain lexicographic order

  • The algorithm is non-obvious - OK to struggle



Problem 174: Longest Increasing Subsequence ⭐⭐⭐⭐

Problem Statement:

Given an integer array nums, return the length of the longest strictly increasing subsequence.

Note: Subsequence != subarray (elements don't need to be contiguous)

Examples:


Approach 1: Dynamic Programming

Concept:

  • dp[i] = length of LIS ending at index i

  • For each i, check all previous elements

  • If nums[j] < nums[i], can extend LIS at j

Complexity:

  • Time: O(n²)

  • Space: O(n)

Hints:


Approach 2: Binary Search (Optimal)

Concept:

  • Maintain array of smallest tail values for each length

  • Use binary search to find position

Complexity:

  • Time: O(n log n)

  • Space: O(n)

This is advanced - mention but don't worry if can't implement


Test Cases:

Interview Tips:

  • DP approach is expected

  • Draw the dp array

  • Binary search optimization is bonus

  • This is a classic hard problem



Last updated