diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/ClassTemplate.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/ClassTemplate.java similarity index 69% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/ClassTemplate.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/ClassTemplate.java index d588c1f..7b9ec55 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/ClassTemplate.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/ClassTemplate.java @@ -4,14 +4,16 @@ *
* * @question Problem Statement - - * @example + * @example Example 1: + * @example Example 2: + * @example Example 3: * @note Solution - * @note Time Complexity - * @note Space Complexity - * @author David Kariuki - * @since /8/2022 + * @since /9/2022 */ -package AceTheJavaCodingInterview.module2_data_structures; +package AceTheJavaCodingInterview.data_structures; public class ClassTemplate { diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/FindMaximumInSlidingWindow.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/FindMaximumInSlidingWindow.java similarity index 95% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/FindMaximumInSlidingWindow.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/FindMaximumInSlidingWindow.java index b8bbde3..c5b9e6c 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/FindMaximumInSlidingWindow.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/FindMaximumInSlidingWindow.java @@ -11,9 +11,9 @@ * @author David Kariuki * @since 17/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; -import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils; +import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils; import java.util.ArrayDeque; import java.util.Deque; diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/FindTheSmallestCommonNumber.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/FindTheSmallestCommonNumber.java similarity index 86% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/FindTheSmallestCommonNumber.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/FindTheSmallestCommonNumber.java index 1410242..5eef48b 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/FindTheSmallestCommonNumber.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/FindTheSmallestCommonNumber.java @@ -3,14 +3,14 @@ * *
* - * @question Given three integer arrays sorted in ascending order, return the smallest number found - * in all three arrays. + * @question Given three integer array sorted in ascending order, return the smallest number found + * in all three array. * @author David Kariuki * @since 18/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; -import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils; +import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils; public class FindTheSmallestCommonNumber { diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/MaximumSumSubarrayOfSizeK.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/MaximumSumSubarrayOfSizeK.java similarity index 97% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/MaximumSumSubarrayOfSizeK.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/MaximumSumSubarrayOfSizeK.java index 5cb6b29..a1afc8e 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/MaximumSumSubarrayOfSizeK.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/MaximumSumSubarrayOfSizeK.java @@ -22,7 +22,7 @@ * @author David Kariuki * @since 23/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; public class MaximumSumSubarrayOfSizeK { diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/MergeAnArrayWithOverlappingIntervals.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/MergeAnArrayWithOverlappingIntervals.java similarity index 96% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/MergeAnArrayWithOverlappingIntervals.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/MergeAnArrayWithOverlappingIntervals.java index 92ff7ff..813d0e6 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/MergeAnArrayWithOverlappingIntervals.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/MergeAnArrayWithOverlappingIntervals.java @@ -17,9 +17,9 @@ * @author David Kariuki * @since 22/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; -import AceTheJavaCodingInterview.module2_data_structures.tuples.Interval; +import AceTheJavaCodingInterview.data_structures.tuple.Interval; import java.util.ArrayList; import java.util.Arrays; diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/OneDimensionalArrays.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/OneDimensionalArrays.java similarity index 94% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/OneDimensionalArrays.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/OneDimensionalArrays.java index 3817ba6..dd6a623 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/OneDimensionalArrays.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/OneDimensionalArrays.java @@ -7,7 +7,7 @@ * @author David Kariuki * @since 14/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; @SuppressWarnings({"ForLoopReplaceableByForEach", "SameParameterValue"}) public class OneDimensionalArrays { diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/PairWithTargetSum.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/PairWithTargetSum.java similarity index 98% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/PairWithTargetSum.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/PairWithTargetSum.java index e1139bd..d534a8f 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/PairWithTargetSum.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/PairWithTargetSum.java @@ -36,7 +36,7 @@ * @author David Kariuki * @since 24/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; public class PairWithTargetSum { diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/Permutations.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/Permutations.java similarity index 90% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/Permutations.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/Permutations.java index 7e3a1a2..02a4195 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/Permutations.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/Permutations.java @@ -9,9 +9,9 @@ *
{1, 2, 3} {1, 3, 2} {2, 1, 3} {2, 3, 1} {3, 1, 2} {3, 2, 1} *
If a set has n distinct elements it will have n! n! permutations. * @note Solution This problem follows the Subsets pattern ({@link - * AceTheJavaCodingInterview.module2_data_structures.arrays.Subset}) and, we can follow a - * similar Breadth First Search (BFS) approach. However, unlike Subsets, every permutation must - * contain all the numbers. + * AceTheJavaCodingInterview.data_structures.array.Subset}) and, we can follow a similar Breadth + * First Search (BFS) approach. However, unlike Subsets, every permutation must contain all the + * numbers. *
Let’s take the example-1 mentioned above to generate all the permutations. Following a BFS * approach, we will consider one number at a time: *
1. If the given set is empty then we have only an empty permutation set: [] @@ -39,12 +39,12 @@ * and the queue to store the intermediate permutations. If you see closely, at any time, we * don’t have more than N! permutations between the result list and the queue. Therefore, the * overall space complexity to store N! permutations each containing N elements will be O(N*N!). - * @see AceTheJavaCodingInterview.module2_data_structures.arrays.Subset - * @see AceTheJavaCodingInterview.module2_data_structures.arrays.SubsetsWithDuplicates + * @see AceTheJavaCodingInterview.data_structures.array.Subset + * @see AceTheJavaCodingInterview.data_structures.array.SubsetsWithDuplicates * @author David Kariuki * @since 24/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; import java.util.ArrayList; import java.util.LinkedList; diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SmallestSubarrayWithAGreaterSum.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SmallestSubarrayWithAGreaterSum.java similarity index 97% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SmallestSubarrayWithAGreaterSum.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SmallestSubarrayWithAGreaterSum.java index 4413714..63ff2c0 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SmallestSubarrayWithAGreaterSum.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SmallestSubarrayWithAGreaterSum.java @@ -31,7 +31,7 @@ * @author David Kariuki * @since 23/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; public class SmallestSubarrayWithAGreaterSum { diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SquaringASortedArray.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SquaringASortedArray.java similarity index 96% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SquaringASortedArray.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SquaringASortedArray.java index 88a1784..a39ce3f 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SquaringASortedArray.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SquaringASortedArray.java @@ -18,7 +18,7 @@ * @author David Kariuki * @since 23/8/2022 */ -package AceTheJavaCodingInterview.module2_data_structures.arrays; +package AceTheJavaCodingInterview.data_structures.array; public class SquaringASortedArray { diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SubArraysWithProductLessThanTarget.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SubArraysWithProductLessThanTarget.java similarity index 62% rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SubArraysWithProductLessThanTarget.java rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SubArraysWithProductLessThanTarget.java index 4c3a5be..910173c 100644 --- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/SubArraysWithProductLessThanTarget.java +++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/SubArraysWithProductLessThanTarget.java @@ -4,31 +4,33 @@ *
* * @question Problem Statement - Given an array with positive numbers and a positive target number, - * find all of its contiguous sub-arrays whose product is less than the target number. + * find all of its contiguous sub-array whose product is less than the target number. * @example Example 1: *
Input: [2, 5, 3, 10], target=30 Output: [2], [5], [2, 5], [3], [5, 3], [10] Explanation: - * There are six contiguous sub-arrays whose product is less than the target. + * There are six contiguous sub-array whose product is less than the target. * @example Example 2: *
Input: [8, 2, 6, 5], target=50 Output: [8], [2], [8, 2], [6], [2, 6], [5], [6, 5] - * Explanation: There are seven contiguous sub-arrays whose product is less than the target. + * Explanation: There are seven contiguous sub-array whose product is less than the target. * @note Solution - This problem follows the Sliding Window and the Two Pointers pattern and shares * similarities with Triplets with Smaller Sum *
({@link - * AceTheJavaCodingInterview.module2_data_structures.arrays.TripletsWithSmallerSum_ReturnCount}, - * {@link - * AceTheJavaCodingInterview.module2_data_structures.arrays.TripletsWithSmallerSum_ReturnList}) - * with two differences: + * AceTheJavaCodingInterview.data_structures.array.TripletsWithSmallerSum_ReturnCount}, {@link + * AceTheJavaCodingInterview.data_structures.array.TripletsWithSmallerSum_ReturnList}) with two + * differences: *
In this problem, the input array is not sorted. Instead of finding triplets with sum less
- * than a target, we need to find all sub-arrays having a product less than the target. The
+ * than a target, we need to find all sub-array having a product less than the target. The
* implementation will be quite similar to Triplets with Smaller Sum.
- * @note Time Complexity -
- * @note Space Complexity -
+ * @note Time Complexity - The main for-loop managing the sliding window takes O(N) but creating
+ * sub-array can take up to O(N^2) in the worst case. Therefore overall, our algorithm will take
+ * O(N^3).
+ * @note Space Complexity - Ignoring the space required for the output list, the algorithm runs in
+ * O(N) space which is used for the temp list.
* @author David Kariuki
* @since 26/8/2022
- * @see AceTheJavaCodingInterview.module2_data_structures.arrays.TripletsWithSmallerSum_ReturnCount
- * @see AceTheJavaCodingInterview.module2_data_structures.arrays.TripletsWithSmallerSum_ReturnList
+ * @see AceTheJavaCodingInterview.data_structures.array.TripletsWithSmallerSum_ReturnCount
+ * @see AceTheJavaCodingInterview.data_structures.array.TripletsWithSmallerSum_ReturnList
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays;
+package AceTheJavaCodingInterview.data_structures.array;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -49,7 +51,7 @@ public static void main(String[] args) {
}
/**
- * Method to find sub arrays
+ * Method to find sub array
*
* @param arr - int[]
* @param target - int
@@ -72,7 +74,7 @@ public static List We can follow a similar approach to iterate through the array, taking one number at a
* time. At every step, we will save the difference between the triplet and the target number,
* so that in the end, we can return the triplet with the closest sum.
@@ -19,9 +18,9 @@
* for sorting.
* @author David Kariuki
* @since 25/8/2022
- * @see AceTheJavaCodingInterview.module2_data_structures.arrays.TripletSumToZero
+ * @see AceTheJavaCodingInterview.data_structures.array.TripletSumToZero
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays;
+package AceTheJavaCodingInterview.data_structures.array;
import java.util.Arrays;
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletSumToZero.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletSumToZero.java
similarity index 82%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletSumToZero.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletSumToZero.java
index b952c9e..78f64bf 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletSumToZero.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletSumToZero.java
@@ -14,31 +14,31 @@
* unique triplets whose sum is equal to zero.
* @solution Solution - This problem follows the Two Pointers pattern and shares similarities with
* Pair with Target Sum ({@link
- * AceTheJavaCodingInterview.module2_data_structures.arrays.PairWithTargetSum}). A couple of
- * differences are that the input array is not sorted and instead of a pair we need to find
- * triplets with a target sum of zero.
+ * AceTheJavaCodingInterview.data_structures.array.PairWithTargetSum}). A couple of differences
+ * are that the input array is not sorted and instead of a pair we need to find triplets with a
+ * target sum of zero.
* To follow a similar approach, first, we will sort the array and then iterate through it
* taking one number at a time. Let’s say during our iteration we are at number ‘X’, so we need
* to find ‘Y’ and ‘Z’ such that X + Y + Z == 0. At this stage, our problem translates into
* finding a pair whose sum is equal to -X (as from the above equation Y + Z == -X).
*
* Another difference from Pair with Target Sum({@link
- * AceTheJavaCodingInterview.module2_data_structures.arrays.PairWithTargetSum}) is that we need
- * to find all the unique triplets. To handle this, we have to skip any duplicate number. Since
- * we will be sorting the array, so all the duplicate numbers will be next to each other and are
- * easier to skip.
+ * AceTheJavaCodingInterview.data_structures.array.PairWithTargetSum}) is that we need to find
+ * all the unique triplets. To handle this, we have to skip any duplicate number. Since we will
+ * be sorting the array, so all the duplicate numbers will be next to each other and are easier
+ * to skip.
* @note Time complexity - Sorting the array will take O(N * logN). The searchPair() function will
* take O(N). As we are calling searchPair() for every number in the input array, this means
* that overall searchTriplets() will take O(N * logN + N^2), which is asymptotically equivalent
* to O(N^2).
* @note Space complexity - Ignoring the space required for the output array, the space complexity
* of the above algorithm will be O(N) which is required for sorting.
- * @see AceTheJavaCodingInterview.module2_data_structures.arrays.PairWithTargetSum
- * @see AceTheJavaCodingInterview.module2_data_structures.hash_tables.PairWithTargetSum
+ * @see AceTheJavaCodingInterview.data_structures.array.PairWithTargetSum
+ * @see AceTheJavaCodingInterview.data_structures.hash_table.PairWithTargetSum
* @author David Kariuki
* @since 25/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays;
+package AceTheJavaCodingInterview.data_structures.array;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletsWithSmallerSum_ReturnCount.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletsWithSmallerSum_ReturnCount.java
similarity index 95%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletsWithSmallerSum_ReturnCount.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletsWithSmallerSum_ReturnCount.java
index 120606d..0589b52 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletsWithSmallerSum_ReturnCount.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletsWithSmallerSum_ReturnCount.java
@@ -17,9 +17,9 @@
* of the above algorithm will be O(N) which is required for sorting.
* @author David Kariuki
* @since 26/8/2022
- * @see AceTheJavaCodingInterview.module2_data_structures.arrays.TripletSumToZero
+ * @see AceTheJavaCodingInterview.data_structures.array.TripletSumToZero
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays;
+package AceTheJavaCodingInterview.data_structures.array;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletsWithSmallerSum_ReturnList.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletsWithSmallerSum_ReturnList.java
similarity index 87%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletsWithSmallerSum_ReturnList.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletsWithSmallerSum_ReturnList.java
index 8e63503..8eee3c7 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/TripletsWithSmallerSum_ReturnList.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/TripletsWithSmallerSum_ReturnList.java
@@ -14,10 +14,10 @@
* is less than the target: [-1, 1, 4], [-1, 1, 3], [-1, 1, 2], [-1, 2, 3]
* @note Solution - This problem follows the Two Pointers pattern and shares similarities with
* Triplet Sum to Zero ({@link
- * AceTheJavaCodingInterview.module2_data_structures.arrays.TripletSumToZero}). The only
- * difference is that, in this problem, we need to find the triplets whose sum is less than the
- * given target. To meet the condition i != j != k we need to make sure that each number is not
- * used more than once.
+ * AceTheJavaCodingInterview.data_structures.array.TripletSumToZero}). The only difference is
+ * that, in this problem, we need to find the triplets whose sum is less than the given target.
+ * To meet the condition i != j != k we need to make sure that each number is not used more than
+ * once.
* Following a similar approach, first, we can sort the array and then iterate through it,
* taking one number at a time. Let’s say during our iteration we are at number ‘X’, so we need
* to find ‘Y’ and ‘Z’ such that X + Y + Z < target X+Y+Z
*
- * @note Challenge 2: Merge Two Sorted Arrays
- * Given two sorted arrays, merge them into one array, which should also
- * be sorted.
+ * @note Challenge 2: Merge Two Sorted Arrays Given two sorted array, merge them into one array,
+ * which should also be sorted.
* @author David Kariuki
* @since 14/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
public class CH2_MergeTwoSortedArrays {
@@ -35,7 +34,7 @@ public static void main(String[] args) {
* Method to remove even numbers from array
*
* The time complexity for this algorithm is O(n+m), where n and m are the * sizes of arr1 and
- * arr2, respectively. This is because both arrays are iterated over once.
+ * arr2, respectively. This is because both array are iterated over once.
*
* @param arr1 - Array1
* @param arr2 - Array2
@@ -49,7 +48,7 @@ public static int[] mergeArrays(int[] arr1, int[] arr2) {
int i = 0, j = 0, k = 0;
- // Traverse both arrays
+ // Traverse both array
while (i < arr1Length && j < arr2Length) {
// Check if current element of first array is smaller than current
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH3_FindTwoNoAddingUpToN_Sol_1.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH3_FindTwoNoAddingUpToN_Sol_1.java
similarity index 85%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH3_FindTwoNoAddingUpToN_Sol_1.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH3_FindTwoNoAddingUpToN_Sol_1.java
index a96b3b5..ccad680 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH3_FindTwoNoAddingUpToN_Sol_1.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH3_FindTwoNoAddingUpToN_Sol_1.java
@@ -3,13 +3,12 @@
*
*
*
- * @note Challenge 2: Merge Two Sorted Arrays
- * Given an array and a number "n", find two numbers from the array that
- * sums up to "n".
+ * @note Challenge 2: Merge Two Sorted Arrays Given an array and a number "n", find two numbers from
+ * the array that sums up to "n".
* @author David Kariuki
* @since 14/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
public class CH3_FindTwoNoAddingUpToN_Sol_1 {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH3_FindTwoNoAddingUpToN_Sol_2.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH3_FindTwoNoAddingUpToN_Sol_2.java
similarity index 91%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH3_FindTwoNoAddingUpToN_Sol_2.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH3_FindTwoNoAddingUpToN_Sol_2.java
index ec457f9..a05024d 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH3_FindTwoNoAddingUpToN_Sol_2.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH3_FindTwoNoAddingUpToN_Sol_2.java
@@ -3,13 +3,12 @@
*
*
*
- * @note Challenge 2: Merge Two Sorted Arrays
- * Given an array and a number "n", find two numbers from the array that
- * sums up to "n".
+ * @note Challenge 2: Merge Two Sorted Arrays Given an array and a number "n", find two numbers from
+ * the array that sums up to "n".
* @author David Kariuki
* @since 14/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
public class CH3_FindTwoNoAddingUpToN_Sol_2 {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH4_ArrayOFProductsOfAllElementsExceptItself.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH4_ArrayOFProductsOfAllElementsExceptItself.java
similarity index 92%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH4_ArrayOFProductsOfAllElementsExceptItself.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH4_ArrayOFProductsOfAllElementsExceptItself.java
index 5c2fc35..50d0122 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH4_ArrayOFProductsOfAllElementsExceptItself.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH4_ArrayOFProductsOfAllElementsExceptItself.java
@@ -8,9 +8,9 @@
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
-import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils;
+import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils;
public class CH4_ArrayOFProductsOfAllElementsExceptItself {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH5_FindMinimumValueInArray.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH5_FindMinimumValueInArray.java
similarity index 88%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH5_FindMinimumValueInArray.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH5_FindMinimumValueInArray.java
index 5f54b79..2545728 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH5_FindMinimumValueInArray.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH5_FindMinimumValueInArray.java
@@ -7,9 +7,9 @@
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
-import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils;
+import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils;
public class CH5_FindMinimumValueInArray {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH6_FindFirstNonRepeatingIntegerInArray.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH6_FindFirstNonRepeatingIntegerInArray.java
similarity index 84%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH6_FindFirstNonRepeatingIntegerInArray.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH6_FindFirstNonRepeatingIntegerInArray.java
index 7af67fd..c18034b 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH6_FindFirstNonRepeatingIntegerInArray.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH6_FindFirstNonRepeatingIntegerInArray.java
@@ -3,15 +3,14 @@
*
*
*
- * @note Given an array, find the first integer, which is unique in the array.
- * Unique means the number does not repeat and appears only once in the
- * whole array.
+ * @note Given an array, find the first integer, which is unique in the array. Unique means the
+ * number does not repeat and appears only once in the whole array.
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
-import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils;
+import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils;
public class CH6_FindFirstNonRepeatingIntegerInArray {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH7_FindSecondMaximumValueInArray_Sol_1.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH7_FindSecondMaximumValueInArray_Sol_1.java
similarity index 92%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH7_FindSecondMaximumValueInArray_Sol_1.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH7_FindSecondMaximumValueInArray_Sol_1.java
index ee6d075..0406c0d 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH7_FindSecondMaximumValueInArray_Sol_1.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH7_FindSecondMaximumValueInArray_Sol_1.java
@@ -7,9 +7,9 @@
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
-import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils;
+import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils;
public class CH7_FindSecondMaximumValueInArray_Sol_1 {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH7_FindSecondMaximumValueInArray_Sol_2.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH7_FindSecondMaximumValueInArray_Sol_2.java
similarity index 89%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH7_FindSecondMaximumValueInArray_Sol_2.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH7_FindSecondMaximumValueInArray_Sol_2.java
index 8b4208f..d36b952 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH7_FindSecondMaximumValueInArray_Sol_2.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH7_FindSecondMaximumValueInArray_Sol_2.java
@@ -7,9 +7,9 @@
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
-import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils;
+import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils;
public class CH7_FindSecondMaximumValueInArray_Sol_2 {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH8_RightRotateTheArrayByOneIndex.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH8_RightRotateTheArrayByOneIndex.java
similarity index 93%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH8_RightRotateTheArrayByOneIndex.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH8_RightRotateTheArrayByOneIndex.java
index 8e290f3..2025126 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH8_RightRotateTheArrayByOneIndex.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH8_RightRotateTheArrayByOneIndex.java
@@ -7,7 +7,7 @@
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
public class CH8_RightRotateTheArrayByOneIndex {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_1.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_1.java
similarity index 86%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_1.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_1.java
index 6374177..00857fd 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_1.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_1.java
@@ -7,9 +7,9 @@
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
-import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils;
+import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils;
public class CH9_ReArrangePositiveAndNegativeValues_SOL_1 {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_2.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_2.java
similarity index 85%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_2.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_2.java
index ca76d6e..ecc9929 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_2.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/challenges/CH9_ReArrangePositiveAndNegativeValues_SOL_2.java
@@ -7,9 +7,9 @@
* @author David Kariuki
* @since 16/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.challenges;
+package AceTheJavaCodingInterview.data_structures.array.challenges;
-import AceTheJavaCodingInterview.module2_data_structures.utils.DataStructuresUtils;
+import AceTheJavaCodingInterview.data_structures.utils.DataStructuresUtils;
public class CH9_ReArrangePositiveAndNegativeValues_SOL_2 {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/sorting/CyclicSortEasy.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/sorting/CyclicSortEasy.java
similarity index 97%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/sorting/CyclicSortEasy.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/sorting/CyclicSortEasy.java
index 71fdf05..04baa3d 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/sorting/CyclicSortEasy.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/sorting/CyclicSortEasy.java
@@ -34,7 +34,7 @@
* @author David Kariuki
* @since 23/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.sorting;
+package AceTheJavaCodingInterview.data_structures.array.sorting;
public class CyclicSortEasy {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/sorting/QuicksortAlgorithm.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/sorting/QuicksortAlgorithm.java
similarity index 97%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/sorting/QuicksortAlgorithm.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/array/sorting/QuicksortAlgorithm.java
index 67f000b..ce5ae57 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/arrays/sorting/QuicksortAlgorithm.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/array/sorting/QuicksortAlgorithm.java
@@ -18,7 +18,7 @@
* @author David Kariuki
* @since 23/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.arrays.sorting;
+package AceTheJavaCodingInterview.data_structures.array.sorting;
import java.util.Arrays;
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/hash_tables/PairWithTargetSum.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/hash_table/PairWithTargetSum.java
similarity index 97%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/hash_tables/PairWithTargetSum.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/hash_table/PairWithTargetSum.java
index 9a11767..3ae68a1 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/hash_tables/PairWithTargetSum.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/hash_table/PairWithTargetSum.java
@@ -26,7 +26,7 @@
* @author David Kariuki
* @since 24/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.hash_tables;
+package AceTheJavaCodingInterview.data_structures.hash_table;
import java.util.HashMap;
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/hash_tables/_hash_tables.md b/app/src/main/java/AceTheJavaCodingInterview/data_structures/hash_table/_hash_tables.md
similarity index 100%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/hash_tables/_hash_tables.md
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/hash_table/_hash_tables.md
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/stacks_and_queues/_stacks_and_queues.md b/app/src/main/java/AceTheJavaCodingInterview/data_structures/stacks_and_queue/_stacks_and_queues.md
similarity index 100%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/stacks_and_queues/_stacks_and_queues.md
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/stacks_and_queue/_stacks_and_queues.md
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/tuples/Interval.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/tuple/Interval.java
similarity index 85%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/tuples/Interval.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/tuple/Interval.java
index 670dfb5..84508b8 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/tuples/Interval.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/tuple/Interval.java
@@ -7,7 +7,7 @@
* @author David Kariuki
* @since 22/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.tuples;
+package AceTheJavaCodingInterview.data_structures.tuple;
public class Interval {
diff --git a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/tuples/Tuple.java b/app/src/main/java/AceTheJavaCodingInterview/data_structures/tuple/Tuple.java
similarity index 84%
rename from app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/tuples/Tuple.java
rename to app/src/main/java/AceTheJavaCodingInterview/data_structures/tuple/Tuple.java
index e8e09cd..1ce5605 100644
--- a/app/src/main/java/AceTheJavaCodingInterview/module2_data_structures/tuples/Tuple.java
+++ b/app/src/main/java/AceTheJavaCodingInterview/data_structures/tuple/Tuple.java
@@ -7,7 +7,7 @@
* @author David Kariuki
* @since 18/8/2022
*/
-package AceTheJavaCodingInterview.module2_data_structures.tuples;
+package AceTheJavaCodingInterview.data_structures.tuple;
public class Tuple> findSubArrays(int[] arr, int target) {
}
// Since the product of all numbers from left to right is less than the
- // target therefore, all sub-arrays from left to right will have a
+ // target therefore, all sub-array from left to right will have a
// product less than the target too; to avoid duplicates, we will start
// with a sub-array containing only arr[right] and then extend it.
List