7 X丶

尚未进行身份认证

暂无相关简介

等级
TA的排名 8w+

离散化--个人总结

使用离散化的一般情况:1⃣️ 数据的值的范围太大,但数据的量并不多2⃣️ 值的大小不重要,重要的是值之间的大小关系离散化一般方法:1⃣️ 排序2⃣️ 去重3⃣️ 形成新的映射例子:https://www.cnblogs.com/farewell-farewell/p/5330429.html常用到的STL库函数:unique(start,end...

2019-11-16 20:38:08

在有序数字中寻找和为k的两个数 O(n)

思路:分别在有序数字串的两头向中间遍历 bool findTarget(vector<int> &nums,int k) { for(i=0,j=nums.size()-1;i<j;){ if(nums[i]+nums[j]==k)return true; (nums[i]+nums[j]&...

2019-05-19 21:54:36

865. Smallest Subtree with all the Deepest Nodes(‘找小弟’思想)

problem:Given a binary tree rooted atroot, thedepthof each node is the shortest distance to the root.A node isdeepestif it has the largest depth possible amongany node in theentire tree....

2019-05-19 21:46:39

951. Flip Equivalent Binary Trees(左右交叉走思想)

problem:For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.A binary tree Xisflip equivalentto a binary tree Y if and on...

2019-05-17 20:03:22

1026. Maximum Difference Between Node and Ancestor(递归+记录最大最小值)

problem:Given therootof a binary tree, find the maximum valueVfor which there existsdifferentnodesAandBwhereV = |A.val - B.val|andAis an ancestor ofB.(A node A is an ancestor of B ...

2019-05-17 19:49:26

889. Construct Binary Tree from Preorder and Postorder Traversal (用stack构建树)

Return any binary tree that matches the given preorder and postorder traversals.Values in the traversalspreandpostare distinctpositive integers.Example 1:Input: pre = [1,2,4,5,3,6,7], ...

2019-05-17 11:34:52

669. Trim a Binary Search Tree(‘找小弟’思想)

problem:Given a binary search tree and the lowest and highest boundaries asLandR, trim the tree so that all its elements lies in[L, R](R >= L). You might need to change the root of the tree...

2019-05-17 11:13:57

872. Leaf-Similar Trees(迭代法配合stack获取所有叶子结点)

problem:Consider all the leaves of a binary tree. Fromleft to right order, the values of thoseleaves form aleaf value sequence.For example, in the given tree above, the leaf value sequence ...

2019-05-17 10:51:51

1008. Construct Binary Search Tree from Preorder Traversal(lower and upper)

Return the root node of a binarysearchtree that matches the givenpreordertraversal.(Recall that a binary search treeis a binary tree where for everynode, any descendant ofnode.lefthas a val...

2019-05-13 15:02:25

1028. Recover a Tree From Preorder Traversal(用stack构建树)

problem:We run apreorderdepth first search on therootof a binary tree.At each node in this traversal, we outputDdashes (whereDis thedepthof this node), then we output the value of this ...

2019-05-13 14:37:09

617. Merge Two Binary Trees(‘抢小弟’思想)

problem:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new ...

2019-05-12 22:35:06

979. Distribute Coins in Binary Tree

Problem:Given therootof a binary tree withNnodes, eachnodein the tree hasnode.valcoins, and there areNcoins total.In one move, we may choose two adjacent nodes and move one coin from on...

2019-05-12 22:02:53

Maximum Binary Tree

Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array. The left subtree is the maximum tree constructed ...

2019-05-10 11:45:54

My Calendar

leetcode problem:My Calendar1Implement aMyCalendarclass to store your events. A new event can be added if adding the event will not cause a double booking.Your class will have the method,book(...

2019-05-10 11:21:54

856. 括号的分数

problem:给定一个平衡括号字符串S,按下述规则计算该字符串的分数:()得 1 分。 AB得A + B分,其中 A 和 B 是平衡括号字符串。 (A)得2 * A分,其中 A 是平衡括号字符串。示例 1:输入: "()"输出: 1示例 2:输入: "(())"输出: 2示例3:输入: "()()"输出: 2示例...

2019-05-04 09:32:01

739.每日温度

题目:根据每日气温列表,请重新生成一个列表,对应位置的输入是你需要再等待多久温度才会升高的天数。如果之后都不会升高,请输入0来代替。例如,给定一个列表temperatures = [73, 74, 75, 71, 69, 72, 76, 73],你的输出应该是[1, 1, 4, 2, 1, 1, 0, 0]。提示:气温列表长度的范围是[1, 30000]。每个气温的值的都是...

2019-05-03 20:13:09

94. 二叉树的中序遍历(迭代)

用栈记录走过的位置,当遇到NULL结点时,用栈pop进行回溯//回溯到父节点后,应该马上进入父结点的 右结点,这样就可以避免重复进入左结点(相当于递归回到当前层的时候,只是继续执行上次剩下没执行的语句,而不是把当前层的所有代码都执行一遍)/** * Definition for a binary tree node. * struct TreeNode { * int...

2019-05-02 22:13:01

1021. 删除最外层的括号

思路:stack在两次empty之间,括号存在闭合,那么我们可以分别记录两次empty时的索引,最后用索引提取字符串class Solution {public: string removeOuterParentheses(string str) { string ans=""; stack<char> s; i...

2019-05-02 18:33:25

铁轨(6-2)

判断出栈顺序是否正确:如果与栈顶相同#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<stack>using namespace std;#define maxn 100int main() { int n; int s[maxn],t[maxn];//入栈元素s , 判断元素t i...

2019-05-02 16:46:42

DNN的BP推导

向前传播:第一层第二层第三层计算代价:反向传播:这是一个求偏导数的线路图 我们会发现,这都是有规律的: 每一列都是一样的,也就是我们可以通过从结果J反向求偏导数,累积偏导数来反向递推计算每一层的和也就是我们可以根据上一项的梯度(grad)来进一步求出下一项的梯度(gra...

2019-04-30 13:34:33

查看更多

勋章 我的勋章
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
  • 勤写标兵Lv3
    勤写标兵Lv3
    授予每个自然周发布7篇到8篇原创IT博文的用户。本勋章将于次周周三上午根据用户上周的博文发布情况由系统自动颁发。