Skip to content

markhary/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

Lessons

Here are my C++ solutions to the LeetCode lessons. You can find the lessons here.

Here is the score color key:

  • Green >= 75%
  • 50% <= Blue < 75%
  • 25% <= Yellow < 50%
  • Red < 25% and accepted solution
  • Grey is work in progress, not accepted, or exceeded time limits.

Details Legend: D = Difficulty; S = Score; RT = Runtime

# Task - Solution Details
1 TwoSum.cpp
2 Add Two Numbers.cpp
3 Longest Substring.cpp
4 Median of Two Sorted Arrays.cpp
5 Longest Palindromic Substring.cpp
19 Remove Nth Node From End of List.cpp
36 Valid Sudoku.cpp
37 Sudoku Solver.cpp
94 Binary Tree Inorder Traversal.cpp
98 Validate Binary Search Tree.cpp
100 Same Tree.cpp
104 Maximum Depth of Binary Tree.cpp
141 LinkedListCycle.cpp
142 LinkedListCycleII.cpp
175 Combine Two Tables.sql
176 Second Hightest Salary.sql
177 Nth Hightest Salary.sql
178 Rank Scores.sql
181 Employees Earning More Than Their Managers.sql
204 Count Primes.cpp
237 Delete Node in a Linked List.cpp
268 Missing Number.cpp
349 Intersection of Two Arrays.cpp
412 Fizz Buzz.cpp
735 Asteroid Collision.cpp

Tests

Assuming you are using cmake, tests will be located in your $BUILD_DIR}/bin directory. All tests are in the same leetcode binary. Individual tests can be run per the googletest framework documentation. Here is a quick reference:

/path/to/build/bin> leetcode --help
/path/to/build/bin> leetcode --gtest_list_tests
/path/to/build/bin> leetcode --gtest_filter=TestName.Test
/path/to/build/bin> leetcode --seed 12345

Dependencies

Binaries are built using conan and cmake. Dependencies will be downloaded and built automatically.

Building

Use cmake and conan:

  1. mkdir build && cd build
  2. conan install ..
  3. cmake ..
  4. make

NOTICE: On Ubuntu, you will need to do an extra step: conan profile update settings.compiler.libcxx=libstdc++11 default. See step #5 for details.

Executables will be located in your $BUILD_DIR}/bin directory. Libraries will be located in your $BUILD_DIR}/lib directory.

You can build the tests for your favorite development environment using cmake. e.g.:

  • For the command line:
mkdir test/build
cd test/build
conan install ..
cmake ..
make
  • For XCode:
mkdir test/xcode
cd test/xcode
conan install ..
cmake -G Xcode ..
make

Tests will be created in the bin directory located wherever you ran cmake from (test\build\bin in the example above).

Contributing

You are welcome to contribute provided you accept the Contributor Covenant Code of Conduct.

License

This repository is licensed under The Unlicense.

Acknowledgements

  • Thank you to the gflags command line parsing library.
  • Thank you to the googletest C++ test framework.

About

My C++/SQL solutions to the LeetCode problems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published