随笔分类 - Java-面试笔试
摘要:You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contai
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in
阅读全文
摘要:Remove all elements from a linked list of integers that have value val. Example: 【递归】
阅读全文
摘要:Given a singly linked list, determine if it is a palindrome. Example 1: Example 2: Follow up:Could you do it in O(n) time and O(1) space?
阅读全文
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe
阅读全文
摘要:Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look
阅读全文
摘要:22 23 24 25 26 27 28 1 21 44 45 46 47 48 29 2 20 43 58 59 60 49 30 3 19 42 57 64 61 50 31 4 18 41 56 63 62 51 32 5 17 40 55 54 53 52 33 6 16 39 38 37
阅读全文
摘要:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example
阅读全文
摘要:Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string.
阅读全文
摘要:Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the posi
阅读全文
摘要:Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Example 1: Input: "aba" Output: True Exa
阅读全文
摘要:Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: Input: "le
阅读全文
摘要:Given a non-negative integer c, your task is to decide whether there're two integers a and bsuch that a2 + b2 = c. Example 1: Input: 5 Output: True Ex
阅读全文
摘要:https://www.cnblogs.com/Roni-i/p/7774100.html https://www.cnblogs.com/Roni-i/p/9253303.html 几百年前就会双指针了,但是Java有些语法还不熟练。。 (ps:双指针利用序列的递增性
阅读全文
摘要:把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 Step1.和二分查找
阅读全文
摘要:给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。 ①节点右孩子存在,则设置一个指针从该节点的右孩子出发,一直沿着指向左子结点的指针找到的叶子节点即为下一个节点; 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的
阅读全文
摘要:private boolean isBalanced = true; public boolean IsBalanced_Solution(TreeNode root) { height(root); return isBalanced; } public int height(TreeNode root) { ...
阅读全文
摘要:class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val) { this.val = val; } } public class Solution { public int Tree...
阅读全文

浙公网安备 33010602011771号