给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。 你的算法时间复杂度必须是 O(log n) 级别。 如果数组中不存在目标值,返回 [-1, -1]。 示例 1: 输入: nums = [5,7,7,8,8,10], target = ...
分类:
编程语言 时间:
2020-07-19 16:33:02
阅读次数:
61
#树状数组 又名二叉索引树,是一种与线段树相似的数据结构 他们能使对一个区间的数修改以及查询的速度提升许多 ##树状数组模板1 #include<iostream> #include<cstdio> using namespace std; int tree[2333333]; int sum[23 ...
分类:
其他好文 时间:
2020-07-19 16:06:22
阅读次数:
52
链接:https://leetcode-cn.com/problems/recover-binary-search-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode ...
分类:
其他好文 时间:
2020-07-19 11:36:41
阅读次数:
70
链接:https://leetcode-cn.com/problems/same-tree/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode ...
分类:
其他好文 时间:
2020-07-19 11:33:58
阅读次数:
44
此博客链接: https://www.cnblogs.com/ping2yingshi/p/13337999.html 搜索插入位置 题目链接:https://leetcode-cn.com/problems/search-insert-position/submissions/ 给定一个排序数组和 ...
分类:
其他好文 时间:
2020-07-19 00:56:40
阅读次数:
101
[编程题] lc:236. 二叉树的最近公共祖先 题目描述 输入输出例子 思路 使用后续遍历的思想,根据找到了左和右的情况,进行相应的返回结果。 Java代码 /** * Definition for a binary tree node. * public class TreeNode { * i ...
分类:
其他好文 时间:
2020-07-19 00:39:06
阅读次数:
85
抓取一波知乎表情图呀,表情来源于知乎某个提问,地址为 https://www.zhihu.com/question/311745535. import requests import re import os class CrawlImg: def __init__(self): self.ques ...
分类:
其他好文 时间:
2020-07-19 00:37:54
阅读次数:
84
struct BinaryTreeNode { int nvalue=0; BinaryTreeNode* pleft = nullptr; BinaryTreeNode* pright = nullptr; BinaryTreeNode* parent = nullptr;};vector<vec ...
分类:
其他好文 时间:
2020-07-18 22:37:14
阅读次数:
87
题解:层次遍历的基础上加个计数器,偶数层得到的结果反转一下 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeN ...
分类:
其他好文 时间:
2020-07-18 21:52:24
阅读次数:
59
解题:利用队列先进先出来实现层次遍历 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) ...
分类:
其他好文 时间:
2020-07-18 19:52:44
阅读次数:
68