Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7834491

Browse files
refactoring
1 parent b0c0302 commit 7834491

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

‎src/main/java/ir/sk/adt/datastructure/linklist/DoubleEndedList.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public T peakFirst() {
104104

105105
public void displayList() {
106106
System.out.print("List (first-->last): ");
107-
SinglyLink current = head; // start at beginning
107+
SinglyLink<T> current = head; // start at beginning
108108
while (current != null) // until end of list,
109109
{
110110
current.displayLink(); // print data

‎src/main/java/ir/sk/adt/queue/circularqueue/ArrayCircularQueue.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class ArrayCircularQueue<T> implements Queue<T>, Iterable<T> {
3333
// there are another way to calculate front and rear.
3434
// 1. front = start, rear = start + size
3535
// 2. to how two pointer, front, rear
36+
// in this implementation, use [inclusive] for both front and rear
3637
// front
3738
private int start;
3839
private int size;
@@ -98,6 +99,7 @@ public String toString() {
9899
return s;
99100
}
100101

102+
@Override
101103
public Iterator<T> iterator() {
102104
return new CircularQueueIterator();
103105
}

‎src/main/java/ir/sk/algorithm/array/ArrayAlgorithms.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,18 @@ public static boolean checkPossibility(int[] arr) {
234234
* The best solution is to use XOR. XOR of all array elements gives us the number with a single occurrence. The idea is based on the following two facts.
235235
* a) XOR of a number with itself is 0.
236236
* b) XOR of a number with 0 is number itself.
237+
*
238+
* Let us consider the above example.
239+
* Let ^ be xor operator as in C and C++.
240+
*
241+
* res = 7 ^ 3 ^ 5 ^ 4 ^ 5 ^ 3 ^ 4
242+
*
243+
* Since XOR is associative and commutative, above
244+
* expression can be written as:
245+
* res = 7 ^ (3 ^ 3) ^ (4 ^ 4) ^ (5 ^ 5)
246+
* = 7 ^ 0 ^ 0 ^ 0
247+
* = 7 ^ 0
248+
* = 7
237249
*
238250
* @param array
239251
* @return

‎src/main/java/ir/sk/algorithm/linklist/LinkListAlgorithms.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class LinkListAlgorithms {
3838
@SpaceComplexity("O(1)")
3939
@Point("Using two Loop")
4040
@BruteForce
41-
public static void deleteDuplicatesByRunner(SinglyLink head) {
41+
public static void deleteDuplicates(SinglyLink head) {
4242
SinglyLink current = head;
4343
while (current != null) {
4444
SinglyLink runner = head;

‎src/main/java/ir/sk/helper/pattern/BitwiseXORPattern.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
/**
44
* This technique uses the XOR operator to manipulate bits to solve problems.
5+
* a) XOR of a number with itself is 0.
6+
* b) XOR of a number with 0 is number itself.
57
*
68
* Created by sad.kayvanfar on 6/12/2021.
79
*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /