Skip to content

Commit

Permalink
πŸ“ Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jobearrr authored Jul 2, 2024
1 parent 6e61b76 commit dd7d409
Showing 1 changed file with 74 additions and 1 deletion.
75 changes: 74 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,71 @@ Solutions to [LeetCode](https://leetcode.com/) problems written in Swift.
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]

## Requirements

* Xcode 15+
* Swift 5.9

## Running the solutions

Each problem solution has a test case in the [`Tests`][test-cases-folder-url] folder.

You can modify the test cases, provide new inputs and expected outputs.

Or you can run the companion app `LeetSwift`, to browse and run the test cases of the solutions for the problems you would like to check.

## Project structure
Here's the representation of the project structure, to make it easier to navigate through all folders.

Please pay attention to this if adding problems and implementing solutions, so everything conforms to this folder structure.
``` bash
.
β”œβ”€β”€ LICENSE
β”œβ”€β”€ LeetSwift # Companion app
β”‚Β Β  β”œβ”€β”€ Package.swift # Dummy package - excludes this folder from the main package
β”‚Β Β  └── ... # Companion app project files
β”œβ”€β”€ LeetSwift.xcworkspace # Workspace
β”œβ”€β”€ Package.swift # Main package
β”œβ”€β”€ Sources # Main package source code
β”‚Β Β  └── LeetSwiftCore # Library folder
β”‚Β Β  β”œβ”€β”€ Problems # Descriptions and definitions
β”‚Β Β  β”‚Β Β  └── XXX - Problem title # Problem files
β”‚Β Β  β”‚Β Β  └── ProblemDefinition.swift # Protocol-based problem definition
β”‚Β Β  └── Solutions # Implementation of solutions
β”‚Β Β  └── XXX - Problem title # Problem solution folder
β”‚Β Β  └── ProblemSolution.swift # A solution to the corresponding problem
└── Tests # Main package source code tests
└── LeetSwiftCoreTests # Core tests
β”œβ”€β”€ Core # Core testing support files
β”‚Β Β  β”œβ”€β”€ TestCaseProviding.swift # Testing support
β”‚Β Β  └── TestData.swift # Definition of test data
└── Problems # Tests for the solutions of all problems
└── XXX - Problem title # Problem solution test folder
└── ProblemTests.swift # Run test cases for a solution to the corresponding problem
```

### Companion App (🚧 Under construction πŸ‘·)
The companion app `LeetSwift` is intended to make it easier to browse and run the solutions. You can run it on any platform.

### Problems

Below there is a table with all the problems with their corresponding solution.

You can find the walkthrough with detailed solution of all the problems on my blog [jobear.dev][jobear-blog-url], or concrete problem solution walkthrough on the `Walkthrough` column (🚧 Under construction πŸ‘·).

| # | Title | Solution | Difficulty | Topics | Time | Space | Walkthrough |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | [Two Sum][001-problem] | [Solution][001-solution] | ![Difficulty][difficulty-easy-shield] | **`A`** **`HT`** | | | |

#### Topics
- **`A`** : Array
- **`HT`** : Hash Table

## Approach
Here, I use the TDD approach, writing the test cases before writing the solution. This way, I can quickly verify if the solution works as expected. The goals is to always have test cases for all the problems and to make all of them green.

If you would like to contribute, I recomment to write your solutions using this same approach.

<!-- Markdown references https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[last-commit-shield]: https://img.shields.io/github/last-commit/jobearrr/LeetSwift?style=flat
[last-commit-url]: https://github.com/jobearrr/LeetSwift/commits/master
Expand All @@ -15,4 +80,12 @@ Solutions to [LeetCode](https://leetcode.com/) problems written in Swift.
[license-shield]: https://img.shields.io/github/license/jobearrr/LeetSwift.svg?style=flat
[license-url]: https://github.com/jobearrr/LeetSwift/LICENSE
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg??style=flat&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/in/jobertsa/
[linkedin-url]: https://www.linkedin.com/in/jobertsa
[jobear-blog-url]: https://jobear.dev
[test-cases-folder-url]: https://github.com/jobearrr/LeetSwift/tree/main/Tests/LeetSwiftCoreTests/Problems
[difficulty-easy-shield]: https://img.shields.io/badge/%20Difficulty-Easy-brightgreen.svg
[difficulty-medium-shield]: https://img.shields.io/badge/%20Difficulty-Medium-orange.svg
[difficulty-hard-shield]: https://img.shields.io/badge/%20Difficulty-Hard-red.svg
[001-problem]: https://leetcode.com/problems/two-sum
[001-solution]: https://github.com/jobearrr/LeetSwift/blob/main/Sources/LeetSwiftCore/Solutions/001%20-%20Two%20Sum/TwoSumSolution.swift

0 comments on commit dd7d409

Please sign in to comment.