Recursion
Special Binary String public String makeLargestSpecial(String s) { List<String> list = new ArrayList<>(); int count = 0, i = 0, j = 0; // splits s into as many special stri...
Special Binary String public String makeLargestSpecial(String s) { List<String> list = new ArrayList<>(); int count = 0, i = 0, j = 0; // splits s into as many special stri...
Transformation String Transforms Into Another String public boolean canConvert(String str1, String str2) { if (str1.equals(str2)) { return true; } Map<Character, Character...
Zigzag Iterator public class ZigzagIterator { private Queue<Iterator<Integer>> q; public ZigzagIterator(List<Integer> v1, List<Integer> v2) { q = new Linke...
Read N Characters Given Read4 II - Call multiple times public class Solution extends Reader4 { private char[] buff = new char[4]; private int p = 0; private int count = 0; // count of...
Min Stack stack and minStack Max Stack Two stacks Double linked list + TreeMap Stack + Heap + Set private Deque<int[]> st = new LinkedList<>(); // {element, id of the elemen...
Chunked Transfer Encoding Chunked transfer encoding: HTTP/1.1 Encode and Decode Strings private String toCount(String s) { int length = 4; // 4 chunks char[] bytes = new char[length]; ...
In this type of problem, we linear scan the elements one by one, and use dp[i] to store the state at a certain position. The DP array (1D) can usually be reduced to a DP variable (0D). The general...
Fundamentals Topological sorting: In computer science, a topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge uv from...
Insert Interval vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) { int n = intervals.size(); vector<vector<i...
Math Chalkboard XOR Game public boolean xorGame(int[] nums) { int xor = 0; for (int num : nums) { xor ^= num; } // when the number of elements are even // not all ele...