comments for bob solutions
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
// Full solved correct solution
|
||||
public class DealEmOut {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.InputStreamReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
//Incomplete Not Working
|
||||
public class DontTestMe {
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
@@ -17,16 +18,12 @@ public class DontTestMe {
|
||||
Test[] ar = new Test[N];
|
||||
for (int i = 0; i < N; i++) {
|
||||
st = new StringTokenizer(br.readLine());
|
||||
ar[i] = new Test(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()),Double.parseDouble(st.nextToken()));
|
||||
ar[i] = new Test(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()),
|
||||
Double.parseDouble(st.nextToken()));
|
||||
}
|
||||
|
||||
Arrays.sort(ar, (a1, a2) -> a1.compareTo(a2));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,8 +42,10 @@ class Test{
|
||||
|
||||
public int compareTo(Object o) {
|
||||
Test t = (Test) o;
|
||||
if (this.weight > t.weight) return 1;
|
||||
else if (this.weight < t.weight) return -1;
|
||||
if (this.weight > t.weight)
|
||||
return 1;
|
||||
else if (this.weight < t.weight)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
//Nearly correct solution...one/two bugs passed most testcases
|
||||
public class Island {
|
||||
static int N, M;
|
||||
static int[][] grid;
|
||||
static boolean[][] visited;
|
||||
static Map<Integer, Integer> islands = new HashMap<>();
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
StringTokenizer st = new StringTokenizer(br.readLine());
|
||||
@@ -29,7 +31,8 @@ public class Island {
|
||||
br.close();
|
||||
for (int i = 0; i < N; i++) {
|
||||
for (int j = 0; j < M; j++) {
|
||||
if (visited[i][j]) continue;
|
||||
if (visited[i][j])
|
||||
continue;
|
||||
if (grid[i][j] > 0) {
|
||||
islands.put(grid[i][j], islands.getOrDefault(grid[i][j], 0) + 1);
|
||||
search(grid[i][j], i, j);
|
||||
@@ -50,7 +53,8 @@ public class Island {
|
||||
}
|
||||
|
||||
static void search(int val, int i, int j) {
|
||||
if (visited[i][j]) return;
|
||||
if (visited[i][j])
|
||||
return;
|
||||
visited[i][j] = true;
|
||||
for (int dir = 0; dir < 4; dir++) {
|
||||
switch (dir) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.PrintWriter;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
//Correct solution with too much time complexity O(n*n) fails almost every test case to time
|
||||
public class MaximumAura {
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
@@ -53,7 +54,6 @@ public class MaximumAura {
|
||||
out.print((left[i] + right[i] - 1) + " ");
|
||||
}
|
||||
|
||||
|
||||
br.close();
|
||||
out.flush();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
// Working but O(n*n) --> 50% of test cases fail on time complexity
|
||||
public class WeightedDifference {
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
@@ -12,7 +13,6 @@ public class WeightedDifference {
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
|
||||
// Write code here
|
||||
|
||||
int a = Integer.parseInt(br.readLine());
|
||||
|
||||
Reference in New Issue
Block a user