题目描述 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。如果是则输出Yes,否则输出No。假设输入的数组的任意两个数字都互不相同。 解题思路 二叉搜索树: 左子树<根<=右子树 对于后序遍历…
分类:LeetCode
LeetCode算法题-String Compression(Java实现)
这是悦乐书的第230次更新,第242篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第97题(顺位题号是443)。给定一组字符,就地压缩它。压缩后的长度必须始终小于或等于原始数组。数组的每个元…
LeetCode[9] - Binary Tree Paths
一幕了然. DFS把tree给过了. 用ArrayList存item比较方便,记得每次backtrack的时候把末尾的item去掉 list.remove(list.size() - 1); /* Given a bin…
[LeetCode] Meeting Rooms II 会议室之二
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...]&n…
[LeetCode] Design Excel Sum Formula 设计Excel表格求和公式
Your task is to design the basic function of Excel and implement the function of sum formula. Specifica…
[LeetCode] Implement Magic Dictionary 实现神奇字典
Implement a magic directory with buildDict, and search methods. For the method buil…
LeetCode 240. Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following prope…
LeetCode 总结 - 搞定 Binary Search 面试题
最近实习生面试因为算法题吃了大亏,之前虽然看了《剑指Offer》,LeetCode也刷了差不多几十道题,但是没有实实在在掌握,现在赶紧补上来,希望还不算太晚!这两天一直在刷Binary Search相关tag的题,暂时把…
[LeetCode] Swap Nodes in Pairs 成对交换节点
Given a linked list, swap every two adjacent nodes and return its head. Example: Given 1->2->…
[LeetCode] Search in Rotated Sorted Array II 在旋转有序数组中搜索之二, Search in Rotated Sorted Array 在旋转有序数组中搜索, Search in Rotated Sorted Array 在旋转有序数组中搜索
Follow up for “Search in Rotated Sorted Array”:What if duplicates are allowed? Wo…
[LeetCode] Random Pick with Weight 根据权重随机取点
Given an array w of positive integers, where w[i] describes the weight of index&nbs…
LeetCode 232 Implement Queue using Stacks
题目描述 Implement the following operations of a queue using stacks. push(x) – Push element x to the back of queue…