. - Any Character Except New Line
\d - Digit (0-9)
\D - Not a Digit (0-9)
\w - Word Character (a-z, A-Z, 0-9, _)
\W - Not a Word Character
\s - Whitespace (space, tab, newline)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// node.left -> node.right -> node | |
public void postorder(TreeNode root) { | |
Stack<Integer> stack1 = new Stack<>(); | |
Stack<Integer> stack2 = new Stack<>(); | |
stack1.push(root); | |
TreeNode current; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// node.left -> node -> node.right | |
public void inorder(TreeNode root) { | |
Stack<Integer> stack = new Stack<>(); | |
TreeNode current = root; | |
while (!stack.empty() || current != null) { | |
if (current != null) { | |
stack.push(current); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Preorder traversal: node -> node.left -> node.right | |
public void preorder(TreeNode root) { | |
Stack<TreeNode> stack = new Stack<>(); | |
TreeNode current = root; | |
while (stack.size > 0 || current != null) { | |
if (current != null) { | |
visit(current); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Lambda | |
Syntax: ```lambda arguments: expression``` | |
__Example__ | |
``` | |
# Regular way of creating a function | |
def add(x, y): | |
return x+y | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
git commit -m "title" -m "longer descriptions" | |
# or | |
git commit # an editor will be opened and you will be able to type your commit title and descriptions there | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
git config --global core.editor vim|emacs|nano | |
# Add flag --wait for your favorite editor in order to tell git | |
# to wait until I quit atom for the action to be completed | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
# Add the missing files from the previous commit | |
git add missing-file.txt | |
# Modify the last commit with new file added and/or new commit message | |
git commit --amend | |
``` | |
`git commit --amend` can only be used when you forgot files from the last commit. |