Solutions to leetcode problems implemented in Swift
Run the following interactive script to to generate a blank leetcode solution and test case
swift Scripts/start-new-problem.swift
Documentation is generated from the markdown in the solution files, with the DocC documentation compiler
To generate the static documentation in /_site
, from the repo folder run:
bash Scripts/generate-docs.sh
To preview the web version, run:
bash Scripts/preview-docs.sh
GitHub Pages is used to host the static content generated by the "Deploy Documentation" workflow
Linting can be ran with the SwiftLint tool:
swiftlint
XCTests can be ran through Xcode or VS Code (with Swift extension), or with:
swift test
Note: Current test cases are just the example inputs/outputs provided by Leetcode, and are not comprehensive
The Swift image for docker can be used if Swift is not installed locally
This command ran from the root of the repo will run the tests for instance:
docker run --rm -it -v "$(pwd):/leetcode" -w /leetcode swift swift test
docker run
: run a command within a docker container--rm
: removes container once it is done--it
: runs container in interactive mode (to see console output)-v "$(pwd):/leetcode
: mounts current directory to /leetcode inside container-w /leetcode
: sets container working directory to /leetcodeswift swift test
: executeswift test
using theswift
docker image