APIs To Learn Flashcards
vLeast Integer
Integer.MIN_VALUE
Greatest Integer
Integer.MAX_VALUE
Greater of two numbers
Math.max(double, double)
add collection to other collection
::addAll(Collection c)
char[] from String
String::toCharArray
check if char is numeric
Character.isDigit(char)
Eulerian Path on Undirected Graph
Either every vertex has even degree
-or-
exactly two vertices have odd degree
Eulerian Circuit on Undirected Graph
Every vertex has an even degree
Eulerian circuit on directed graph
Every vertex has an equal in degree and out degree
Eulerian Path on Directed Graph
At most 1 vertex with one more out degree than in degree
- and -
at most 1 vertex with one more in degree than out degree
- and -
all other vertices have equal in and out degrees
number of chars in string
String::length()
get “bcde” from “abcde”
“abcde”.substring(1) // NOTE ALL LOWER CASE
get “bcd” from “abcde”
“abcde”.substring(1,4) // begin index is inclusive, end index is not inclusive NOTE ALL LOWER CASE
insert element into Set
Set.add(element)
Get any element from Set
Set::iterator::next
concrete implementation of stack
Stack
Boxed Object for char
Character
number of elements in list
List::size
sort int[] (and complexity)
Arrays.sort(int[] a), O(n log(n))
copy an int[]
Arrays.copyOf(int[] original, int newLength)
sort int[] range (and complexity)
Arrays.sort(int[] a, int fromIndex, int toIndex) O(n log(n)), fromIndex is inclusive, toIndex is exclusive
parse int value from char
Character.getNumericValue(c)
check if map has any key value mappings
Map::isEmpty
remove key value mapping from map
Map.remove(Object key)
put element in set
Set.add(Object o)
increment a maybe null map key with default
int count = m.getOrDefault(k, d);
m.put(k, count + 1);
or
m.compute(k, (k, count) -> count == null ? 1 : count+1);
int to String
String.valueOf(int n) or specific implementation Integer.toString(int n)
Data Structure that maintains unique elements with order
TreeSet
least element in TreeSet
treeSet::first
greatest element in TreeSet
treeSet::last
TreeSet least element strictly greater than the given element (or null if not exist)
treeSet.higher(E e)
TreeSet greatest element strictly less than the given element, or null if there is no such element.
treeSet.lower(E e)
Queue that maintains order based on Comparator
new PriorityQueue(Comparator comparator)
Comparator Signature
int compare(T o1, T o2) Returns: a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
Look at top of Stack without removing
Stack::peek
square root
Math.sqrt(double a)
raise to power
Math.pow(double a, double b)
Integer Comparator
Integer::compare