Add imports for Java solutions

This commit is contained in:
2023-10-06 03:25:12 -05:00
parent 9e0c58faff
commit 5a1efd2418
10 changed files with 42 additions and 12 deletions

View File

@@ -3,16 +3,17 @@
// Memory Usage: 39.3 MB
// Submitted: January 15th, 2021
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class ListNode {
int val;
ListNode next;
ListNode() {}
ListNode(int val) { this.val = val; }
ListNode(int val, ListNode next) {
this.val = val;
this.next = next;
}
}
class Solution {
public ListNode addTwoNumbers(ListNode a, ListNode b) {
ListNode dummy = new ListNode(0);

View File

@@ -3,6 +3,9 @@
// Memory Usage: 39.5 MB
// Submitted: January 14th, 2021
import java.util.Map;
import java.util.HashMap;
class Solution {
public int firstUniqChar(String s) {
Map<Character, Integer> count = new HashMap<Character, Integer>();

View File

@@ -3,6 +3,10 @@
// Memory Usage: 39.1 MB
// Submitted: January 14th, 2021
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
class Solution {
public int longestStrChain(String[] words) {
Map<String, Integer> chain = new HashMap<String, Integer>();

View File

@@ -3,6 +3,9 @@
// Memory Usage: 39.1 MB
// Submitted: January 13th, 2021
import java.util.HashMap;
import java.util.Map;
class Solution {
public int lengthOfLongestSubstring(String s) {
int max = 0;

View File

@@ -3,8 +3,7 @@
// Memory Usage: 54.7 MB
// Submitted: January 14th, 2021
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.HashMap;
class Solution {
HashMap<String, Integer> count = new HashMap<String, Integer>();

View File

@@ -6,6 +6,12 @@
// that worked, but it also used RegEx, did operations it didn't need to, and overall was much too complex and aggressive to work well.
// The correct solution was much simpler and more concise. It did technically work, though!
import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

View File

@@ -3,6 +3,9 @@
// Memory Usage: 39.3 MB
// Submitted: January 15th, 2021
import java.util.HashMap;
import java.util.Map;
class Solution {
Map<Character, Integer> convert = new HashMap<Character, Integer>();

View File

@@ -3,6 +3,10 @@
// Memory Usage: 39.1 MB
// Submitted: January 15th, 2021
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
class Solution {
public int[] frequencySort(int[] nums) {
Map<Integer, Integer> count = new HashMap<Integer, Integer>();

View File

@@ -3,6 +3,10 @@
// Memory Usage: 40 MB
// Submitted: January 14th, 2021
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
class Solution {
public String frequencySort(String s) {
// Get each character's frequency

View File

@@ -3,6 +3,9 @@
// Memory Usage: 39.7 MB
// Submitted: January 12th, 2021
import java.util.HashMap;
import java.util.Map;
class Solution {
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();