Git Product home page Git Product logo

leetcode-1's Introduction

Leetcode

Code snippets and Test cases for Leetcode problems. Only Easy Problems are solved.

Build Status Codacy Badge

Introduction

This project hosts the snippet code and test cases for Leetcode problems. You may find my solution code in branch hjmao.

Environment

This project is coded and tested with Java 8 and Gradle 5.4.1.

The test cases are based on the TestNG framework (6.14.3).

The Google Java code style is used in this project.

Code Layout

  • src/main/java/com/leetcode/snippets holds the original blank code snippets from leetcode.com and you may start solving the problems from here.

  • src/main/java/cn/hjmao holds the utilities for this project.

  • src/test/java/com/leetcode/snippets holds the test cases. All the test cases are disabled by the SOLUTION_DONE static variable in the solution file. So when you finish the problem, please set it to true in the solution file to enable the test cases. You can execute all the test cases with gradle test. If you have more test cases, you can append the test cases in the test unit files.

Source Code Layout

src
├── main
│   └── java
│       ├── cn
│       │   └── hjmao
│       │       ├── ProblemFetcher.java
│       │       └── utils
│       │           ├── AssertUtils.java
│       │           ├── list
│       │           │   ├── ListNode.java
│       │           │   └── ListNodeUtils.java
│       │           └── tree
│       │               ├── TreeNode.java
│       │               └── TreeNodeUtils.java
│       └── com
│           └── leetcode
│               └── snippets
│                   ├── a001twosum
│                   │   └── Solution.java
│                   ├── a002addtwonumbers
│                   │   └── Solution.java
│                   ├── ...
│                   │   └── Solution.java
│                   └── ...
│                       └── Solution.java
└── test
    ├── java
    │   ├── cn
    │   │   └── hjmao
    │   │       ├── ProblemFetcherTest.java
    │   │       └── utils
    │   │           ├── AssertUtilsTest.java
    │   │           ├── list
    │   │           │   └── ListNodeUtilsTest.java
    │   │           ├── quadtree
    │   │           │   └── NodeTest.java
    │   │           └── tree
    │   │               └── TreeNodeUtilsTest.java
    │   └── com
    │       └── leetcode
    │           └── snippets
    │               ├── a001twosum
    │               ├── ...
    │               │   └── SolutionTest.java
    │               └── a999availablecapturesforrook
    │                   └── SolutionTest.java
    └── resources
        └── log4j2.properties

How to use this repo

  1. Install Gradle 5.4.1

  2. Clone this project

    git clone https://github.com/huajianmao/leetcode
  3. Install the dependencies.

    gradle check
  4. Choose a problem, and focus on problem solving!!!

  5. Set the protected static final boolean SOLUTION_DONE = false; to true!!!!!

  6. Open and append your test cases to the test file!

  7. Debug with the test cases in src/test/java/com/leetcode/snippets/a00xxxxx/SolutionTest.java.

  8. Copy the code and submit it to Leetcode.

Note: If you don't like the code style checking, you may comment out two configurations in build.gradle:

->  // id 'checkstyle'
...
...
->  // checkstyle {
->  //   toolVersion = '6.19'
->  //   configDir = file("$rootProject.projectDir/config/checkstyle")
->  //}

ProblemFetcher script

If a new problem is provided in leetcode.com, you might use ProblemFetcher to automatically get the problem descriptions and the Solution file will be generated in com.leetcode.snippets, and you can copy it to your code place package. But in this case, you have to write the test cases by yourself.

Notice: You might need to revise the snippet slightly to make it return in the correct type.

Contribution

It would be my honor if you like this repo. You are very welcome to submit PRs on solutions, test cases. There would probably have lots of issues in this project, if you find some one, please throw a issue to me. Please help improving this repo better. Thanks!

leetcode-1's People

Contributors

huajianmao avatar

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.