Skip to content

Commit 471af0a

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: Left Rotation. Clean code improvement.
1 parent 19c01cb commit 471af0a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

algorithm-exercises-java/src/main/java/ae/hackerrank/interview_preparation_kit/arrays/ArraysLeftRoration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ private ArraysLeftRoration() {
1414
* rotLeftOne.
1515
*/
1616
public static List<Integer> rotLeftOne(List<Integer> a) {
17-
1817
// Clone the list
1918
List<Integer> output = new ArrayList<>(a);
19+
final int FIRST_POSITION = 0;
2020

21-
Integer first = output.getFirst();
22-
output.remove(0);
21+
Integer first = output.get(FIRST_POSITION);
22+
output.remove(FIRST_POSITION);
2323
output.add(first);
2424

2525
return output;
@@ -37,7 +37,7 @@ public static List<Integer> rotLeft(List<Integer> a, int d) {
3737
while (i <= d)
3838
{
3939

40-
output = ArraysLeftRoration.rotLeftOne(output);
40+
output = rotLeftOne(output);
4141
i += 1;
4242
}
4343

0 commit comments

Comments
 (0)