02 2019 档案

摘要:当你把对象加入HashSet时,HashSet会先计算对象的hashcode值来判断对象加入的位置,同时也会和其他加入的对象的hashcode值作比较,如果没有相符的hashcode,HashSet会假设对象没有重复出现,但是如果发现有相同的hashcode值的对象,这时候会调用equals方法来检 阅读全文
posted @ 2019-02-28 14:48 林木声 阅读(1827) 评论(0) 推荐(3)
摘要:执行顺序: 父类 static 子类 static 父类普通代码块 父类 constructor 子类 普通代码块 子类 constructo 阅读全文
posted @ 2019-02-26 16:08 林木声 阅读(196) 评论(0) 推荐(0)
摘要:题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in t 阅读全文
posted @ 2019-02-24 15:39 林木声 阅读(322) 评论(0) 推荐(0)
摘要:题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or anothe 阅读全文
posted @ 2019-02-24 15:30 林木声 阅读(132) 评论(0) 推荐(0)
摘要:题目: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – R 阅读全文
posted @ 2019-02-24 15:19 林木声 阅读(116) 评论(0) 推荐(0)
摘要:题目: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999 解答: 阅读全文
posted @ 2019-02-23 15:49 林木声 阅读(239) 评论(0) 推荐(0)
摘要:题目: Given a matrix of m ✕ n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, given the following matrix:[[ 阅读全文
posted @ 2019-02-23 15:14 林木声 阅读(102) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example, given the below binary tree,1/ \2 4 阅读全文
posted @ 2019-02-23 14:56 林木声 阅读(102) 评论(0) 推荐(0)
摘要:题目: Given an array where elements are sorted in ascending order, convert it to BST 解答: 阅读全文
posted @ 2019-02-22 16:17 林木声 阅读(134) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the neares 阅读全文
posted @ 2019-02-22 15:47 林木声 阅读(112) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthes 阅读全文
posted @ 2019-02-22 15:42 林木声 阅读(92) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, determine if it is a valid Binary Search Tree (BST) 解答: 阅读全文
posted @ 2019-02-22 15:36 林木声 阅读(108) 评论(0) 推荐(0)
摘要:题目: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contains a si 阅读全文
posted @ 2019-02-21 14:52 林木声 阅读(118) 评论(0) 推荐(0)
摘要:题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists 解答: 阅读全文
posted @ 2019-02-21 14:34 林木声 阅读(275) 评论(0) 推荐(0)
摘要:题目: Determine whether an integer is a palindrome. Do this without extra space 解答: First, compare the first and last digit. If they are not the same, i 阅读全文
posted @ 2019-02-21 14:28 林木声 阅读(169) 评论(0) 推荐(0)
摘要:题目: Given a number represented as an array of digits, plus one to the number 解答: 阅读全文
posted @ 2019-02-21 14:15 林木声 阅读(139) 评论(0) 推荐(0)
摘要:题目: Reverse digits of an integer. For example: x = 123, return 321 解答: 阅读全文
posted @ 2019-02-19 20:29 林木声 阅读(102) 评论(0) 推荐(0)
摘要:题目: The API: int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it r 阅读全文
posted @ 2019-02-19 20:19 林木声 阅读(136) 评论(0) 推荐(0)
摘要:题目: Given two strings S and T, determine if they are both one edit distance apart i. Modify operation – Modify a character to X in S.S = “abcde”T = “a 阅读全文
posted @ 2019-02-18 19:03 林木声 阅读(233) 评论(0) 推荐(0)
摘要:题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo 阅读全文
posted @ 2019-02-18 18:20 林木声 阅读(146) 评论(0) 推荐(0)
摘要:题目: Given a sorted integer array where the range of elements are [0, 99] inclusive, return its missing ranges.For example, given [0, 1, 3, 50, 75], re 阅读全文
posted @ 2019-02-17 12:51 林木声 阅读(243) 评论(0) 推荐(0)
摘要:题目: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter 阅读全文
posted @ 2019-02-16 19:18 林木声 阅读(268) 评论(0) 推荐(0)
摘要:题目: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否存在该整数。 解答: 阅读全文
posted @ 2019-02-16 17:15 林木声 阅读(921) 评论(0) 推荐(0)
摘要:题目: 在一个m×n的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值(价值大于0)。你可以从棋盘的左上角开始拿格子里的礼物,并每次向右或者向下移动一格直到到达棋盘的右下角。给定一个棋盘及其上面的礼物,请计算你最多能拿到多少价值的礼物? 解答: 使用动态规划,f(i,j)表示到达坐标[i,j]时能 阅读全文
posted @ 2019-02-16 14:52 林木声 阅读(358) 评论(0) 推荐(0)
摘要:代码: 测试: 阅读全文
posted @ 2019-02-16 12:01 林木声 阅读(1016) 评论(0) 推荐(0)
摘要:题目: 输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。为简单起见,标点符号和普通字母一样处理 解答: 阅读全文
posted @ 2019-02-15 17:01 林木声 阅读(864) 评论(0) 推荐(0)
摘要:题目: 输入一个递增排序的数组和一个数字 s。 在数组中查找两个数,使得它们的和正好是 s。 如果有多对数字的和等于 s,输出任意一对即可。 解答: 阅读全文
posted @ 2019-02-15 16:52 林木声 阅读(1094) 评论(0) 推荐(0)
摘要:题目: 一个整型数组里除了两个数字之外,其他的数字都出现了两次 解答: 我们从头到尾异或数组中的每个数字,那么最终的结果是两个只出现一次数字的异或的结果,由于两个数字不一样,那么异或的结果肯定不为0,那么这个数字的二进制表示中至少有一位为1。 阅读全文
posted @ 2019-02-15 16:33 林木声 阅读(522) 评论(0) 推荐(0)
摘要:题目: 输入一颗二叉树的根节点,求该树的深度。 解答: 阅读全文
posted @ 2019-02-15 16:21 林木声 阅读(660) 评论(0) 推荐(0)
摘要:题目: 输入两个单向链表,找出它们的第一个公共结点 解答: 阅读全文
posted @ 2019-02-14 15:54 林木声 阅读(386) 评论(0) 推荐(0)
摘要:1 public class Solution { 2 public static void main(String[] args) { 3 4 } 5 6 public static void mergeSort(int[] nums) { 7 int[] tmp = new int[nums.length]; 8 9 ... 阅读全文
posted @ 2019-02-14 15:03 林木声 阅读(188) 评论(0) 推荐(0)
摘要:题目: 在数组中的两个数字如果前面一个数字大于后面的数字, 则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。 解答: 阅读全文
posted @ 2019-02-14 14:14 林木声 阅读(1242) 评论(0) 推荐(0)
摘要:题目: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数。打印能拼接出所有数字中最小的一个。 解答: 阅读全文
posted @ 2019-02-14 12:53 林木声 阅读(1374) 评论(0) 推荐(0)
摘要:题目: 输入一个整型数组,数组里有正数,也有负数。 数组中一个或连续的多个整数组成一个子数组。 求所有子数组的和的最大值。要求时间复杂度为 O(n)。 解答: 阅读全文
posted @ 2019-02-14 12:37 林木声 阅读(1934) 评论(1) 推荐(0)
摘要:题目: 数组中有一个数字出现的次数超过数组长度的一半。请找出这个数字。 解答: 阅读全文
posted @ 2019-02-14 12:29 林木声 阅读(816) 评论(0) 推荐(0)
摘要:题目: 输入一个字符串,打印出该字符串中字符的所有排列 解答: 阅读全文
posted @ 2019-02-13 17:10 林木声 阅读(1836) 评论(0) 推荐(0)
摘要:题目: 输入一颗二叉搜索树,将该二叉搜索树转换成一个排序的双向链表 要求不能创建人和新的结点,只能调整树中结点指针的指向 解答: 阅读全文
posted @ 2019-02-13 13:59 林木声 阅读(309) 评论(0) 推荐(0)
摘要:题目: 输入一颗二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。 解答: 阅读全文
posted @ 2019-02-13 12:35 林木声 阅读(738) 评论(0) 推荐(0)
摘要:题目: 输入一个数组,判断该数组是不是某二叉搜索树的后序遍历结果。 解答: 阅读全文
posted @ 2019-02-13 12:08 林木声 阅读(561) 评论(0) 推荐(0)
摘要:题目: 输入两个整数序列 第一个序列表示栈的压入顺序,第二个序列是弹出序列。 判断第二个序列是否是该栈的弹出序列。 假设所有的入栈的数字均不相等。 解答: 阅读全文
posted @ 2019-02-12 15:30 林木声 阅读(173) 评论(0) 推荐(0)
摘要:题目: Validate if a given string is numeric Some examples:"0" > true"0.1" >true"abc" > false 解答: 阅读全文
posted @ 2019-02-08 16:00 林木声 阅读(170) 评论(0) 推荐(0)
摘要:1 private static final int maxDiv10 = Integer.MAX_VALUE / 10; 2 3 public int atoi(String str) { 4 int i = 0; 5 int n = str.length(); 6 // 首先忽略字符串前面的空格 7 while(i maxDiv10 || n... 阅读全文
posted @ 2019-02-02 18:10 林木声 阅读(157) 评论(0) 推荐(0)
摘要:题目: Given an input string s, reverse the string word by word.For example, given s = "the sky is blue", return "blue is sky the" Example Questions Cand 阅读全文
posted @ 2019-02-02 14:37 林木声 阅读(137) 评论(0) 推荐(0)
摘要:在一个字符串中寻找某个字串 阅读全文
posted @ 2019-02-01 17:26 林木声 阅读(758) 评论(0) 推荐(0)
摘要:题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: 阅读全文
posted @ 2019-02-01 16:28 林木声 阅读(106) 评论(0) 推荐(0)
摘要:题目: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the tw 阅读全文
posted @ 2019-02-01 14:18 林木声 阅读(146) 评论(0) 推荐(0)