Some other coding problems in my inteviews
- reverse a string
- judge if a string is the substring of another string
- Hanoi tower
- use two stacks to implement a queue (pseudo code), https://leetcode.com/problems/implement-stack-using-queues/
Some questions in my interviews
- time complexity of merge sort
- what is the quickest search
- what is the worse case of hash table
- mouse maze, similar to LeetCode-490 The Maze (medium): https://leetcode.com/articles/the-maze/
- TicTacToe (LeetCode, my AI side project and React official site)
Some other interesting problems
- (Meta string) Checking if two strings contain the same characters regardless of order
- Regular Expression Puzzle: http://jimbly.github.io/regex-crossword
- easy(12): https://leetcode.com/list/1emvu11
- medium(12): https://leetcode.com/list/1emw747
- hard(12): https://leetcode.com/list/1emdws5
12
in easy(12)
means that the first 12 problems in the list are in the first 200 leetcode problems which are used frequently.
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
two pointer method (caterpillar method), e.g:
- https://app.codility.com/programmers/lessons/15-caterpillar_method/
- https://leetcode.com/articles/two-pointer-technique/
- https://www.geeksforgeeks.org/find-number-of-triangles-possible/
Sometimes it is used in linked-list problems.
Install:
- yarn install
Test:
- yarn test (find all
*.test.js
in the root folder) - yarn test specific_folder (only that folder)
Todo:
- (breakpoint) debugging while using Jest
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)
Run:
- in each folder, execute
go build
/go build xxx.go
and executed the generated binary file
Test:
- execute
go test xxx_test.go
orgo *.go
to test 1 file/folder - in root folder,
go test ./...
to test all sub folders. Issue: it will fail if any folder has c/cpp files. UseCGO_ENABLED=0 go test ./...
if this happen.
Select the file in VS code, then select the cooresponding config in Debug panel to launch.
Take LeetCodeTests/1-twoSum.cpp
as an example.
in terminal, typeg++ -g 1-twoSum.cpp
, thena.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
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:
- class name is the same as file name.
- no duplicate file names.
- write your test case in
test_solution
function. - (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