算法
文章平均质量分 63
橙子爱吃蛋
慢慢成长,做一个高级的程序员。
展开
-
数据结构整理
并查集并查集:并查集介绍并查集相关题目:leetcode 399减法求值binary index tree 树状数组树状数组介绍:树状数组(Binary Indexed Tree),看这一篇就够了树状数组(Binary Indexed Tree)原创 2021-09-23 10:25:23 · 81 阅读 · 0 评论 -
进化算法总览
1.遗传算法2.差分进化算法https://zhuanlan.zhihu.com/p/112471225原创 2021-06-16 10:14:14 · 534 阅读 · 0 评论 -
深度学习中的指标总结
对于一个二分类问题,我们定义如下指标:TP:True Positive,即正确预测出的正样本个数 FP:False Positive,即错误预测出的正样本个数(本来是负样本,被我们预测成了正样本) TN:True Negative,即正确预测出的负样本个数 FN:False Negative,即错误预测出的负样本个数(本来是正样本,被我们预测成了负样本)1.分类: 1)正确率(accuracy) 正确率是我们最常见的评价指标,accuracy = (TP+TN)/(P...原创 2020-10-17 10:42:28 · 993 阅读 · 0 评论 -
leetcode question 103 : Binary Tree Zigzag Level Order Traversal
问题:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary tre...原创 2018-04-24 21:37:24 · 104 阅读 · 0 评论 -
leetcode question 104 : Maximum Depth of Binary Tree
问题: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no...原创 2018-04-24 21:48:42 · 118 阅读 · 0 评论 -
leetcode question 105 : Construct Binary Tree from Preorder and Inorder Traversal
问题:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder = [3,9,20,15,7]inorder = [9,3,15,2...原创 2018-05-10 16:48:36 · 155 阅读 · 0 评论 -
leetcode question 106 :Construct Binary Tree from Inorder and Postorder Traversal
问题:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder = [9,3,15,20,7]postorder = [9,15,7...原创 2018-05-10 16:57:46 · 125 阅读 · 0 评论 -
leetcode question 116、117: Populating Next Right Pointers in Each Node(Ⅱ)
问题:Given a binary treestruct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next;}Populate each next pointer to point to its next right node. If there is no next ...原创 2018-10-02 21:04:42 · 118 阅读 · 0 评论 -
leetcode question 129: Sum Root to Leaf Numbers
问题:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the...原创 2018-10-02 22:03:28 · 126 阅读 · 0 评论 -
leetcode question 144:Binary Tree Preorder Traversal
问题:Given a binary tree, return the preorder traversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,2,3]Follow up: Recursive solution is trivial, ...原创 2018-10-03 21:01:15 · 129 阅读 · 0 评论 -
leetcode question 145:Binary Tree Postorder Traversal
问题:Given a binary tree, return the postorder traversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [3,2,1]Follow up: Recursive solution is trivial,...原创 2018-10-03 21:24:35 · 116 阅读 · 0 评论 -
leetcode question 114: Flatten Binary Tree to Linked List
问题:Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 \...原创 2018-09-27 10:46:25 · 114 阅读 · 0 评论 -
leetcode question 113: Path Sum II
问题:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note: A leaf is a node with no children.Example:Given the below binary tree and sum = 2...原创 2018-09-27 10:56:30 · 147 阅读 · 0 评论 -
leetcode question 199:Binary Tree Right Side View
问题:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.Example:Input: [1,2,3,null,5,null,4]Output: [1,...原创 2018-10-06 20:53:09 · 146 阅读 · 0 评论 -
leetcode question 102 : Binary Tree Level Order Traversal
问题:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 /...原创 2018-04-24 21:07:01 · 134 阅读 · 0 评论 -
leetcode question 100:Same Tree
题目:Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1...原创 2018-04-12 11:54:07 · 145 阅读 · 0 评论 -
leetcode question 27:Remove Element
问题:Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-pla...原创 2018-03-06 20:23:45 · 113 阅读 · 0 评论 -
leetcode question 31:Next Permutation
问题:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible ...原创 2018-03-07 14:41:20 · 125 阅读 · 0 评论 -
leetcode question 33:Search in Rotated Sorted Array
问题:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in th...原创 2018-03-07 15:30:02 · 85 阅读 · 0 评论 -
leetcode question 34:Search for a Range
问题:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the targe...原创 2018-03-07 20:21:46 · 112 阅读 · 0 评论 -
leetcode question 35:Search Insert Position
问题:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.E...原创 2018-03-09 10:20:06 · 118 阅读 · 0 评论 -
leetcode question 16: 3Sum Closest
问题:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exac...原创 2018-03-02 11:11:20 · 127 阅读 · 0 评论 -
leetcode question 18: 4Sum
问题:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution se...原创 2018-03-05 23:43:36 · 134 阅读 · 0 评论 -
leetcode question 42: Trapping Rain Water
问题:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], r...原创 2018-03-14 16:30:41 · 134 阅读 · 0 评论 -
leetcode question 41:First Missing Positive
问题:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.分析...原创 2018-03-14 16:49:41 · 128 阅读 · 0 评论 -
leetcode question 94:Binary Tree Inorder Traversal
题目:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recursive solution is trivial, co...原创 2018-03-26 11:22:38 · 112 阅读 · 0 评论 -
leetcode question 95: Unique Binary Search Trees II
题目:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 ...原创 2018-04-02 19:43:19 · 116 阅读 · 0 评论 -
leetcode question 98:Validate Binary Search Tree
转载自:StudyCoder题目:验证二叉搜索树Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than t...转载 2018-04-02 20:39:50 · 109 阅读 · 0 评论 -
leetcode question 96:Unique Binary Search Trees
转自:点击打开链接Given 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 3 3 2 1 \...转载 2018-03-27 20:43:55 · 138 阅读 · 0 评论 -
leetcode question 26:Remove Duplicates from Sorted Array
问题:Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying t...原创 2018-03-06 19:53:42 · 128 阅读 · 0 评论