随笔分类 -  leetcode

algorithn
摘要:题目链接 https://leetcode cn.com/problems/merge two binary trees/description/ 题目描述 给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。 你需要将他们合并为一个新的二叉树。合并的规则是如果两个 阅读全文
posted @ 2018-08-27 11:09 DCREN 阅读(191) 评论(0) 推荐(0)
摘要:题目链接 https://leetcode cn.com/problems/invert binary tree/description/ 题目描述 翻转一颗二叉树 示例 输入: 输出: ` 题解 使用递归的方式来求解。需要注意的是,在翻转的过程中,注意保存树节点的一个副本,不然在后面的翻转中会存在 阅读全文
posted @ 2018-08-27 09:39 DCREN 阅读(115) 评论(0) 推荐(0)
摘要:题目链接 https://leetcode cn.com/problems/maximum binary tree/description/ 题目描述 给定一个不含重复元素的整数数组。一个以此数组构建的最大二叉树定义如下: 1. 二叉树的根是数组中的最大元素。 2. 左子树是通过数组中最大值左边部分 阅读全文
posted @ 2018-08-27 09:33 DCREN 阅读(459) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-07-31 11:34 DCREN 阅读(186) 评论(0) 推荐(0)
摘要:Description Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) compl 阅读全文
posted @ 2018-07-30 14:29 DCREN 阅读(147) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-07-30 12:10 DCREN 阅读(218) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-07-30 10:43 DCREN 阅读(158) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-07-27 15:35 DCREN 阅读(255) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-07-27 14:28 DCREN 阅读(284) 评论(0) 推荐(0)
摘要:To Lower Case Description Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. Example 1: Examp 阅读全文
posted @ 2018-07-27 12:47 DCREN 阅读(402) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-07-27 12:17 DCREN 阅读(205) 评论(0) 推荐(0)