这是悦乐书的第285次更新,第302篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第153题(顺位题号是671)。给定非空的特殊二叉树,其由具有非负值的节点组成,其中该树中的每个节点具有恰好…
分类:LeetCode
[剑指offer] 二叉树的深度
本文首发于我的个人博客:尾尾部落 题目描述 输入一棵二叉树,求该树的深度。从根结点到叶结点依次经过的结点(含根、叶结点)形成树的一条路径,最长路径的长度为树的深度。 解题思路 法一:递归法。求二叉树的深度,就是求左子树、…
剑值offer - 把数组排成最小的数
最近又看到一道比较好的题,给大家分享一下。 题目 输入一个正整数,把数组里所有的数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如,输入数组{3,32,321},则打印出这3个数字能排成的最小数字。 思路 …
Leetcode - Insert Delete GetRandom O(1) - Duplicates allowed
My code: public class RandomizedCollection { HashMap<Integer, Set<Integer>> map = new HashMap<I…
[LeetCode By Go 38]Add to List 122. Best Time to Buy and Sell Stock II
题目 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm…
9. Palindrome Number
9. Palindrome Number 题目 Determine whether an integer is a palindrome. Do this without extra space. click to sh…
118. Pascal's Triangle
欢迎fork and star:Nowcoder-Repository-github 118. Pascal’s Triangle 题目 Given numRows, generate the first n…
147. Insertion Sort List
欢迎fork and star:Nowcoder-Repository-github 147. Insertion Sort List 题目 Sort a linked list using insertion sort…
[LeetCode] Construct Binary Tree from Inorder and Postorder Traversal 由中序和后序遍历建立二叉树,Convert Sorted Array to Binary Search Tree 将有序数组转为二叉搜索树
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that d…
[LeetCode] Longest Consecutive Sequence 求最长连续序列
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your…
[LeetCode] Word Frequency 单词频率
Write a bash script to calculate the frequency of each word in a text file words.txt. For simplicity sa…
[LeetCode] Reverse Pairs 翻转对
Given an array nums, we call (i, j) an important reverse pair if i < j…