Skip to content

Commit

Permalink
Replaced <>() with ()
Browse files Browse the repository at this point in the history
  • Loading branch information
RodneyShag committed Nov 27, 2019
1 parent 11dd8da commit d4a47cd
Show file tree
Hide file tree
Showing 37 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static void main(String[] args) {
}

/* Calculate Mode - if there's a tie, choose the smaller number */
HashMap<Integer, Integer> map = new HashMap<>();
HashMap<Integer, Integer> map = new HashMap();
int maxOccurrences = 0;
int mode = Integer.MAX_VALUE;
for (int num : array) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static void main(String[] args) {
/* Save input as entries in a HashMap */
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
HashMap<String, Integer> map = new HashMap<>();
HashMap<String, Integer> map = new HashMap();
for (int i = 0; i < n; i++) {
String name = scan.next();
int phone = scan.nextInt();
Expand Down
4 changes: 2 additions & 2 deletions 30 Days of Code/Day 18 - Queues and Stacks/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class Solution {
/* Stack - using an ArrayDeque */
ArrayDeque<Character> dequeAsStack = new ArrayDeque<>();
ArrayDeque<Character> dequeAsStack = new ArrayDeque();

void pushCharacter(char ch) {
dequeAsStack.push(ch);
Expand All @@ -18,7 +18,7 @@ char popCharacter() {
}

/* Queue - using an ArrayDeque */
ArrayDeque<Character> dequeAsQueue = new ArrayDeque<>();
ArrayDeque<Character> dequeAsQueue = new ArrayDeque();

void enqueueCharacter(char ch) {
dequeAsQueue.add(ch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static void levelOrder(Node root) {
if (root == null) {
return;
}
ArrayDeque<Node> deque = new ArrayDeque<>(); // use deque as a queue
ArrayDeque<Node> deque = new ArrayDeque(); // use deque as a queue
deque.add(root);
while (!deque.isEmpty()) {
Node n = deque.removeFirst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static void findDistances(Node start) {
if (start == null) {
return;
}
ArrayDeque<Node> deque = new ArrayDeque<>(); // use deque as a queue
ArrayDeque<Node> deque = new ArrayDeque(); // use deque as a queue
start.distance = 0;
deque.add(start);
while (!deque.isEmpty()) {
Expand All @@ -73,7 +73,7 @@ public static class Node {
public Node (int id) {
this.id = id;
distance = -1;
neighbors = new HashSet<>();
neighbors = new HashSet();
}

public void addNeighbor(Node neighbor) {
Expand Down
2 changes: 1 addition & 1 deletion Algorithms/Search/Ice Cream Parlor/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void main(String[] args) {
}

public static void buyIceCream(int [] costs, int money) {
HashMap<Integer, Integer> map = new HashMap<>(); // key = cost, value = ice cream ID
HashMap<Integer, Integer> map = new HashMap(); // key = cost, value = ice cream ID
for (int i = 0; i < costs.length; i++) {
int icecreamID = i + 1;
int cost = costs[i];
Expand Down
4 changes: 2 additions & 2 deletions Algorithms/Sorting/Quicksort 2 - Sorting/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ private static void quickSort(int [] array, int start, int end) {
/* Partition/Quicksort "Stable Sort" version using O(n) space */
private static int partition(int[] array, int start, int end) {
int pivotValue = array[start]; // not a great choice of pivot
ArrayList<Integer> leftList = new ArrayList<>();
ArrayList<Integer> rightList = new ArrayList<>();
ArrayList<Integer> leftList = new ArrayList();
ArrayList<Integer> rightList = new ArrayList();

for (int i = start + 1 ; i <= end; i++) {
if (array[i] < pivotValue) {
Expand Down
2 changes: 1 addition & 1 deletion Algorithms/Strings/Super Reduced String/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

String superReducedString(String str) {
/* Iterate through String, creating final result in a Stack */
Stack<Character> stack = new Stack<>();
Stack<Character> stack = new Stack();
for (int i = 0; i < str.length(); i++) {
Character ch = str.charAt(i);
if (!stack.isEmpty() && ch == stack.peek()) {
Expand Down
2 changes: 1 addition & 1 deletion Algorithms/Strings/Weighted Uniform Strings/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void main(String[] args) {
}

private static HashSet<Integer> getWeights(String str) {
HashSet<Integer> weights = new HashSet<>();
HashSet<Integer> weights = new HashSet();
int weight = 0;
char prev = ' '; // so it doesn't match 1st character
for (int i = 0; i < str.length(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static void findDistances(Node start) {
if (start == null) {
return;
}
ArrayDeque<Node> deque = new ArrayDeque<>(); // use deque as a queue
ArrayDeque<Node> deque = new ArrayDeque(); // use deque as a queue
start.distance = 0;
deque.add(start);
while (!deque.isEmpty()) {
Expand All @@ -73,7 +73,7 @@ public static class Node {
public Node (int id) {
this.id = id;
distance = -1;
neighbors = new HashSet<>();
neighbors = new HashSet();
}

public void addNeighbor(Node neighbor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static void main(String[] args) {
}

public static void buyIceCream(int [] costs, int money) {
HashMap<Integer, Integer> map = new HashMap<>(); // key = cost, value = ice cream ID
HashMap<Integer, Integer> map = new HashMap(); // key = cost, value = ice cream ID
for (int i = 0; i < costs.length; i++) {
int icecreamID = i + 1;
int cost = costs[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void checkMagazine(String[] magazine, String[] ransom) {

/* Creates and returns a HashMap out of an array of Strings */
private static HashMap<String, Integer> makeMap(String[] words) {
HashMap<String, Integer> map = new HashMap<>();
HashMap<String, Integer> map = new HashMap();
for (int i = 0; i < words.length; i++) {
map.merge(words[i], 1, Integer::sum);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class Solution {
private static PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections.reverseOrder()); // keeps track of the SMALL numbers
private static PriorityQueue<Integer> minHeap = new PriorityQueue<>(); // keeps track of the LARGE numbers
private static PriorityQueue<Integer> minHeap = new PriorityQueue(); // keeps track of the LARGE numbers

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public static void main(String[] args) {
}

public static class MyQueue<Integer> {
private Stack<Integer> stack1 = new Stack<>();
private Stack<Integer> stack2 = new Stack<>();
private Stack<Integer> stack1 = new Stack();
private Stack<Integer> stack2 = new Stack();

public void enqueue(Integer num) {
stack1.push(num);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/* Create HashMap to match opening brackets with closing brackets */
static String isBalanced(String expression) {
HashMap<Character, Character> map = new HashMap<>();
HashMap<Character, Character> map = new HashMap();
map.put('(', ')');
map.put('[', ']');
map.put('{', '}');
Expand All @@ -18,7 +18,7 @@ private static boolean isBalanced(String expression, HashMap<Character, Characte
if ((expression.length() % 2) != 0) {
return false; // odd length Strings are not balanced
}
ArrayDeque<Character> deque = new ArrayDeque<>(); // use deque as a stack
ArrayDeque<Character> deque = new ArrayDeque(); // use deque as a stack
for (int i = 0; i < expression.length(); i++) {
Character ch = expression.charAt(i);
if (map.containsKey(ch)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void main(String[] args) {

/* Based loosely on tutorial video in this problem */
class TrieNode {
private HashMap<Character, TrieNode> children = new HashMap<>();
private HashMap<Character, TrieNode> children = new HashMap();
public int size = 0; // this was the main trick to decrease runtime to pass tests.

public void putChildIfAbsent(char ch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// Can alternatively be solved in O(1) space (per testcase) by using iteration instead of recursion

public class Solution {
private static HashMap<Integer, Integer> cache = new HashMap<>();
private static HashMap<Integer, Integer> cache = new HashMap();

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Expand Down
2 changes: 1 addition & 1 deletion Data Structures/Arrays/Dynamic Array/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void main(String[] args) {
int lastAns = 0;

/* Create 2-D ArrayList */
ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
ArrayList<ArrayList<Integer>> lists = new ArrayList();
for (int i = 0; i < N; i++) {
lists.add(new ArrayList<Integer>());
}
Expand Down
2 changes: 1 addition & 1 deletion Data Structures/Arrays/Sparse Arrays/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static void main(String[] args) {
scan.nextLine(); // gets rid of pesky newline

/* Create and fill HashMap */
HashMap<String, Integer> map = new HashMap<>();
HashMap<String, Integer> map = new HashMap();
for (int i = 0; i < N; i++) {
String str = scan.nextLine();
map.merge(str, 1, Integer::sum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class Solution {
private static PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections.reverseOrder()); // keeps track of the SMALL numbers
private static PriorityQueue<Integer> minHeap = new PriorityQueue<>(); // keeps track of the LARGE numbers
private static PriorityQueue<Integer> minHeap = new PriorityQueue(); // keeps track of the LARGE numbers

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Expand Down
4 changes: 2 additions & 2 deletions Data Structures/Queues/Queue using Two Stacks/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public static void main(String[] args) {
}

public static class MyQueue<Integer> {
private Stack<Integer> stack1 = new Stack<>();
private Stack<Integer> stack2 = new Stack<>();
private Stack<Integer> stack1 = new Stack();
private Stack<Integer> stack2 = new Stack();

public void enqueue(Integer num) {
stack1.push(num);
Expand Down
4 changes: 2 additions & 2 deletions Data Structures/Stacks/Balanced Brackets/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class Solution {
public static void main(String[] args) {
/* Create HashMap to match opening brackets with closing brackets */
HashMap<Character, Character> map = new HashMap<>();
HashMap<Character, Character> map = new HashMap();
map.put('(', ')');
map.put('[', ']');
map.put('{', '}');
Expand All @@ -31,7 +31,7 @@ private static boolean isBalanced(String expression, HashMap<Character, Characte
if ((expression.length() % 2) != 0) {
return false; // odd length Strings are not balanced
}
ArrayDeque<Character> deque = new ArrayDeque<>(); // use deque as a stack
ArrayDeque<Character> deque = new ArrayDeque(); // use deque as a stack
for (int i = 0; i < expression.length(); i++) {
Character ch = expression.charAt(i);
if (map.containsKey(ch)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Node {
// Space Complexity: O(n)

void LevelOrder(Node root) {
ArrayDeque<Node> deque = new ArrayDeque<>(); // use deque as a queue
ArrayDeque<Node> deque = new ArrayDeque(); // use deque as a queue
if (root != null) {
deque.add(root);
}
Expand Down
2 changes: 1 addition & 1 deletion Data Structures/Trie/Contacts/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void main(String[] args) {

/* Based loosely on tutorial video in this problem */
class TrieNode {
private HashMap<Character, TrieNode> children = new HashMap<>();
private HashMap<Character, TrieNode> children = new HashMap();
public int size = 0; // this was the main trick to decrease runtime to pass tests.

public void putChildIfAbsent(char ch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Complete the minimumDistances function below.
static int minimumDistances(int[] array) {
HashMap<Integer, Integer> map = new HashMap<>();
HashMap<Integer, Integer> map = new HashMap();
int minDistance = Integer.MAX_VALUE;
for (int i = 0; i < array.length; i++) {
if (map.containsKey(array[i])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static void main(String[] args) {
int n = scan .nextInt();

/* Count pairs */
HashSet<Integer> set = new HashSet<>();
HashSet<Integer> set = new HashSet();
int pairs = 0;
for (int i = 0; i < n; i++) {
int cost = scan.nextInt();
Expand Down
2 changes: 1 addition & 1 deletion Implementation/Brute Force/Pangrams/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static void main(String[] args) {
String str = scan.nextLine().toLowerCase();
scan.close();

HashSet<Character> set = new HashSet<>();
HashSet<Character> set = new HashSet();
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if (Character.isLetter(ch)) {
Expand Down
2 changes: 1 addition & 1 deletion Java/Advanced/Java Reflection - Attributes/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static void main(String[] args) {
Method[] methods = student.getDeclaredMethods();

/* Get names from Methods */
ArrayList<String> methodNames = new ArrayList<>();
ArrayList<String> methodNames = new ArrayList();
for (Method method : methods) {
methodNames.add(method.getName());
}
Expand Down
2 changes: 1 addition & 1 deletion Java/Advanced/Java Varargs - Simple Addition/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void main(String[] args) {
ob.add(n1,n2,n3,n4,n5);
ob.add(n1,n2,n3,n4,n5,n6);
Method[] methods = Add.class.getDeclaredMethods();
Set<String> set = new HashSet<>();
Set<String> set = new HashSet();
boolean overload = false;
for (int i = 0; i < methods.length; i++) {
if (set.contains(methods[i].getName())) {
Expand Down
6 changes: 3 additions & 3 deletions Java/Advanced/Java Visitor Pattern/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public int getDepth() {
}

class TreeNode extends Tree {
private ArrayList<Tree> children = new ArrayList<>();
private ArrayList<Tree> children = new ArrayList();

public TreeNode(int value, Color color, int depth) {
super(value, color, depth);
Expand Down Expand Up @@ -168,15 +168,15 @@ public static Tree solve() {
/* Edges are undirected: Add 1st direction */
HashSet<Integer> uNeighbors = map.get(u);
if (uNeighbors == null) {
uNeighbors = new HashSet<>();
uNeighbors = new HashSet();
map.put(u, uNeighbors);
}
uNeighbors.add(v);

/* Edges are undirected: Add 2nd direction */
HashSet<Integer> vNeighbors = map.get(v);
if (vNeighbors == null) {
vNeighbors = new HashSet<>();
vNeighbors = new HashSet();
map.put(v, vNeighbors);
}
vNeighbors.add(u);
Expand Down
2 changes: 1 addition & 1 deletion Java/Advanced/Prime Checker/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void main(String[] args) {
ob.checkPrime(n1,n2,n3);
ob.checkPrime(n1,n2,n3,n4,n5);
Method[] methods = Prime.class.getDeclaredMethods();
Set<String> set = new HashSet<>();
Set<String> set = new HashSet();
boolean overload = false;
for (int i = 0; i < methods.length; i++) {
if (set.contains(methods[i].getName())) {
Expand Down
4 changes: 2 additions & 2 deletions Java/Data Structures/Java ArrayList/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public static void main(String[] args) {
int n = scan.nextInt();

/* Save numbers in 2-D ArrayList */
ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
ArrayList<ArrayList<Integer>> lists = new ArrayList();
for (int row = 0; row < n; row++) {
int d = scan.nextInt();
ArrayList<Integer> list = new ArrayList<>();
ArrayList<Integer> list = new ArrayList();
for (int col = 0; col < d; col++) {
list.add(scan.nextInt());
}
Expand Down
4 changes: 2 additions & 2 deletions Java/Data Structures/Java Dequeue/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

public class test {
public static void main(String[] args) {
HashMap<Integer, Integer> map = new HashMap<>();
ArrayDeque<Integer> deque = new ArrayDeque<>();
HashMap<Integer, Integer> map = new HashMap();
ArrayDeque<Integer> deque = new ArrayDeque();

Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
Expand Down
2 changes: 1 addition & 1 deletion Java/Data Structures/Java List/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static void main(String[] args) {
/* Create and fill Linked List of Integers */
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
LinkedList<Integer> list = new LinkedList<>();
LinkedList<Integer> list = new LinkedList();
for (int i = 0; i < N; i++) {
int value = scan.nextInt();
list.add(value);
Expand Down
2 changes: 1 addition & 1 deletion Java/Data Structures/Java Map/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void main(String[] args) throws IOException {
/* Save input as entries in a HashMap */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
HashMap<String, Integer> map = new HashMap<>();
HashMap<String, Integer> map = new HashMap();
while (n-- > 0) {
String name = br.readLine();
int phone = Integer.parseInt(br.readLine());
Expand Down
Loading

0 comments on commit d4a47cd

Please sign in to comment.