├── ---code-template-codechef.js
├── .gitattributes
├── .gitignore
├── BIT-fenwick-tree-explanation.md
├── BIT-fenwick-tree.cpp
├── BITS-AND-BYTES.cpp
├── BIT_fenwick_tree_explanation.md
├── MATHEMATICS.MD
├── PRINT-EVERYTHING.cpp
├── README.md
├── RMQ-using-NxN.cpp
├── RMQ-using-cartesian-tree.cpp
├── RMQ-using-sparse-table.cpp
├── RangeMaxQuery-using-segment-tree.cpp
├── avl-self-balancing-tree.cpp
├── basics-a-pow-n.js
├── basics-fact-n.js
├── basics-fibo-n.js
├── basics-gcd-euclidean-algorithm.cpp
├── basics-merge-sort-top-down-recursive.cpp
├── basics-performance-timers.js
├── basics-quicksort-lomuto.cpp
├── cartesian-tree.cpp
├── convex-hull-jarvis.js
├── gccp.bat
├── javascript-deque.js
├── js-backtracking-knight-movement.js
├── js-math-nCr.js
├── js-math-pascal-triangle-simplex-numbers
├── js-min-heap.js
├── js-util-binary-search.js
├── js-util-bits.js
├── js-util-combinations-without-repetition.js
├── js-util-permutation.js
├── js-util-power-set-on-array.js
├── longest-increasing-sequence.cpp
├── main.js
├── minmaxsum.cpp
├── my-statistics-notes.MD
├── nbproject
├── private
│ ├── private.properties
│ └── private.xml
├── project.properties
└── project.xml
├── old-my-datastructures-in-c
├── .gitattributes
├── .gitignore
├── BST.c
├── BST.h
├── ReadMe.txt
├── ReadMe_binarytree_types.txt
├── ReadMe_tree_types.txt
├── _main.c
├── array.c
├── array.h
├── binaryheap.c
├── binaryheap.h
├── binarytree.c
├── binarytree.h
├── common.c
├── common.h
├── datastructures.sln
├── datastructures.vcxproj
├── datastructures.vcxproj.filters
├── datastructures.vcxproj.user
├── linkedlist.c
├── linkedlist.h
├── llqueue.c
├── llqueue.h
├── queue.c
├── queue.h
├── queue_circular_buffer.c
├── queue_circular_buffer.h
├── stack.c
└── stack.h
├── package.json
├── primes-offline.cpp
├── sa-lcp-working-to-post.cpp
├── segment-tree-cleaned-up.cpp
├── square-root-decomposition-min-and-second-min.cpp
├── trie-the-dictionary.cpp
├── y-BST.txt
├── y-HEAP.txt
└── y-primality.txt
/---code-template-codechef.js:
--------------------------------------------------------------------------------
1 | // NODEJS (Node 7.4.0) common template for everyone
2 |
3 | // NOTE: This is common code - MUST be there for all problems below
4 | let inputStr = "";
5 | const _toInt = (x) => +x;
6 | process.stdin.resume();
7 | process.stdin.setEncoding("utf8");
8 | process.stdin.on("data", (chunk) => (inputStr += chunk));
9 |
10 | // problem https://www.codechef.com/problems/START01
11 | process.stdin.on("end", () => {
12 | console.log(+inputStr);
13 | });
14 |
15 | // problem https://www.codechef.com/problems/FLOW001
16 | process.stdin.on("end", () => {
17 | const inputLinesArr = inputStr.split("\n");
18 |
19 | let T = +inputLinesArr[0]; // # of tests
20 |
21 | for (let i = 1; i <= T; i++) {
22 | let [a, b] = inputLinesArr[i].split(" ").map(_toInt); // each test case
23 |
24 | console.log(a + b);
25 | }
26 | });
27 |
28 | // problem https://www.codechef.com/problems/INTEST
29 | process.stdin.on("end", () => {
30 | const inputLinesArr = inputStr.split("\n");
31 |
32 | let [n, k] = inputLinesArr[0].split(" ").map(_toInt);
33 |
34 | let count = 0;
35 |
36 | for (let i = 1; i <= n; i++) {
37 | let ti = +inputLinesArr[i];
38 | if (ti % k === 0) {
39 | count++;
40 | }
41 | }
42 |
43 | console.log(count);
44 | });
45 |
46 | // problem https://www.codechef.com/problems/HS08TEST
47 | process.stdin.on("end", () => {
48 | let [a, b] = inputStr.split(" ").map(_toInt); // each test case
49 |
50 | let res = b - a - 0.5;
51 | if (a % 5 === 0 && res >= 0) {
52 | // all good
53 | } else {
54 | res = b;
55 | }
56 |
57 | console.log(res);
58 | });
59 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 | /main/main/nbproject/private/
49 | /main/main/build/
50 | /main/build/
51 | /main/nbproject/private/
--------------------------------------------------------------------------------
/BIT-fenwick-tree-explanation.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Sources:
4 | https://en.wikipedia.org/wiki/Fenwick_tree
5 | http://www.geeksforgeeks.org/binary-indexed-tree-range-update-range-queries/
6 | https://cs.stackexchange.com/questions/33014/range-update-range-query-with-binary-indexed-trees
7 |
8 |
9 | =====
10 | Logic for Point & Range update
11 | =====
12 | Since this is in progress, if you already forked this repository, you would need to merge new changes from here to your forked ones in future if you need new changes. Obviously, if you liked this, click the Star above will help others find this page.
13 | =====
14 |
15 | ====================
16 | > Section 1
17 | ====================
18 | Point Update
19 | ====================
20 | i 0 1 2 3 4 5 6 7 8 9
21 | A[i] 0 0 0 0 0 0 0 0 0 0
22 | SumTill[i] 0 0 0 0 0 0 0 0 0 0
23 | ___
24 | Now +5 to [3]
25 | ___
26 | i 0 1 2 3 4 5 6 7 8 9
27 | A[i] 0 0 0 0 +5 0 0 0 0 0
28 | SumTill[i] 0 0 0 0 5 5 5 5 5 5
29 | ___
30 | In Point Update form:
31 | A[3] += +5
32 | BITarr[3] += +5 (and, +5 also proprates to other elements, acc to algorithm of BIT)
33 | ___
34 | In Point Update form (in general form)
35 | A[i] += +V
36 | BITarr[i] += +V (and, +V also proprates to other elements, acc to algorithm of BIT)
37 | ___
38 |
39 |
40 |
41 | ====================
42 | > Section 2
43 | ====================
44 | Range Update
45 | ====================
46 | Assume
47 | ___
48 | i 0 1 2 3 4 5 6 7 8 9
49 | A[i] 0 0 0 0 0 0 0 0 0 0
50 | SumTill[i] 0 0 0 0 0 0 0 0 0 0
51 | ___
52 | Now +5 to [3 to 7]
53 | ___
54 | i 0 1 2 3 4 5 6 7 8 9
55 | A[i] 0 0 0 5 5 5 5 5 0 0
56 | SumTill[i] 0 0 0 5 10 15 20 25 25 25
57 | ___
58 | Here
59 | ___
60 | SumTill[i] 0 0 0 5 10 15 20 25 25 25
61 | is
62 | i 0 1 2 3 4 5 6 7 8 9
63 | X1[i] *0 0 0 5 5 5 5 5 0 0
64 | X2[i] +0 0 0 10 10 10 10 10 -25 -25
65 | .
66 | > Tranformation formula
67 | > Where, SumTill[i] = i * X1[i] - X2[i], This will not be used anywhere below, but is key to derive BIT form
68 | .
69 | ___
70 | Here
71 | ___
72 | i 0 1 2 3 4 5 6 7 8 9
73 | X1[i] *0 0 0 5 5 5 5 5 0 0
74 | X2[i] +0 0 0 10 10 10 10 10 -25 -25
75 | ___
76 | looks like:
77 | ___
78 | i 0 1 2 3 4 5 6 7 8 9
79 | index names 3 7 7+1
80 | -------------------------------------------------------------
81 | BIT-like-form-X1 *0 0 0 +5 0 0 0 0 -5 0
82 | BIT-like-form-X2 +0 0 0 10 0 0 0 0 -35 0
83 | ___
84 |
85 | Above in Point Update form: (see above, Section 1)
86 | this is
87 | BITX1[3] = +5
88 | BITX1[7+1] = -5
89 | BITX2[3] = +10
90 | BITX2[7+1] = -35
91 | So, +5 to [3 to 7] came down to above.
92 | These above 4 formulas are for range_update(3,7,5).
93 | ___
94 |
95 | Exact above (in general form) looks like:
96 | ___
97 | index 0 1 2 3 4 5 6 7 8 9
98 | index names i j j+1
99 | -------------------------------------------------------------
100 | BIT-like-form-X1 *0 0 0 +V 0 0 0 0 -V 0
101 | BIT-like-form-X2 +0 0 0 (i-1)*V 0 0 0 0 -j*V 0
102 | ___
103 | Above in Point Update form (in general form): (see above, Section 1)
104 | this is
105 | ___
106 | (in general form)
107 | BITX1[i] += +V
108 | BITX1[j+1] += -V
109 | BITX2[i] += +(i-1)*V
110 | BITX2[j+1] += -j*V
111 | So, +V to [i to j] came down to above
112 | These above 4 formulas are for range_update(i,j,V).
113 |
114 | So, you will need two arrays of size A[],
115 | however update of range (i,j)
116 | should be logN for BITX1 &
117 | another logN for BITX2
118 | which is 2*logN, still O(logN), faster than O(N) updating all values of (i,j), so above 'Tranformation formula' is key
119 | ___
120 |
121 |
122 |
--------------------------------------------------------------------------------
/BITS-AND-BYTES.cpp:
--------------------------------------------------------------------------------
1 |
2 | void know_bits_and_bytes() {
3 |
4 | cout << left << setw(30) << "size of char: " << "-" << pow(2, 8 * sizeof(char) - 1) << " " << pow(2, 8 * sizeof(char) - 1) - 1 << endl;
5 | cout << left << setw(30) << "size of unsigned char: " << " " << 0 << " " << pow(2, 8 * sizeof(unsigned char)) - 1 << endl;
6 | cout << left << setw(30) << "size of short: " << "-" << pow(2, 8 * sizeof(short) - 1) << " " << pow(2, 8 * sizeof(short) - 1) - 1 << endl;
7 | cout << left << setw(30) << "size of unsigned short: " << " " << 0 << " " << pow(2, 8 * sizeof(unsigned short)) - 1 << endl;
8 | cout << left << setw(30) << "size of int: " << "-" << pow(2, 8 * sizeof(int) - 1) << " " << pow(2, 8 * sizeof(int) - 1) - 1 << endl;
9 | cout << left << setw(30) << "size of unsigned int: " << " " << 0 << " " << pow(2, 8 * sizeof(unsigned int)) - 1 << endl;
10 | cout << left << setw(30) << "size of long: " << "-" << pow(2, 8 * sizeof(long) - 1) << " " << pow(2, 8 * sizeof(long) - 1) - 1 << endl;
11 | cout << left << setw(30) << "size of unsigned long: " << " " << 0 << " " << pow(2, 8 * sizeof(unsigned long)) - 1 << endl;
12 | cout << left << setw(30) << "size of long long: " << "-" << pow(2, 8 * sizeof(long long) - 1) << " " << pow(2, 8 * sizeof(long long) - 1) - 1 << endl;
13 | cout << left << setw(30) << "size of unsigned long long: " << " " << 0 << " " << pow(2, 8 * sizeof(unsigned long long)) - 1 << endl;
14 | }
15 |
16 |
17 | /*
18 | hackerrank
19 | size of char: -128 127
20 | size of unsigned char: 0 255
21 | size of short: -32768 32767 // 3 X 10^4
22 | size of unsigned short: 0 65535 // 6 X 10^4
23 | size of int: -2.14748e+09 2.14748e+09 // 2 X 10^9
24 | size of unsigned int: 0 4.29497e+09 // 4 X 10^9
25 | size of long: -9.22337e+18 9.22337e+18 // 9 X 10^18
26 | size of unsigned long: 0 1.84467e+19 // 1 X 10^19
27 | size of long long: -9.22337e+18 9.22337e+18 // 9 X 10^18
28 | size of unsigned long long: 0 1.84467e+19 // 1 X 10^19
29 |
30 | // summary: long and long long are same on hackerrank --- so use (short, int, long) only for integers, signed or unsigned as required
31 |
32 | local machine/ laptop
33 | size of char: -128 127
34 | size of unsigned char: 0 255
35 | size of short: -32768 32767 // 3 X 10^4
36 | size of unsigned short: 0 65535 // 6 X 10^4
37 | size of int: -2.14748e+09 2.14748e+09 // 2 X 10^9
38 | size of unsigned int: 0 4.29497e+09 // 4 X 10^9
39 | size of long: -2.14748e+09 2.14748e+09 // 2 X 10^9
40 | size of unsigned long: 0 4.29497e+09 // 4 X 10^9
41 | size of long long: -9.22337e+18 9.22337e+18 // 9 X 10^18
42 | size of unsigned long long: 0 1.84467e+19 // 1 X 10^19
43 | */
44 |
--------------------------------------------------------------------------------
/BIT_fenwick_tree_explanation.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Sources:
4 | https://en.wikipedia.org/wiki/Fenwick_tree
5 | http://www.geeksforgeeks.org/binary-indexed-tree-range-update-range-queries/
6 | https://cs.stackexchange.com/questions/33014/range-update-range-query-with-binary-indexed-trees
7 |
8 |
9 | =====
10 | Logic for Point & Range update
11 | =====
12 | Since this is in progress, if you already forked this repository, you would need to merge new changes from here to your forked ones in future if you need new changes. Obviously, if you liked this, click the Star above will help others find this page.
13 | =====
14 |
15 | ====================
16 | > Section 1
17 | ====================
18 | Point Update
19 | ====================
20 | i 0 1 2 3 4 5 6 7 8 9
21 | A[i] 0 0 0 0 0 0 0 0 0 0
22 | SumTill[i] 0 0 0 0 0 0 0 0 0 0
23 | ___
24 | Now +5 to [3]
25 | ___
26 | i 0 1 2 3 4 5 6 7 8 9
27 | A[i] 0 0 0 0 +5 0 0 0 0 0
28 | SumTill[i] 0 0 0 0 5 5 5 5 5 5
29 | ___
30 | In Point Update form:
31 | A[3] += +5
32 | BITarr[3] += +5 (and, +5 also proprates to other elements, acc to algorithm of BIT)
33 | ___
34 | In Point Update form (in general form)
35 | A[i] += +V
36 | BITarr[i] += +V (and, +V also proprates to other elements, acc to algorithm of BIT)
37 | ___
38 |
39 |
40 |
41 | ====================
42 | > Section 2
43 | ====================
44 | Range Update
45 | ====================
46 | Assume
47 | ___
48 | i 0 1 2 3 4 5 6 7 8 9
49 | A[i] 0 0 0 0 0 0 0 0 0 0
50 | SumTill[i] 0 0 0 0 0 0 0 0 0 0
51 | ___
52 | Now +5 to [3 to 7]
53 | ___
54 | i 0 1 2 3 4 5 6 7 8 9
55 | A[i] 0 0 0 5 5 5 5 5 0 0
56 | SumTill[i] 0 0 0 5 10 15 20 25 25 25
57 | ___
58 | Here
59 | ___
60 | SumTill[i] 0 0 0 5 10 15 20 25 25 25
61 | is
62 | i 0 1 2 3 4 5 6 7 8 9
63 | X1[i] *0 0 0 5 5 5 5 5 0 0
64 | X2[i] +0 0 0 10 10 10 10 10 -25 -25
65 | .
66 | > Tranformation formula
67 | > Where, SumTill[i] = i * X1[i] - X2[i], This will not be used anywhere below, but is key to derive BIT form
68 | .
69 | ___
70 | Here
71 | ___
72 | i 0 1 2 3 4 5 6 7 8 9
73 | X1[i] *0 0 0 5 5 5 5 5 0 0
74 | X2[i] +0 0 0 10 10 10 10 10 -25 -25
75 | ___
76 | looks like:
77 | ___
78 | i 0 1 2 3 4 5 6 7 8 9
79 | index names 3 7 7+1
80 | -------------------------------------------------------------
81 | BIT-like-form-X1 *0 0 0 +5 0 0 0 0 -5 0
82 | BIT-like-form-X2 +0 0 0 10 0 0 0 0 -35 0
83 | ___
84 |
85 | Above in Point Update form: (see above, Section 1)
86 | this is
87 | BITX1[3] = +5
88 | BITX1[7+1] = -5
89 | BITX2[3] = +10
90 | BITX2[7+1] = -35
91 | So, +5 to [3 to 7] came down to above.
92 | These above 4 formulas are for range_update(3,7,5).
93 | ___
94 |
95 | Exact above (in general form) looks like:
96 | ___
97 | index 0 1 2 3 4 5 6 7 8 9
98 | index names i j j+1
99 | -------------------------------------------------------------
100 | BIT-like-form-X1 *0 0 0 +V 0 0 0 0 -V 0
101 | BIT-like-form-X2 +0 0 0 (i-1)*V 0 0 0 0 -j*V 0
102 | ___
103 | Above in Point Update form (in general form): (see above, Section 1)
104 | this is
105 | ___
106 | (in general form)
107 | BITX1[i] += +V
108 | BITX1[j+1] += -V
109 | BITX2[i] += +(i-1)*V
110 | BITX2[j+1] += -j*V
111 | So, +V to [i to j] came down to above
112 | These above 4 formulas are for range_update(i,j,V).
113 |
114 | So, you will need two arrays of size A[],
115 | however update of range (i,j)
116 | should be logN for BITX1 &
117 | another logN for BITX2
118 | which is 2*logN, still O(logN), faster than O(N) updating all values of (i,j), so above 'Tranformation formula' is key
119 | ___
120 |
121 |
122 |
--------------------------------------------------------------------------------
/MATHEMATICS.MD:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ====
5 | This Mathematics Notes is from khanacademy.org/math
6 | where I got Ramanujan in 60 actual days - possibly 3 hours of work everyday
7 |
8 | ====
9 | BODMAS is an acronym and it stands for Bracket, Of, Division, Multiplication, Addition and Subtraction.
10 | In certain regions,
11 | PEDMAS (Parentheses, Exponents, Division, Multiplication, Addition and Subtraction) is the synonym of BODMAS.
12 |
13 | ====
14 | non-statistical - single value like age
15 | statistical question - multiple values - need to gather info about 1+ items/people, etc.
16 |
17 | double number lines - show the ratio
18 | dot plot - most often/ frequent, helps finding median, more than x, max and specific - below x
19 | bar graph/histogram - helps finding more than x, less than (some are good, some dont tell)
20 | box & whiskers plot - helps finding median
21 |
22 | distribution
23 | left-tailed - decreasing towards left (approximate: skewed to the left: mean is to the left of median and mode)
24 | right-tailed - decreasing towards right (approximate: skewed to the right: mean is to the right of median and mode)
25 | approximately symmetrical - both left-tailed & right-tailed - median will be close to center
26 |
27 | for dot plot (only?) we can see below:
28 | outlier = an end element that is far to the right/left - isolated one data point (unusually low or unusually high)
29 | cluster = grouping of data, between two data points, from x to y, saying 100 to 200
30 | peak = most frequent data item
31 | gap = (no values)?
32 |
33 | mean (a+b+c+d)/4
34 | median mid element, OR average(2 mid elements)
35 | mode most often
36 | range = max - min
37 |
38 | . interquartile range (IQR)
39 | . sort asc
40 | . find median
41 | . IQR = lower half's median - upper half's median
42 |
43 | box plot
44 | min Q1 median Q3 max
45 | min lower quartile median upper quartile max
46 |
47 | range = max - min
48 | 4 = 15 - 11
49 | // 0? ??
50 | min median max
51 | 11? 13 15?
52 |
53 | |a - b| = |a| - |b|
54 | |a - b| = |b - a|
55 |
56 | . Mean absolute deviation (MAD)
57 | . find mean
58 | . average (abs each ele - mean)
59 |
60 | ====
61 | algebra
62 | variables
63 | expressions
64 | equations = a statement that two expressions are equal
65 | value of the variable that makes a true equation is called a solution to the equation
66 | we always have to do the same thing to both sides of an equation to keep it true
67 | Addition and subtraction are inverse operations
68 |
69 | inverse operation of addition is subtraction
70 | inverse operation of subtraction is addition
71 |
72 | Multiplication and division are inverse operations
73 | inverse operation of division is multiplication
74 | inverse operation of multiplication is division
75 |
76 | Inequalities show the relation between two expressions that are not equal.
77 |
78 | > open circle and arrow
79 | >= closed circle and arrow
80 |
81 | independent variable is a variable that represents a quantity that is being manipulated in an experiment
82 | dependent variable represents a quantity whose value depends on how the independent variable is manipulated
83 |
84 | ====
85 | 0 is neither -ve or +ve
86 | 0/n=0 where n != 0
87 | n/0=undefined
88 | 0/0=undefined
89 |
90 | 1*n = n
91 |
92 | 1*0 = 0
93 | 1*1 = 1
94 |
95 | n^1 = n
96 | n^0 = 1 where n != 0
97 | 0^n=0 where n != 0
98 | 0^0 = undefined
99 |
100 | ====
101 | 25% of 600 is 150
102 | 25% . 600 = 150
103 | percent . base = amount
104 |
105 | 10% = 10/100 = 1/10 = 0.1
106 |
107 | ~ approximately equal
108 |
109 | ====
110 | shares of stock = how much a person (shareholder) owns in a company
111 | profits (dividends) can be equal or not
112 |
113 | ====
114 | polyhedron
115 | polyhedra
116 | 3d shape
117 | flat surfaces
118 | straight edges
119 | Surface area is the amount of space covering the outside of a three-dimensional shape.
120 |
121 | ====
122 | TIPS for khanacademy.org/math
123 |
124 | use your calculator instead of given calculator - its a bit cramped
125 |
126 | How to work?
127 | instead of doing only arithmetic, OR geometry
128 | i would do 1st class, then 2nd class,
129 | this looks a bit slow but they are better in understanding many things at little bit each
130 |
131 | verify
132 | after each answer
133 | i verify in a different way
134 | if 2+4+5 is given
135 | first, i will add 2+4 then add 5 = 11
136 | for verification, i will add 4+5 then add 2 = 11
137 | if both are same, i will Check/ Submit
138 |
139 | viewed videos at
140 | X2 speed, possibly after viewing few videos
141 | 1st 1 or 2 videos are at 1.5 video speed rate
142 | later videos are at 2 video speed rate
143 |
144 | if its text box
145 | that does not give the symbols input
146 | then you can press ENTER to submit answer
147 |
148 | if from desktop
149 | you can view all videos at once, continuously
150 |
151 | From 6th grade the volume of video seems very slow
152 | GOOD PLUGIN
153 | I used Volume Booster extension of Chrome browser
154 | listen to video/audio sound a bit louder
155 | https://chrome.google.com/webstore/detail/volume-booster/ejkiikneibegknkgimmihdpcbcedgmpo/related
156 | BAD PLUGIN
157 | I installed another chrome extension
158 | https://chrome.google.com/webstore/detail/youtube-playback-speed-co/hdannnflhlmdablckfkjpleikpphncik/reviews?hl=en
159 | and went at 2.25 speed
160 | remembers speed 2.00 Options > Settings tab > 'Remember Playback Speed For All Videos'
161 | but 2.25 failed
162 | This failed as the points were not coming as usual
163 |
164 | ====
165 |
166 |
--------------------------------------------------------------------------------
/PRINT-EVERYTHING.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | void print() {
4 |
5 | printf("%c", 'c');
6 |
7 | cout << endl; // ok
8 | cout << "\n"; // better sometimes for performance
9 |
10 | cout << 'a' << "\n";
11 | cout << "abc" << "\n";
12 | cout << 1 << "\n";
13 |
14 | cout << "[" << 100 << "," << 200 << "]" << "\n";
15 |
16 | cout << setw(10) << 100 << "\n";
17 | cout << setw(10) << setfill('-') << 100 << "\n";
18 |
19 |
20 | string s1 = "hello";
21 | cout << s1 << "\n";
22 |
23 | stringstream output1;
24 | output1 << "hello" << "\n";
25 | output1 << "world" << "\n";
26 | cout << output1.str();
27 | }
28 |
29 |
30 | template
31 | void printA(T *A, size_t N, bool bNewLine = true) { // print A[]
32 | for (size_t i = 0; i < N; i++) {
33 | cout << A[i] << " ";
34 | }
35 | if (bNewLine) {
36 | cout << "\n";
37 | }
38 | }
39 |
40 | template
41 | void printVD(T c1, bool bNewLine = true) { // print vector, deque
42 | for (size_t i = 0; i < c1.size(); i++) {
43 | cout << c1[i] << " ";
44 | }
45 | if (bNewLine) {
46 | cout << "\n";
47 | }
48 | }
49 |
50 | template
51 | static void printVVDD(T vv1, bool bNewLine = true) { // print vector>, deque>
52 | for (size_t i = 0; i < vv1.size(); i++) {
53 | printVD(vv1[i], bNewLine);
54 | }
55 | if (bNewLine) {
56 | cout << "\n";
57 | }
58 | }
59 |
60 | template
61 | static void printM(const T &m1, bool bNewLine = true) { // print map
62 | for (auto kv1 : m1) {
63 | cout << kv1.first << " " << kv1.second << endl;
64 | }
65 | if (bNewLine) {
66 | cout << "\n";
67 | }
68 | }
69 |
70 |
71 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | Advanced DataStructures & Algorithms
3 |
4 | These were created while learning
5 | NOTE: The old ones could be more buggy :-). Please note to check before using these.
6 |
7 |
8 | # Run as below:
9 |
10 | Example:
11 | g++ quicksort_lomuto.cpp
12 |
13 |
14 | # Star or Fork
15 | If you like, click on Star or click on Fork to suggest changes
16 |
17 |
18 | # Some Useful links
19 |
20 | - Leetcode contest rating predictor - all contests : https://lccn.lbao.site/
21 | - Leetcode contest rating predictor - specific contest : https://lccn.lbao.site/predicted/weekly-contest-332
22 |
23 |
--------------------------------------------------------------------------------
/RMQ-using-NxN.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // beautiful code
3 | //
4 |
5 | #include // min
6 | #include
7 | #include // assert
8 | #include
9 | #include
10 | #include // deque
11 | #include // ifstream
12 | #include // greater
13 | #include // setw, setfill
14 | #include
15 | #include // numeric_limits
16 | #include