Implement next permutation, which rearranges numbers into the lexicographically next greater permutatio…
分类:LeetCode
[LeetCode] Department Highest Salary 系里最高薪水
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column …
[LeetCode] Palindrome Pairs 回文对
Given a list of unique words. Find all pairs of distinct indices (i, j) in the give…
[LeetCode] Arranging Coins 排列硬币
You have a total of n coins that you want to form in a staircase shape, where every k-th row must have …
[LeetCode] Diameter of Binary Tree 二叉树的直径
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a bina…
LeetCode | Longest Consecutive Sequence
题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For exa…
LeetCode | Sum Root to Leaf Numbers
题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a nu…
LeetCode | Add Binary
题目: Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1"…
LeetCode | Maximum Depth of Binary Tree(二叉树的深度)
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path f…
LeetCode算法题-Sum of Left Leaves(Java实现)
这是悦乐书的第217次更新,第230篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第85题(顺位题号是404)。找到给定二叉树中所有左叶的总和。例如: 二叉树中有两个左叶,分别为9和15。 …
Leetcode之653-两数之和IV-输入BST(Two Sum IV - Input is a BST)
前言 个人网站 公众号: 北京程序猿, 网站 : https://yaml.vip 算法题 题干 给定一个二叉搜索树和一个目标结果,如果 BST 中存在两个元素且它们的和等于给定的目标结果,则返回 true。 示例 输入…
算法(4)数据结构:堆
1.0 问题描述 实现数据结构:堆。 2.0 问题分析 堆一般使用数组来表示,其中某个节点下标i的两个子节点的下标为 2i+1 和 2i+2。堆是一棵完全二叉树。 堆有3种基本操作:创建,插入,删除。 这3种操作都需要通…