随笔分类 - Java
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a binary tree, determine if it is a valid Binary Search Tree (BST) 解答:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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 解答:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a number represented as an array of digits, plus one to the number 解答:
阅读全文
摘要:题目: Reverse digits of an integer. For example: x = 123, return 321 解答:
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter
阅读全文
摘要:题目: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否存在该整数。 解答:
阅读全文
摘要:题目: 在一个m×n的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值(价值大于0)。你可以从棋盘的左上角开始拿格子里的礼物,并每次向右或者向下移动一格直到到达棋盘的右下角。给定一个棋盘及其上面的礼物,请计算你最多能拿到多少价值的礼物? 解答: 使用动态规划,f(i,j)表示到达坐标[i,j]时能
阅读全文
摘要:题目: 输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。为简单起见,标点符号和普通字母一样处理 解答:
阅读全文
摘要:题目: 输入一个递增排序的数组和一个数字 s。 在数组中查找两个数,使得它们的和正好是 s。 如果有多对数字的和等于 s,输出任意一对即可。 解答:
阅读全文
摘要:题目: 一个整型数组里除了两个数字之外,其他的数字都出现了两次 解答: 我们从头到尾异或数组中的每个数字,那么最终的结果是两个只出现一次数字的异或的结果,由于两个数字不一样,那么异或的结果肯定不为0,那么这个数字的二进制表示中至少有一位为1。
阅读全文
摘要:题目: 输入一颗二叉树的根节点,求该树的深度。 解答:
阅读全文
摘要:题目: 输入两个单向链表,找出它们的第一个公共结点 解答:
阅读全文

浙公网安备 33010602011771号