随笔分类 - 代码随想录训练营
60天刷题计划
摘要: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)。 你只能移除第一个元素。
阅读全文
摘要:459. Repeated Substring Pattern Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the subs
阅读全文
摘要:28. Find the Index of the First Occurrence in a String Given two strings needle and haystack, return the index of the first occurrence of needle in ha
阅读全文
摘要:344. Reverse String Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the
阅读全文
摘要:454. 4Sum II Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that: 0 <= i, j,
阅读全文
摘要:Hash table 一般哈希表都是用来快速判断一个元素是否出现集合里。 例如要查询一个名字是否在这所学校里。 要枚举的话时间复杂度是O(n),但如果使用哈希表的话, 只需要O(1)就可以做到。 Hash Function 通过hashCode把名字转化为数值,一般hashcode是通过特定编码方式
阅读全文
摘要:24. Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the value
阅读全文
摘要:###链表理论基础 链表是一种通过指针串联在一起的线性结构,每一个节点由两部分组成,一个是数据域(Node) 一个是指针域(Next),最后一个节点的指针域指向null。 链接的入口节点称为链表的头结点也就是head。 单链表中的指针域只能指向节点的下一个节点。 双链表:每一个节点有两个指针域,一个
阅读全文