Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
fix smells
  • Loading branch information
ThanhNIT committed Mar 29, 2022
commit b339a01599f345812727a0eae83846955306625f
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public int[] getStrongest(int[] arr, int k) {
Arrays.sort(arr);
int[] array = new int[k];
int median = arr[(arr.length - 1) / 2];
int start = 0, end = arr.length - 1;
int start = 0;
int end = arr.length - 1;
for (int i = 0; i < k; i++) {
if (Math.abs(arr[end] - median) >= Math.abs(arr[start] - median)) {
array[i] = arr[end];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Solution {
private int nColors;
private int[][] cost;

public int minCost(int[] houses, int[][] cost, int nHouses, int nColors, int tGroups) {
public int minCost(int[] houses, int[][] cost, int nColors, int tGroups) {
this.cost = cost;
this.houses = houses;
this.memo = new int[houses.length][nColors + 1][tGroups + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ void minCost() {
.minCost(
new int[] {0, 0, 0, 0, 0},
new int[][] {{1, 10}, {10, 1}, {10, 1}, {1, 10}, {5, 1}},
5,
2,
3),
equalTo(9));
Expand All @@ -26,7 +25,6 @@ void minCost2() {
.minCost(
new int[] {0, 2, 1, 2, 0},
new int[][] {{1, 10}, {10, 1}, {10, 1}, {1, 10}, {5, 1}},
5,
2,
3),
equalTo(11));
Expand All @@ -39,7 +37,6 @@ void minCost3() {
.minCost(
new int[] {3, 1, 2, 3},
new int[][] {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}},
4,
3,
3),
equalTo(-1));
Expand Down