Git Product home page Git Product logo

grimmer0125 / algorithms-vscode Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 119 KB

All are written in Python 3. Some also have Go, JavaScript (Node.js), C#, C++ versions. Include test cases. To be convenient, often not follow Python pep8 snake coding style. IDE: VS Code & Atom. Include data structures, LeetCode problems. Convenient debugging by VSCode Setting

Python 84.38% Go 4.39% JavaScript 7.84% C++ 1.63% C# 1.76%
jest pytest unit-test cpp c-sharp dotnet-core visual-studio-code mstest

algorithms-vscode's Introduction

Some other coding problems in my inteviews

  1. reverse a string
  2. judge if a string is the substring of another string
  3. Hanoi tower
  4. use two stacks to implement a queue (pseudo code), https://leetcode.com/problems/implement-stack-using-queues/

Some questions in my interviews

  1. time complexity of merge sort
  2. what is the quickest search
  3. what is the worse case of hash table
  4. mouse maze, similar to LeetCode-490 The Maze (medium): https://leetcode.com/articles/the-maze/
  5. TicTacToe (LeetCode, my AI side project and React official site)

Some other interesting problems

  1. (Meta string) Checking if two strings contain the same characters regardless of order
  2. Regular Expression Puzzle: http://jimbly.github.io/regex-crossword

LeetCode favorite list

12 in easy(12) means that the first 12 problems in the list are in the first 200 leetcode problems which are used frequently.

Tips on LeetCode

Do not uncomment some pre-definition classes which are defined somewhere already, the system comments are just exploration e.g.

# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

interesting skills

two pointer method (caterpillar method), e.g:

Sometimes it is used in linked-list problems.

Node.js

Install:

  • yarn install

Test:

  • yarn test (find all *.test.js in the root folder)
  • yarn test specific_folder (only that folder)

Todo:

  1. (breakpoint) debugging while using Jest

Python

Install:

  • pip install -U pytest

Test:

  • pytest -s (find all *-*.py test_*.py files in the current folder)
  • pytest -s single_file (only that file)

Go

Run:

  1. in each folder, execute go build/go build xxx.go and executed the generated binary file

Test:

  1. execute go test xxx_test.go or go *.go to test 1 file/folder
  2. in root folder, go test ./... to test all sub folders. Issue: it will fail if any folder has c/cpp files. Use CGO_ENABLED=0 go test ./... if this happen.

How to debug Python, Go and Node.js with breakpoints

Select the file in VS code, then select the cooresponding config in Debug panel to launch.

Build and Debug C++ (experimental)

Take LeetCodeTests/1-twoSum.cpp as an example.

  • in terminal, type g++ -g 1-twoSum.cpp, then a.out (default name) will be generated.
  • select this file in VS code, then choose C++: currentFile_build-debug in Debug panel to build+launch.

.vscode/launch.json or tasks.json are for macOS, please read https://code.visualstudio.com/docs/languages/cpp to modify the cpp part of them if yours OS is not macOS.

issue

  • need a framework to test all

C#

Installation

Follow https://docs.microsoft.com/zh-tw/dotnet/core/tutorials/with-visual-studio-code to install .NET Core SDK and VSCode extension.

Then dotnet restore to install project dependencies.

Dev

Make your classes like LeetCodeTests/Solution1.cs, rules:

  1. class name is the same as file name.
  2. no duplicate file names.
  3. write your test case in test_solution function.
  4. (optional) add [TestClass] and [TestMethod] for run_all_tests runner.

Debug

  • select this file in VS code, then choose .NET Core: Current File in Debug panel to build+launch.

Run all tests at once

  • execute dotnet test to run all tests function which have [TestMethod]

The current C# namespace defined in the project is not aligned with the folder structure

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.