Tested in Mac OS X: super == command
Open/Goto
- super+t: go to file
- super+ctrl+p: go to project
- super+r: go to methods
| // "def a" and "def c" are methods | |
| // methods are executed for every separate call | |
| // "val b" val so it will be executed only in the beginning and after that for every call the stored value will be used | |
| object argh { | |
| def a = { | |
| println("a") | |
| 1 |
| public class Lamps{ | |
| private boolean[] columns, rows, diagonalsLeft, diagonalsRight; | |
| public Lamps(int size, int[][] lamps){ | |
| this.columns = new boolean[size]; | |
| this.rows = new boolean[size]; | |
| this.diagonalsLeft = new int[(size) * 2 - 2]; or (size - 1) * 2 + 1 | |
| this.diagonalsRight = new int[(size) * 2 - 2]; | |
| public class Lamps{ | |
| private boolean[] columns, rows, diagonalsLeft, diagonalsRight; | |
| public Lamps(int size, int[][] lamps){ | |
| this.columns = new boolean[size]; | |
| this.rows = new boolean[size]; | |
| this.diagonalsLeft = new int[(size) * 2 - 2]; or (size - 1) * 2 + 1 | |
| this.diagonalsRight = new int[(size) * 2 - 2]; | |
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
###Array ####Definition:
| Collections.sort(sList, (p1, p2) ->p2.getDOB().compareTo(p1.getDOB())); |
| public class Solution { | |
| // you need to treat n as an unsigned value | |
| public static int hammingWeight(int n) { | |
| int count = 0; | |
| while(n!=0) { | |
| int check = n & 1; | |
| count = count + check; | |
| n = n>>>1; // zero filled right shift, eventually the no. "n" will become zero | |
| } | |
| return count; |
| // recursive | |
| public class Solution { | |
| int goal; | |
| double min = Double.MAX_VALUE; | |
| public int closestValue(TreeNode root, double target) { | |
| helper(root, target); | |
| return goal; | |
| } | |