From 3cd3f632724b951ce7a04f2e113724b1813847c5 Mon Sep 17 00:00:00 2001 From: yennanliu Date: Fri, 15 Mar 2024 16:07:32 +0800 Subject: [PATCH] update --- doc/cheatsheet/java_trick.md | 2 +- leetcode_java/src/main/java/dev/Test2.java | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/cheatsheet/java_trick.md b/doc/cheatsheet/java_trick.md index 52bfe340..8dcc14a7 100644 --- a/doc/cheatsheet/java_trick.md +++ b/doc/cheatsheet/java_trick.md @@ -17,7 +17,7 @@ - Define max-heap - LC 1046 - ```java + ```java // java PriorityQueue heap = new PriorityQueue<>(Comperator.reverseOrder()); ``` diff --git a/leetcode_java/src/main/java/dev/Test2.java b/leetcode_java/src/main/java/dev/Test2.java index c440a4d0..891a22d0 100644 --- a/leetcode_java/src/main/java/dev/Test2.java +++ b/leetcode_java/src/main/java/dev/Test2.java @@ -1,8 +1,8 @@ package dev; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import LeetCodeJava.DataStructure.TreeNode; + +import java.util.*; public class Test2 { public static void main(String[] args) { @@ -34,6 +34,22 @@ public static void main(String[] args) { System.out.println(new int[]{1,2,3}); List x2 = new ArrayList<>(Arrays.asList(1, 2, 3)); + + + // PriorityQueue for PriorityQueue + PriorityQueue pq = new PriorityQueue<>(); + pq.add(1); + + // LinkedList for Queue + Queue q = new LinkedList<>(); + q.add(1); + + + String str = "abcd"; + + System.out.println(str); + System.out.println(str.indexOf(1)); + } }