Some strategy learning from leetCode
C++ 2d array Better use a vector(don’t need to consider allocator)
1 2 3 4 int row = 10; int col = 10; int init = 1; vector<vector <int>> memos(row, vector<int>(col, init)) // init can ignore 1 2 3 4 5 int** a = new int*[rowCount]; for(int i = 0; i < rowCount; ++i) a[i] = new int[colCount]; delete ... Traverse a tree The tree structure:
Introduction of Lambda expression in C++ and how to use it.
What is Lambda in C++ Lambda expression is a new feature since c++11. It is used to create anonymous function object to simplify programming process.
How Lambda expressions are composed [capture](parameters) mutable -> return type {statement}
1 2 3 4 // ... #include <functional> // ... std:function<int(int, int)> add = [](int a, int b) -> int {return a+b;}; capture Capture variables from context.
What is crontab Crontab is a toll to schedule commands. You can run your terminal command on a specific schedule like run a command every day or every weekends.
Basic command crontab [-u user] {-l | -e | -r}
command utility -l list your cron job -r remove your cron job -e edit your cron job -u specific a user How to schedule a command Cron job looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of month (1 - 31) # │ │ │ ┌───────────── month (1 - 12) # │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday to Saturday; # │ │ │ │ │ 7 is also Sunday on some systems) # │ │ │ │ │ # │ │ │ │ │ # * * * * * command_to_execute # export date into a file every minutes * * * * * date >> ~/Desktop/test.
DFS & BFS are two basic algorithms to traverse a graph(or a tree). DFS is Deep-first search and BFS is Breath-first search.
Basic idea The idea behind two algorithms are identical but use different auxiliary data structure. DFS use stack and BFS use Queue.
First, Every node have a mark to identify is already be visited or not(it could be a list or an attribute in node).
Second, Push the start point into the auxiliary data structure and loop until structure is empty.
What is millerRabin algorithm The Miller–Rabin primality test or Rabin–Miller primality test is a primality test: an algorithm which determines whether a given number is prime, similar to the Fermat primality test and the Solovay–Strassen primality test. It was first discovered by Russian mathematician M. M. Artjuhov in 1967.[1] Gary L. Miller rediscovered it in 1976; Miller’s version of the test is deterministic, but its correctness relies on the unproven extended Riemann hypothesis.
What is makefile. How to write a makefile.
Ref: https://opensource.com/article/18/8/what-how-makefile
What is makefile A makefile is a file containing a set of directives used by a make build automation tool to generate a target/goal.
You may have used make to compile a program from source code.
How to write makefile To summarize, below is the syntax of a typical rule:
1 2 target: prerequisites <TAB> recipe As an example, a target might be a binary file that depends on prerequisites (source files).
Some keyboards shortcuts when using safari
Navigating Webpages Use arrow keys to go up and down.
Use Option+up/down or Shift+Space / Space to scroll quickly.
Use Command+up/down goto the top & button.
Open Pages in Tabs Use Command+T to open a new Tab.
Use Shift+Command+Left/right arrow or Control+Tab / Control+Shift+Tab to move from tab to tab.
Use Command+W to close current tab.
Use Command+Z to reopen a closed tab.
Use Command+Option+W to close all tabs expect current tab.
Zsh & Bash Since MacOs 10.15(Catalina). The default shell switch from bash to zsh. It is hard to say which one is better however Zsh has been used more widely than bash especially from Linux user.
Zsh The Z shell (also known as zsh) is a Unix shell that is built on top of bash (the default shell for macOS (Before MacOs Catalina)) with additional features. It’s recommended to use zsh over bash.
Basic Documentation: https://erlang.org/doc/search/
Functional language Erlang is a functional language. Code need compile and running line by line.
Every line need finish by a .. like: A = 1..
Module Every erlang file will consider as a module. You console will compile all module you want.
You have to add -module(<filename>). into first line. Module should be same with filename without suffix.
In erl console, run c(<filename>). to compile it. Run a function is like: <moduleName>: <functionName>(.
Extension Reference https://letswp.io/remote-development-visual-studio-code-amazon-ec2/