Code Monkey home page Code Monkey logo

coding-interviews's Introduction

Coding Interviews

This repository presents updated and modernized solutions to programming challenges found in Harry He's "Coding Interviews" book, which is a well-regarded resource for candidates preparing for coding interviews. The book can be purchased on Amazon here.

Capture

Motivation

Here are some specific aspects I focused on while modernizing the solutions:

  1. Error Handling: Replaced error codes with exceptions to handle errors more gracefully.
  2. Input/Output: Used iostream instead of stdlib.h for standard input and output operations.
  3. Testing: Swapped console tests with assertions to validate the solutions.
  4. Data Structures: Preferred using vectors over bare arrays for flexibility.
  5. Looping: Used iterators instead of integer counters for traversing collections.
  6. Class Implementation: Implemented collections using classes to encapsulate data.
  7. References: Used references instead of pointers where possible for safety and readability.
  8. Functional Programming: Employed lambdas for implementing private functions.
  9. Simplifying Data: Used STL pairs instead of creating custom structs.
  10. Type Deduction: Utilized the auto keyword for cleaner code and type deduction.

Scope and Limitations

While I've endeavored to improve the solutions, it is important to note that:

  • This repository does not provide solutions to every problem mentioned in the book.
  • Some solutions in this repository may not correspond to problems directly from the book but are inspired by similar challenges.

Arrays

# Title Solution
1 Array rotation C++
2 Duplicates C++
3 Majority element C++
4 Merge arrays C++
5 Min number C++
6 Permutations C++
7 Reorder numbers C++

Strings

# Title Solution
1 Add numeric string C++
2 Allocate string C
3 Anagram C++
4 Combinations C++
5 Delete char C++
6 Delete duplicate chars C++
7 Edit distance C++
8 First char appearing once C++
9 Numeric string C++
10 Palindrome number C++
11 Permutations C++
12 Regex C++
13 Replace blanks C++
14 Reverse words in a sentence C++
15 String path C++

Stack and Queue

# Title Solution
1 Min in stack C++
2 Push pop order C++
3 Stream median C++

Lists

# Title Solution
1 Clone complex list C++
2 Delete duplicates C++
3 Delete node C++
4 Kth node C++
5 Loops C++
6 Merge lists C++
7 Print reversely C++
8 Reverse list C++
9 Sort list C++

Matrices

# Title Solution
1 Fibonacci C++
2 Partially sorted matrix C++
3 Sorted matrix C++

Classes

# Title Solution
1 Arrow and dot C++
2 Assigment operator C++
3 Objective C C

Bit operations

# Title Solution
1 Count ones C++
2 Modify numbers C++
3 Two missing numbers C++
4 Uniquely occuring numbers C++

Trees

# Title Solution
1 Balance C++
2 Construct binary tree C++
3 Convert to list C++
4 Depth C++
5 Largest subtrees C++
6 Lowest ancestor C++
7 Nodes at k distance C++
8 Path C++
9 Print levels C++
10 Print zigzag C++

Other

# Title Solution
1 Coin change C++
2 Eight queens C++
3 Greatest sum subarrays C++
4 K least numbers C++

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.