|
4 | 4 |
|
5 | 5 | > *First completed : May 29, 2024*
|
6 | 6 | >
|
7 |
| -> *Last updated : July 01, 2024* |
| 7 | +> *Last updated : July 03, 2024* |
8 | 8 |
|
9 | 9 |
|
10 | 10 | ------
|
|
18 | 18 |
|
19 | 19 | *To see the question prompt, click the title.*
|
20 | 20 |
|
| 21 | +> ``` |
| 22 | +> Notes |
| 23 | +> Negation of XOR is Biconditional |
| 24 | +> i.e. p <-> q |
| 25 | +> (p -> q) and (q -> p) |
| 26 | +> (!p or q) and (!q or p) |
| 27 | +> (!p and !q) or (p and q) |
| 28 | +> p == q |
| 29 | +> |
| 30 | +> |
| 31 | +> 1^0 --> 1 --> --> 1^0 --> 1 |
| 32 | +> 1^1 --> 0 --> --> 0^1 --> 1 |
| 33 | +> 0^0 --> 0 --> --> 0^0 --> 0 |
| 34 | +> 0^1 --> 1 --> --> 1^1 --> 0 |
| 35 | +> |
| 36 | +> XORing by the same value again reverses the result! |
| 37 | +> |
| 38 | +> Since 0 <= i < j <= k < arr.len --> k-i+1 >= 2 |
| 39 | +> |
| 40 | +> If two arrays XOR together to get 0, then the two individual sections should have |
| 41 | +> an XOR that equal each other. |
| 42 | +> |
| 43 | +> That is, XOR(arr1) == XOR(arr2) so that XOR(arr1, arr2) == 0 |
| 44 | +> |
| 45 | +
|
| 46 | +------ |
| 47 | +
|
21 | 48 | ## Solutions
|
22 | 49 |
|
23 | 50 | - [m1442 Daily.py](<../my-submissions/m1442 Daily.py>)
|
24 | 51 | ### Python
|
25 | 52 | #### [m1442 Daily.py](<../my-submissions/m1442 Daily.py>)
|
26 | 53 | ```Python
|
27 |
| -''' Notes |
28 |
| - Negation of XOR is Biconditional |
29 |
| - i.e. p <-> q |
30 |
| - (p -> q) and (q -> p) |
31 |
| - (!p or q) and (!q or p) |
32 |
| - (!p and !q) or (p and q) |
33 |
| - p == q |
34 |
| -
|
35 |
| -
|
36 |
| - 1^0 --> 1 --> --> 1^0 --> 1 |
37 |
| - 1^1 --> 0 --> --> 0^1 --> 1 |
38 |
| - 0^0 --> 0 --> --> 0^0 --> 0 |
39 |
| - 0^1 --> 1 --> --> 1^1 --> 0 |
40 |
| -
|
41 |
| - XORing by the same value again reverses the result! |
42 |
| -
|
43 |
| - Since 0 <= i < j <= k < arr.len --> k-i+1 >= 2 |
44 |
| -
|
45 |
| - If two arrays XOR together to get 0, then the two individual sections should have |
46 |
| - an XOR that equal each other. |
47 |
| -
|
48 |
| - That is, XOR(arr1) == XOR(arr2) so that XOR(arr1, arr2) == 0 |
49 |
| -''' |
50 |
| - |
51 | 54 | class Solution:
|
52 | 55 | def countTriplets(self, arr: List[int]) -> int:
|
53 | 56 | counter = 0
|
|
0 commit comments