We define a harmonious array is an array where the difference between its maximum value and its minimum…
分类:LeetCode
[LeetCode] Path Sum IV 二叉树的路径和之四
If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-dig…
LeetCode | Insert Interval(插入区间)
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa…
滑动窗口的最大值
题目描述 给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针…
LeetCode算法题-Contains Duplicate II(Java实现)
这是悦乐书的第193次更新,第197篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第53题(顺位题号是219)。给定整数数组和整数k,找出数组中是否存在两个不同的索引i和j,使得nums […
LeetCode算法题-Intersection of Two Arrays II(Java实现)
这是悦乐书的第208次更新,第220篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第76题(顺位题号是350)。给定两个数组,编写一个函数来计算它们的交集。例如: 输入:nums1 = [1…
binary-tree-postorder-traversal
title: binary-tree-postorder-traversal 描述 Given a binary tree, return the postorder traversal of its nodesR…
二刷297. Serialize and Deserialize Binary Tree
Hard 这道题给的例子我一眼看去觉得是Level Order在做遍历,所以索性就用层级遍历做吧。在deserialize那块index的问题上纠结了很长时间,仍然不是很确定 /** * Definition for a…
Leetcode 228. Summary Ranges
Given a sorted integer array without duplicates, return the summary of its ranges. Example 1: Input: [0,1,2,4,…
298. Binary Tree Longest Consecutive Sequence
/* * 298. Binary Tree Longest Consecutive Sequence My Submissions QuestionEditorial Solution Total Accepted: 9…
[LeetCode] 3Sum Closest 最近三数之和, 3Sum 三数之和
Given an array S of n integers, find three integers in S such that the su…
[LeetCode] Friend Circles 朋友圈
There are N students in a class. Some of them are friends, while some are not. Their friendsh…