This file contains hidden or 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
| var numbers = {one: 1, two: 2, three: 3, four: 4}; | |
| Object.keys(numbers).forEach(function(key){ | |
| var value = numbers[key]; | |
| doSomethingWith(value); | |
| /* For example, key == "one" and value == 1 */ | |
| }); |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | |
| <meta name="description" content=""> | |
| <meta name="author" content=""> | |
| <link rel="icon" href="http://getbootstrap.com/favicon.ico"> |
This file contains hidden or 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
| keyword user:64lines |
This file contains hidden or 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 --amend |
This file contains hidden or 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
| public ArrayList<ArrayList<Integer>> permute(int[] num) { | |
| ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>(); | |
| //start from an empty list | |
| result.add(new ArrayList<Integer>()); | |
| for (int i = 0; i < num.length; i++) { | |
| //list of list in current iteration of the array num | |
| ArrayList<ArrayList<Integer>> current = new ArrayList<ArrayList<Integer>>(); | |
| for (ArrayList<Integer> l : result) { |
This file contains hidden or 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
| public class QuickSort { | |
| public static void main(String[] args) { | |
| int[] x = { 9, 2, 4, 7, 3, 7, 10 }; | |
| System.out.println(Arrays.toString(x)); | |
| int low = 0; | |
| int high = x.length - 1; | |
| quickSort(x, low, high); | |
| System.out.println(Arrays.toString(x)); |
This file contains hidden or 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
| toCharArray() //get char array of a String | |
| charAt(int x) //get a char at the specific index | |
| length() //string length | |
| length //array size | |
| substring(int beginIndex) | |
| substring(int beginIndex, int endIndex) | |
| Integer.valueOf()//string to integer | |
| String.valueOf()/integer to string | |
| Arrays.sort() //sort an array | |
| Arrays.toString(char[] a) //convert to string |
This file contains hidden or 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
| public static long fib(int n) { | |
| if (n <= 1) return n; | |
| else return fib(n-1) + fib(n-2); | |
| } |
This file contains hidden or 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
| Arrays.binarySearch(Object[] a, Object key); |
This file contains hidden or 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
| import java.util.*; | |
| Scanner scanner = new Scanner(System.in); | |
| String myString = scanner.next(); | |
| int myInt = scanner.nextInt(); | |
| scanner.close(); | |
| System.out.println("myString is: " + myString); | |
| System.out.println("myInt is: " + myInt); |