-
Notifications
You must be signed in to change notification settings - Fork 20.1k
Refactoring the files to be in correctly nested packages #6120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
255a507
refactoring to correct package
varada610 1ab83ac
Merge branch 'master' of https://github.com/varada610/Java
varada610 8c36f5f
build fix
varada610 970a32a
Build fail by lint
varada610 4c54898
build fix for PMD
varada610 66de922
pmd failure and clang check
varada610 7646991
Merge branch 'master' into master
varada610 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...m/thealgorithms/misc/InverseOfMatrix.java → ...thealgorithms/matrix/InverseOfMatrix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...m/thealgorithms/misc/MatrixTranspose.java → ...thealgorithms/matrix/MatrixTranspose.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.thealgorithms.misc; | ||
package com.thealgorithms.matrix; | ||
|
||
/** | ||
* | ||
|
2 changes: 1 addition & 1 deletion
2
...om/thealgorithms/misc/MedianOfMatrix.java → .../thealgorithms/matrix/MedianOfMatrix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...om/thealgorithms/misc/MirrorOfMatrix.java → .../thealgorithms/matrix/MirrorOfMatrix.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.thealgorithms.misc; | ||
package com.thealgorithms.matrix; | ||
|
||
// Problem Statement | ||
/* | ||
|
124 changes: 62 additions & 62 deletions
124
...hms/others/PrintAMatrixInSpiralOrder.java → ...hms/matrix/PrintAMatrixInSpiralOrder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
package com.thealgorithms.others; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
public class PrintAMatrixInSpiralOrder { | ||
/** | ||
* Search a key in row and column wise sorted matrix | ||
* | ||
* @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 | ||
*/ | ||
public List<Integer> print(int[][] matrix, int row, int col) { | ||
// r traverses matrix row wise from first | ||
int r = 0; | ||
// c traverses matrix column wise from first | ||
int c = 0; | ||
int i; | ||
List<Integer> result = new ArrayList<>(); | ||
while (r < row && c < col) { | ||
// print first row of matrix | ||
for (i = c; i < col; i++) { | ||
result.add(matrix[r][i]); | ||
} | ||
// increase r by one because first row printed | ||
r++; | ||
// print last column | ||
for (i = r; i < row; i++) { | ||
result.add(matrix[i][col - 1]); | ||
} | ||
// decrease col by one because last column has been printed | ||
col--; | ||
// print rows from last except printed elements | ||
if (r < row) { | ||
for (i = col - 1; i >= c; i--) { | ||
result.add(matrix[row - 1][i]); | ||
} | ||
row--; | ||
} | ||
// print columns from first except printed elements | ||
if (c < col) { | ||
for (i = row - 1; i >= r; i--) { | ||
result.add(matrix[i][c]); | ||
} | ||
c++; | ||
} | ||
} | ||
return result; | ||
} | ||
} | ||
package com.thealgorithms.matrix; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class PrintAMatrixInSpiralOrder { | ||
/** | ||
* Search a key in row and column wise sorted matrix | ||
* | ||
* @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 | ||
*/ | ||
|
||
public List<Integer> print(int[][] matrix, int row, int col) { | ||
|
||
// r traverses matrix row wise from first | ||
int r = 0; | ||
// c traverses matrix column wise from first | ||
int c = 0; | ||
int i; | ||
|
||
List<Integer> result = new ArrayList<>(); | ||
|
||
while (r < row && c < col) { | ||
// print first row of matrix | ||
for (i = c; i < col; i++) { | ||
result.add(matrix[r][i]); | ||
} | ||
|
||
// increase r by one because first row printed | ||
r++; | ||
|
||
// print last column | ||
for (i = r; i < row; i++) { | ||
result.add(matrix[i][col - 1]); | ||
} | ||
|
||
// decrease col by one because last column has been printed | ||
col--; | ||
|
||
// print rows from last except printed elements | ||
if (r < row) { | ||
for (i = col - 1; i >= c; i--) { | ||
result.add(matrix[row - 1][i]); | ||
} | ||
|
||
row--; | ||
} | ||
|
||
// print columns from first except printed elements | ||
if (c < col) { | ||
for (i = row - 1; i >= r; i--) { | ||
result.add(matrix[i][c]); | ||
} | ||
c++; | ||
} | ||
} | ||
return result; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ithms/others/RotateMatrixBy90Degrees.java → ...ithms/matrix/RotateMatrixBy90Degrees.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.thealgorithms.others; | ||
package com.thealgorithms.matrix; | ||
|
||
import java.util.Scanner; | ||
/** | ||
|
2 changes: 1 addition & 1 deletion
2
...ithms/matrixexponentiation/Fibonacci.java → ...atrix/matrixexponentiation/Fibonacci.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ealgorithms/misc/InverseOfMatrixTest.java → ...lgorithms/matrix/InverseOfMatrixTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ealgorithms/misc/MatrixTransposeTest.java → ...lgorithms/matrix/MatrixTransposeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...healgorithms/misc/MedianOfMatrixTest.java → ...algorithms/matrix/MedianOfMatrixTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...healgorithms/misc/MirrorOfMatrixTest.java → ...algorithms/matrix/MirrorOfMatrixTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../others/TestPrintMatrixInSpiralOrder.java → .../matrix/TestPrintMatrixInSpiralOrder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.