随笔分类 - leetcode
algorithn
摘要:题目链接 https://leetcode cn.com/problems/merge two binary trees/description/ 题目描述 给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。 你需要将他们合并为一个新的二叉树。合并的规则是如果两个
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/invert binary tree/description/ 题目描述 翻转一颗二叉树 示例 输入: 输出: ` 题解 使用递归的方式来求解。需要注意的是,在翻转的过程中,注意保存树节点的一个副本,不然在后面的翻转中会存在
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/maximum binary tree/description/ 题目描述 给定一个不含重复元素的整数数组。一个以此数组构建的最大二叉树定义如下: 1. 二叉树的根是数组中的最大元素。 2. 左子树是通过数组中最大值左边部分
阅读全文
摘要:Description A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elem
阅读全文
摘要:Description Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) compl
阅读全文
摘要:Description Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent
阅读全文
摘要:Description Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end i
阅读全文
摘要:Description In a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the hei
阅读全文
摘要:Unique Morse Code Words Description International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, a
阅读全文
摘要:To Lower Case Description Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Examp
阅读全文
摘要:Jewels and Stones Description You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each ch
阅读全文

浙公网安备 33010602011771号