From 32e2191e9b3cefafa88c171e797a880eb65c1717 Mon Sep 17 00:00:00 2001
From: Hardik Pawar
+ * Given a 2D array (matrix), this class provides a method to return the
+ * elements
+ * of the matrix in spiral order, starting from the top-left corner and moving
+ * clockwise.
+ *
+ * Example:
*
- * @param matrix matrix to be searched
- * @param row number of rows matrix has
- * @param col number of columns matrix has
- * @author Sadiul Hakim : https://github.com/sadiul-hakim
+ *
+ * int[][] matrix = {
+ * {1, 2, 3},
+ * {4, 5, 6},
+ * {7, 8, 9}
+ * };
+ * print(matrix, 3, 3) returns [1, 2, 3, 6, 9, 8, 7, 4, 5]
+ *
+ *
- * Bloom filters are space-efficient data structures that provide a fast way to test whether an - * element is a member of a set. They may produce false positives, indicating an element is + * Bloom filters are space-efficient data structures that provide a fast way to + * test whether an + * element is a member of a set. They may produce false positives, indicating an + * element is * in the set when it is not, but they will never produce false negatives. *
* @@ -20,11 +22,14 @@ public class BloomFilter- * This method hashes the element using all defined hash functions and sets the corresponding + * This method hashes the element using all defined hash functions and sets the + * corresponding * bits in the bit array. *
* @@ -65,13 +72,16 @@ public void insert(T key) { /** * Checks if an element might be in the Bloom filter. *- * This method checks the bits at the positions computed by each hash function. If any of these - * bits are not set, the element is definitely not in the filter. If all bits are set, the element + * This method checks the bits at the positions computed by each hash function. + * If any of these + * bits are not set, the element is definitely not in the filter. If all bits + * are set, the element * might be in the filter. *
* * @param key the element to check for membership in the Bloom filter - * @return {@code true} if the element might be in the Bloom filter, {@code false} if it is definitely not + * @return {@code true} if the element might be in the Bloom filter, + * {@code false} if it is definitely not */ public boolean contains(T key) { for (Hash- * Each instance of this class represents a different hash function based on its index. + * Each instance of this class represents a different hash function based on its + * index. *
* * @param+ * Given a 2D array (matrix), this class provides a method to return the + * elements + * of the matrix in spiral order, starting from the top-left corner and moving + * clockwise. + *
+ * + * @author Sadiul Hakim (https://github.com/sadiul-hakim) + */ public class PrintAMatrixInSpiralOrder { + /** - * Search a key in row and column wise sorted matrix + * Returns the elements of the given matrix in spiral order. + * + * @param matrix the 2D array to traverse in spiral order + * @param row the number of rows in the matrix + * @param col the number of columns in the matrix + * @return a list containing the elements of the matrix in spiral order * - * @param matrix matrix to be searched - * @param row number of rows matrix has - * @param col number of columns matrix has - * @author Sadiul Hakim : https://github.com/sadiul-hakim + *+ * Example: + * + *
+ * int[][] matrix = { + * {1, 2, 3}, + * {4, 5, 6}, + * {7, 8, 9} + * }; + * print(matrix, 3, 3) returns [1, 2, 3, 6, 9, 8, 7, 4, 5] + *+ * */ public List
- * Given a 2D array (matrix), this class provides a method to return the - * elements - * of the matrix in spiral order, starting from the top-left corner and moving - * clockwise. - *
- * - * @author Sadiul Hakim (https://github.com/sadiul-hakim) - */ -public class PrintAMatrixInSpiralOrder { - - /** - * Returns the elements of the given matrix in spiral order. - * - * @param matrix the 2D array to traverse in spiral order - * @param row the number of rows in the matrix - * @param col the number of columns in the matrix - * @return a list containing the elements of the matrix in spiral order - * - *- * Example: - * - *
- * int[][] matrix = { - * {1, 2, 3}, - * {4, 5, 6}, - * {7, 8, 9} - * }; - * print(matrix, 3, 3) returns [1, 2, 3, 6, 9, 8, 7, 4, 5] - *- * - */ - public List