Skip to content

Commit dbb80ef

Browse files
committed
refactor: refactor
refactor package names Signed-off-by: dk <workplace.davidkariuki@gmail.com>
1 parent dcec5a0 commit dbb80ef

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

app/src/main/java/AceTheJavaCodingInterview/data_structures/array/Permutations.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* <p>{1, 2, 3} {1, 3, 2} {2, 1, 3} {2, 3, 1} {3, 1, 2} {3, 2, 1}
1010
* <p>If a set has n distinct elements it will have n! n! permutations.
1111
* @note Solution This problem follows the Subsets pattern ({@link
12-
* AceTheJavaCodingInterview.module2_data_structures.array.Subset}) and, we can follow a similar
13-
* Breadth First Search (BFS) approach. However, unlike Subsets, every permutation must contain
14-
* all the numbers.
12+
* AceTheJavaCodingInterview.data_structures.array.Subset}) and, we can follow a similar Breadth
13+
* First Search (BFS) approach. However, unlike Subsets, every permutation must contain all the
14+
* numbers.
1515
* <p>Let’s take the example-1 mentioned above to generate all the permutations. Following a BFS
1616
* approach, we will consider one number at a time:
1717
* <p>1. If the given set is empty then we have only an empty permutation set: []

app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SubArraysWithProductLessThanTarget.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
* @note Solution - This problem follows the Sliding Window and the Two Pointers pattern and shares
1515
* similarities with Triplets with Smaller Sum
1616
* <p>({@link
17-
* AceTheJavaCodingInterview.module2_data_structures.array.TripletsWithSmallerSum_ReturnCount},
18-
* {@link
19-
* AceTheJavaCodingInterview.module2_data_structures.array.TripletsWithSmallerSum_ReturnList})
20-
* with two differences:
17+
* AceTheJavaCodingInterview.data_structures.array.TripletsWithSmallerSum_ReturnCount}, {@link
18+
* AceTheJavaCodingInterview.data_structures.array.TripletsWithSmallerSum_ReturnList}) with two
19+
* differences:
2120
* <p>In this problem, the input array is not sorted. Instead of finding triplets with sum less
2221
* than a target, we need to find all sub-array having a product less than the target. The
2322
* implementation will be quite similar to Triplets with Smaller Sum.

app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletSumCloseToTarget.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
* of the triplet. If there are more than one such triplet, return the sum of the triplet with
99
* the smallest sum.
1010
* @note Solution - This problem follows the Two Pointers pattern and is quite similar to Triplet
11-
* Sum to Zero({@link
12-
* AceTheJavaCodingInterview.module2_data_structures.array.TripletSumToZero}).
11+
* Sum to Zero({@link AceTheJavaCodingInterview.data_structures.array.TripletSumToZero}).
1312
* <p>We can follow a similar approach to iterate through the array, taking one number at a
1413
* time. At every step, we will save the difference between the triplet and the target number,
1514
* so that in the end, we can return the triplet with the closest sum.

app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletSumToZero.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
* unique triplets whose sum is equal to zero.
1515
* @solution Solution - This problem follows the Two Pointers pattern and shares similarities with
1616
* Pair with Target Sum ({@link
17-
* AceTheJavaCodingInterview.module2_data_structures.array.PairWithTargetSum}). A couple of
18-
* differences are that the input array is not sorted and instead of a pair we need to find
19-
* triplets with a target sum of zero.
17+
* AceTheJavaCodingInterview.data_structures.array.PairWithTargetSum}). A couple of differences
18+
* are that the input array is not sorted and instead of a pair we need to find triplets with a
19+
* target sum of zero.
2020
* <p>To follow a similar approach, first, we will sort the array and then iterate through it
2121
* taking one number at a time. Let’s say during our iteration we are at number ‘X’, so we need
2222
* to find ‘Y’ and ‘Z’ such that X + Y + Z == 0. At this stage, our problem translates into
2323
* finding a pair whose sum is equal to -X (as from the above equation Y + Z == -X).
2424
* <p>
2525
* <p>Another difference from Pair with Target Sum({@link
26-
* AceTheJavaCodingInterview.module2_data_structures.array.PairWithTargetSum}) is that we need
27-
* to find all the unique triplets. To handle this, we have to skip any duplicate number. Since
28-
* we will be sorting the array, so all the duplicate numbers will be next to each other and are
29-
* easier to skip.
26+
* AceTheJavaCodingInterview.data_structures.array.PairWithTargetSum}) is that we need to find
27+
* all the unique triplets. To handle this, we have to skip any duplicate number. Since we will
28+
* be sorting the array, so all the duplicate numbers will be next to each other and are easier
29+
* to skip.
3030
* @note Time complexity - Sorting the array will take O(N * logN). The searchPair() function will
3131
* take O(N). As we are calling searchPair() for every number in the input array, this means
3232
* that overall searchTriplets() will take O(N * logN + N^2), which is asymptotically equivalent

app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletsWithSmallerSum_ReturnList.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* is less than the target: [-1, 1, 4], [-1, 1, 3], [-1, 1, 2], [-1, 2, 3]
1515
* @note Solution - This problem follows the Two Pointers pattern and shares similarities with
1616
* Triplet Sum to Zero ({@link
17-
* AceTheJavaCodingInterview.module2_data_structures.array.TripletSumToZero}). The only
18-
* difference is that, in this problem, we need to find the triplets whose sum is less than the
19-
* given target. To meet the condition i != j != k we need to make sure that each number is not
20-
* used more than once.
17+
* AceTheJavaCodingInterview.data_structures.array.TripletSumToZero}). The only difference is
18+
* that, in this problem, we need to find the triplets whose sum is less than the given target.
19+
* To meet the condition i != j != k we need to make sure that each number is not used more than
20+
* once.
2121
* <p>Following a similar approach, first, we can sort the array and then iterate through it,
2222
* taking one number at a time. Let’s say during our iteration we are at number ‘X’, so we need
2323
* to find ‘Y’ and ‘Z’ such that X + Y + Z < target X+Y+Z<target . At this stage, our problem

0 commit comments

Comments
 (0)