文章库ARTICLE COLUMN

  • [Leetcode-Dynamic Programming]Unique Binary Search

    [Leetcode-Dynamic Programming]Unique Binary Search

    Unique Binary Search TreesGiven n, how many structurally unique BST"s (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST"s. 1 ...

    MartinDaiMartinDai 评论0 收藏0
  • [Leetcode-Tree] Sum Root to Leaf Numbers

    [Leetcode-Tree] Sum Root to Leaf Numbers

    摘要:解题思路本题要求所有从根结点到叶子节点的路径和,我们用递归实现。结束条件当遇到叶子节点时,直接结束,返回计算好的如果遇到空节点,则返回数值。 Sum Root to Leaf NumbersGiven a binary tree containing digits from 0-9 only, each root-to-le...

    BigNerdCodingBigNerdCoding 评论0 收藏0
  • [Leetcode-Tree]Binary Tree Maximum Path Sum

    [Leetcode-Tree]Binary Tree Maximum Path Sum

    摘要:但是本题的难点在于,使用递归实现,但是前面的第四种情况不能作为递归函数的返回值,所以我们需要定义两个值,代表单边路径的最大值,用于递归用于和回路的较大值。 Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum. Fo...

    caigecaige 评论0 收藏0
  • [Leetcode-Tree]Binary Tree Level Order Traversal

    [Leetcode-Tree]Binary Tree Level Order Traversal

    摘要:解题思路层次遍历二叉树,我们采用队列,本题的注意点是需要分割出每一层的序列,所以在从队列中取元素之前,我们要先记录队列的大小,以表示这一层中节点的个数。 Binary Tree Level Order TraversalGiven a binary tree, return the level order tra...

    HalfHalf 评论0 收藏0
  • [Leetcode-Tree]Maximum / Minimum Depth of Binary T

    [Leetcode-Tree]Maximum / Minimum Depth of Binary T

    摘要:解题思路用递归实现很简单,对于每个根节点,最大深度就等于左子树的最大深度和右子树的最大深度的较大值。解题思路本题的注意点在于如果某个根节点有一边的子树为空,那么它的深度就等于另一边不为空的子树的深度,其他的逻辑与上一题相同。 Maximum ...

    ThanatosThanatos 评论0 收藏0
  • [Leetcode-Tree]Delete Node in a BST

    [Leetcode-Tree]Delete Node in a BST

    摘要:解题思路我们可以用递归来查找,在找到需要删除的节点后,我们需要分情况讨论节点是叶子节点,直接返回节点有一个孩子,直接返回孩子节点有两个孩子,我们要将右子树中最小的节点值赋值给根节点,并在右子树中删除掉那个最小的节点。 Delete Node in a...

    wangjuntytlwangjuntytl 评论0 收藏0
  • Construct Binary Tree from Preorder and Inorder Tr

    Construct Binary Tree from Preorder and Inorder Tr

    摘要:解题思路利用递归思想,先序遍历的第一个元素就是根节点,然后在中序遍历中寻找该节点,该节点左边的就是左子树,右边的是右子树。 Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, const...

    tuomaotuomao 评论0 收藏0
  • Leetcode[76] Minimum Window Substring

    Leetcode[76] Minimum Window Substring

    LeetCode[76] Minimum Window Substring Given a string S and a string T, find the minimum window in S whichwill contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC&...

    suemisuemi 评论0 收藏0
  • [Leetcode-Tree] Path Sum I II III

    [Leetcode-Tree] Path Sum I II III

    摘要:解题思路利用递归,对于每个根节点,只要左子树和右子树中有一个满足,就返回每次访问一个节点,就将该节点的作为新的进行下一层的判断。代码解题思路本题的不同点是可以不从开始,不到结束。代码当前节点开始当前节点左节点开始当前节点右节点开始 Pa...

    notebinnotebin 评论0 收藏0
  • [Leetcode-Tree] Convert Sorted Array to Binary Sea

    [Leetcode-Tree] Convert Sorted Array to Binary Sea

    摘要:解题思路平衡二叉树,其实就是数组中间的数作为根,利用递归实现左子树和右子树的构造。 Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST. 1.解题思路...

    songzesongze 评论0 收藏0
  • Gecco的网络爬虫例子

    Gecco的网络爬虫例子

    摘要:到了这个时候,我们已经可以把京东的分类首页的手机模块给抓取下来,并且保存成。 GeccoSpider爬虫例子 前些天,想要用爬虫抓取点东西,但是网上很多爬虫都是使用python语言的,本人只会java,因此,只能找相关java的爬虫资料,在开源中国的看到国内的...

    raoyiraoyi 评论0 收藏0
  • [Leetcode-Tree]Sum of Left Leaves

    [Leetcode-Tree]Sum of Left Leaves

    摘要:解题思路这个题目其实就是基于先序遍历,用递归和非递归思想都可以。递归求所有左叶子节点的和,我们可以将其分解为左子树的左叶子和右子树的左叶子和递归结束条件找到左叶子节点,就可以返回该节点的。代码非递归判断是否为左叶子节点递归 Sum of Lef...

    asheashe 评论0 收藏0
  • [Leetcode]Longest Substring Without Repeating Char

    [Leetcode]Longest Substring Without Repeating Char

    摘要:解题思路本题借助实现。如果字符未出现过,则字符,如果字符出现过,则维护上次出现的遍历的起始点。注意点每次都要更新字符的位置最后返回时,一定要考虑到从到字符串末尾都没有遇到重复字符的情况,所欲需要比较下和的大小。 Longest Substring With...

    awesome23awesome23 评论0 收藏0
  • Ummm... Java8和lambda

    Ummm... Java8和lambda

    摘要:引入了与此前完全不同的函数式编程方法,通过表达式和来为下的函数式编程提供动力。命令式编程语言把对象变量和流转当作一等公民,而函数式编程在此基础上加入了策略变量这一新的一等公民。 Java8引入了与此前完全不同的函数式编程方法,通过Lambda表...

    LMouLMou 评论0 收藏0
  • [LeetCode]Find All Anagrams in a String

    [LeetCode]Find All Anagrams in a String

    摘要:解题思路,就是只顺序不同但个数相同的字符串,那我们就可以利用的思想来比较每个字符串中字符出现的个数是否相等。 Find All Anagrams in a StringGiven a string s and a non-empty string p, find all the start indices of p"s anagrams in s. Str...

    niceforbearniceforbear 评论0 收藏0
  • [Leetcode - Array] Combination Sum

    [Leetcode - Array] Combination Sum

    摘要:解题思路对数组进行排序,每次加入第个数后,就减去这个数,并作为新的,进行递归。如果,则说明本次无解如果,则将本序列组合加入结果集中。题意其实就是从数组中选出个数,使得等于。 Combination SumGiven a set of candidate numbers (C) and a ta...

    JackJiangJackJiang 评论0 收藏0
  • RequestBody 报错解决方法

    RequestBody 报错解决方法

    摘要:注本文使用作为序列化和反序列化库如果请求为多层级或者数据量大比较复杂的时候可以考虑采用的方式也就是设置请求方法为中为中是一个字符串在中接收的方式就是采用注解比如但有时这个会抛出类似这样的异常产生这个异常的原因是请求的中包含了这个类没定...

    raledongraledong 评论0 收藏0
  • 下载镜像网站所有文件

    下载镜像网站所有文件

    摘要:镜像网站还没有改成多线程下载所以下载速度较慢流程就是先获取资源的写入文件然后下载如果下载中程序意外终止会保存程序当前的下载状态下次重启下载程序即可继续下载源码地址 镜像网站:showImg("https://segmentfault.com/img/bVFEiE?w=594&h=417"); ...

    番茄西红柿番茄西红柿 评论0 收藏0
  • [LeetCode - Dynamic Programming] Coin Change

    [LeetCode - Dynamic Programming] Coin Change

    摘要:解题思路动态规划,用表示总价为的最小纸币张数,很容易想到状态转移方程当然前提是要大于纸币金额数。表示取一张面额加上合计为的最小纸币数。另题目要求无法合计出的金额,要返回,所以要作特殊处理,否则就会返回元素初始化值代码 Coin ChangeYou a...

    dackeldackel 评论0 收藏0
  • Java基础学习——多线程之单例设计模式(转)

    Java基础学习——多线程之单例设计模式(转)

    摘要:总之,选择单例模式就是为了避免不一致状态,避免政出多头。二饿汉式单例饿汉式单例类在类初始化时,已经自行实例化静态工厂方法饿汉式在类创建的同时就已经创建好一个静态的对象供系统使用,以后不再改变,所以天生是线程安全的。 概念:  Java中单...

    dendoinkdendoink 评论0 收藏0
  • LeetCode[132] Pattern

    LeetCode[132] Pattern

    摘要:复杂度思路维护一个里面有最大值和最小值。如果当前值小于的最小值,那么就将原来的压进去栈,然后在用这个新的的值再进行更新。如果没有适合返回的值,就重新更新当前的。 Leetcode[132] Pattern Given a sequence of n integers a1, a2, ..., an, a...

    go4itgo4it 评论0 收藏0
  • Leetcode[413] Arithmetic Slices

    Leetcode[413] Arithmetic Slices

    摘要:复杂度思路找数组里面的等差数列的个数。想法是如果一开始三个数就满足是等差数列的话,就在当前已有的数目上不断的累加的结果。 Leetcode[413] Arithmetic Slices A sequence of number is called arithmetic if it consists of at least three elem...

    _ipo_ipo 评论0 收藏0
  • [LeetCode - Backtracking] Combinations

    [LeetCode - Backtracking] Combinations

    摘要:本题与类似,都是用回溯法。求中个数的不同组合,很明显我们需要注意的就是每个数字只能出现一次,这点与不同。 CombinationsGiven two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and ...

    fizzfizz 评论0 收藏0
  • [Leetcode]PermutationsI II Next Permutation Permut

    [Leetcode]PermutationsI II Next Permutation Permut

    摘要:解题思路这道题是要将排列按字典序排列,然后求出下一个排列,一种办法是我们先求出所有的排序情况,但是题目规定不能占有额外空间。每次求出一个数字后,要及时的把它从中删除掉。采用来构造结果序列。 PermutationsGiven a collection of distinct n...

    ChristmasBoyChristmasBoy 评论0 收藏0
  • [Leetcode - Tree] Binary Search Tree Iterator

    [Leetcode - Tree] Binary Search Tree Iterator

    摘要:解题思路对于二叉搜索树,我们很容易会想到使用栈和队列来解决问题,本题是要求实现一个对二叉搜索树的遍历器,要求每次可以返回最小的节点值,我们使用栈。 Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your...

    jsyzchenjsyzchen 评论0 收藏0

热门文章

<