10 2022 档案
摘要:216. Combination Sum III Find all valid combinations of k numbers that sum up to n such that the following conditions are true: Only numbers 1 through
阅读全文
摘要:回溯算法理论基础 回溯法也可以叫做回溯搜索法,它是一种搜索的方式。 回溯是递归的副产品,只要有递归就会有回溯。 回溯的本质是穷举,穷举所有可能,然后选出我们想要的答案,如果想让回溯法高效一些,可以加一些剪枝的操作,但也改不了回溯法就是穷举的本质。 回溯法,一般可以解决如下几种问题: 组合问题:N个数
阅读全文
摘要:669. Trim a Binary Search Tree Given the root of a binary search tree and the lowest and highest boundaries as low and high, trim the tree so that all
阅读全文
摘要:235. Lowest Common Ancestor of a Binary Search Tree Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in
阅读全文
摘要:530. Minimum Absolute Difference in BST Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any
阅读全文
摘要:654. Maximum Binary Tree You are given an integer array nums with no duplicates. A maximum binary tree can be built recursively from nums using the fo
阅读全文
摘要:513. Find Bottom Left Tree Value Given the root of a binary tree, return the leftmost value in the last row of the tree. Example 1: Input: root = [2,1
阅读全文
摘要:110. Balanced Binary Tree Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a bi
阅读全文
摘要:104. Maximum Depth of Binary Tree Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes alon
阅读全文
摘要:102. Binary Tree Level Order Traversal Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to rig
阅读全文
摘要:Binary Trees 树是由结点或顶点和边组成的(可能是非线性的)且不存在着任何环的一种数据结构。没有结点的树称为空(null或empty)树。一棵非空的树包括一个根结点,还(很可能)有多个附加结点,所有结点构成一个多级分层结构。 Binary Tree 的每个结点至多拥有两棵子树(即二叉树中不
阅读全文
摘要:150. Evaluate Reverse Polish Notation Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, and /. E
阅读全文
摘要:Stack & Queue 队列是先进先出 栈是先进后出 QUEUE 在 FIFO 数据结构中,将首先处理添加到队列中的第一个元素。 插入(insert)操作也称作入队(enqueue),新元素始终被添加在队列的末尾。 删除(delete)操作也被称为出队(dequeue)。 你只能移除第一个元素。
阅读全文