Skip to content

Commit 2d73410

Browse files
committed
chore: updated
1 parent 1b3226b commit 2d73410

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎README.md

+27
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
- [Quick Sort](#quick-sort)
5252
- [Why Quick sort is used in Array and Merge Sort in Linked List?](#why-quick-sort-is-used-in-array-and-merge-sort-in-linked-list)
5353
- [Mathematics & Stats You should know](#mathematics--stats-you-should-know)
54+
- [XOR operator](#xor-operator)
55+
- [Different Numbers can be solved by XOR](#different-numbers-can-be-solved-by-xor)
5456
- [How to initialize array of size n?](#how-to-initialize-array-of-size-n)
5557
- [How many zeros in 1 Billion](#how-many-zeros-in-1-billion)
5658
- [How many zeros in 1 Million](#how-many-zeros-in-1-million)
@@ -660,8 +662,33 @@ When Browser's are not using Merge sort they most of the time use Quick sort var
660662

661663
In Quick sort we do not create auxiliary arrays. Therefore, it is good choice for Array to use quick sort. However in merge sort we create 2 auxiliary arrays. Therefore, linked list is a good choice.
662664

665+
666+
663667
## Mathematics & Stats You should know
664668

669+
670+
### XOR operator
671+
672+
XOR represents the inequality function, i.e., the output is true if the inputs are not alike otherwise the output is false. A way to remember XOR is "must have one or the other but not both". XOR can also be viewed as addition modulo 2.
673+
674+
#### Different Numbers can be solved by XOR
675+
676+
Find how many different numbers in the array.
677+
678+
Input =[3, 5, 6, 3, 3 , 9, 5]
679+
680+
answer = 4
681+
682+
There are 4 values 3,5, 6,9.
683+
684+
```js
685+
x =0;
686+
array.forEach(num=> x ^= num);
687+
return x;
688+
```
689+
690+
`^=` [XOR assignment operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_XOR).
691+
665692
### How to initialize array of size n?
666693

667694
Example create an array containing numbers from 0 to 9.

0 commit comments

Comments
 (0)