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 // Memory Usage: 39.3 MB
// Submitted: January 15th, 2021 // Submitted: January 15th, 2021
/** class ListNode {
* Definition for singly-linked list. int val;
* public class ListNode { ListNode next;
* int val; ListNode() {}
* ListNode next; ListNode(int val) { this.val = val; }
* ListNode() {} ListNode(int val, ListNode next) {
* ListNode(int val) { this.val = val; } this.val = val;
* ListNode(int val, ListNode next) { this.val = val; this.next = next; } this.next = next;
* } }
*/ }
class Solution { class Solution {
public ListNode addTwoNumbers(ListNode a, ListNode b) { public ListNode addTwoNumbers(ListNode a, ListNode b) {
ListNode dummy = new ListNode(0); ListNode dummy = new ListNode(0);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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