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