105. Construct Binary Tree from Preorder and Inorder Traversal https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ desc 递归。同106,由于树中无重复元素,可以用map记录inorder中元素到index的映射,这样就不用在生成树时遍历inorder查找元素了,这样可以把时间复杂度降为...
Example 1:Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1....
本文链接:https://blog.csdn.net/sjt091110317/article/details/118445178智能推荐451. Sort Characters By Frequency Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must ap...
Explanation: The good meals are (1,1) with 3 ways, (1,3) with 9 ways, and (1,7) with 3 ways. Constraints: 1 <= deliciousness.length <= 105 0 <= deliciousness[i] <= 220 分析 题目的意思是:给你一个数组,求出其中能够构成2的n次方的对数,我参考了一下别人的思路,很巧妙,首先用字典...
此工具的软件安装包,Github下载地址如下: https://github.com/jackzhenguo/leetcode-csharp/tree/master/LeetCodeTool 或者CSDN下载地址: http://download.csdn.net/my/uploads 关于软件的源码下载地址为,Github下载地址如下: https://github.com/jackzhenguo/LeetCodeManager 或者csdn源码下载地址: http://download....
-105 <= nums[i] <= 105 二、反思 1.自己的解法 class Solution { public: bool isMonotonic(vector<int>& nums) { int n=nums.size(); int index_1=0; int index_2=0; for (int i=0;i<n-1;i++){ if(nums[i]<nums[i+1]){ index_1++; }else if(nums[i]>nums[i+1]){ index_...
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree. Example : Input: root = [4,2,6,1,3,null,null] Output: 1 1 2 Explanation: Note that root is a TreeNode object, not an array. The...