mirror of
https://github.com/Xevion/leetcode.git
synced 2025-12-06 07:15:22 -06:00
Add imports for Java solutions
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>();
|
||||
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<>();
|
||||
|
||||
Reference in New Issue
Block a user