自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 二叉搜索树的最近公共祖先

class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if (root.val>p.val && root.val>q.val) return lowestCommonAncestor(root.left,p,q); if (root.val<p.val && root.val&lt.

2020-12-23 16:20:04 139

原创 验证二叉搜索树

class Solution { Long pre = Long.MIN_VALUE; public boolean isValidBST(TreeNode root) { if (root==null){ return true; } if (!isValidBST(root.left)){ return false; } if (root.val<=pre){ return false; }.

2020-12-23 16:01:16 52

原创 三数之和

class Solution { public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> res = new ArrayList<>(); if (nums==null||nums.length<3){ return res; .

2020-12-23 16:00:29 67

原创 两数之和

class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer,Integer> map = new HashMap<Integer,Integer>(); for (int i=0;i<nums.length;i++){ if (map.get(nums[i])!=null){ return ne

2020-12-20 22:32:56 52

原创 有效的字母异位词

class Solution { public boolean isAnagram(String s, String t) { int len = s.length(); if (len!=t.length()){ return false; } int[] count = new int[26]; for (int i=0;i<len;i++){ count[s.c

2020-12-20 22:16:19 64 1

原创 返回滑动窗口中的最大值

class Solution { public int[] maxSlidingWindow(int[] nums, int k) { LinkedList<Integer> queue = new LinkedList<Integer>(); int[] res = new int[nums.length-k+1]; int left = 0; for (int i=0;i<nums.length;i++){ if

2020-12-20 22:03:17 202

原创 返回数据流中的第K大元素

class KthLargest { private int[] minHeap; private final int k; private int last; public KthLargest(int k, int[] nums) { this.k = k; this.minHeap = new int[k]; this.last = -1; for (int i=0;i<k&&i<nums.length;i++

2020-12-20 22:02:18 77

原创 用栈实现队列

class MyQueue { private LinkedList<Integer> stack1; private LinkedList<Integer> stack2; /** Initialize your data structure here. */ public MyQueue() { stack1 = new LinkedList<Integer>(); stack2 = new Linke

2020-12-20 22:01:44 51

原创 用队列实现栈

class MyStack { private LinkedList<Integer> queue; /** Initialize your data structure here. */ public MyStack() { queue = new LinkedList<Integer>(); } /** Push element x onto stack. */ public void push(int

2020-12-20 22:01:08 52

原创 判断括号字符串是否有效

class Solution { public boolean isValid(String s) { LinkedList<Character> stack = new LinkedList<Character>(); int len = s.length(); int index = 0; while(index<len){ if (s.charAt(index)=='(' || s.charAt(index)==

2020-12-20 22:00:20 190

原创 判断链表是否有环

public class Solution { public boolean hasCycle(ListNode head) { ListNode slow = head; while(head!=null&&head.next!=null&&head.next.next!=null){ head=head.next.next; slow = slow.next; if (head==sl

2020-12-20 21:58:39 60

原创 反转链表

迭代 public class Solution { public ListNode ReverseList(ListNode head) { if (head==null||head.next==null){ return head; } ListNode newHead = null; while(head.next!=null){ ListNode tem = head;

2020-12-20 21:58:22 49

转载 Servlet和CGI的区别

Servlet和CGI的区别 Servlet被服务器实例化后,容器运行其init方法,请求到达时运行其service方法,service方法自动派遣运行与请求对应的doXXX方法(doGet,doPost)等,当服务器决定将实例销毁的时候调用其destroy方法。 servlet处于服务器进程中,它通过多线程方式运行其service方法,一个实例可以服务于多个请求,并且其实例一般不会销毁,

2016-07-02 15:20:55 334

转载 Java中的constructor

Java中的构造方法总结 今天写代码突然发现Java的构造方法也有不少说法呢,闲来无事,总结一下: 构造方法和实例方法的区别: 一、主要的区别在于三个方面:修饰符、返回值、命名 1、和实例方法一样,构造器可以有任何访问的修饰符,public、private、protected或者没有修饰符   ,都可以对构造方法进行修饰。不同于实例方法的是构造方法不能有任何非访问性质的修饰

2016-07-02 14:56:27 8111

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除