Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions solutions/java/ConvertArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public int getOriginalIndex(int currentIndex, int length) {
}

public int[] convert(int[] input) {
// When array size is less than 3, returns an error.
if (input.length % 3 != 0 ) {
System.out.println("Error! Array cannot be divided into three equal parts");
return;
}
for (int i = 0; i < input.length; ++i) {
int originalIndex = getOriginalIndex(i, input.length/3);
while (originalIndex < i) {
Expand Down