algorithm-design
文章平均质量分 63
纸上得来终觉浅 绝知此事要躬行
github.com/luqian2017
展开
-
关于素数的算法小结
1. 判断一个数是不是素数解法1:最经典的版本 1 #include <stdio.h> 2 #include <math.h> 3 #include <stdbool.h> //C99 supports bool type 4 5 bool is_prime(int n) { 6 if (n <= 3) return n > 1; 7 int sqrt_n = sqrt(n); 8 9原创 2020-10-02 11:30:59 · 295 阅读 · 0 评论 -
动态规划题型总结
参考九章的资料。前4种常考。1. 坐标型: 在第i个节点会怎么样 例题:Triangle, Unique Paths, Jump Game, 飞行棋I2. 前缀型: 前i个节点怎么怎么样,分为匹配型和划分型 匹配型: dp[i][j]表示word 1的前i个字符和word 2的前j个字符的最优xxx值。例题:LCS, wild card match? 划分型:例题: word break3. 区间型: 例题: Stone game, 最长回文串4. 背包型:其实属于...原创 2020-07-31 13:30:15 · 335 阅读 · 0 评论 -
LintCode 253: Minimum Type Way (双序列DP好题)
253.Minimum Type WayYou are given a string only contains lower or upper English characters that you want to type.At the beginning, the Capslock is off, it's at a state of lower characters, you are required that after typing it should still be at lower .原创 2020-06-13 15:45:46 · 295 阅读 · 0 评论 -
Leetcode 1325. Delete Leaves With a Given Value (二叉树后序遍历经典题)
Leetcode 1325: 二叉树后序遍历经典题原创 2024-02-20 16:51:43 · 419 阅读 · 0 评论 -
Lintcode 614 · Binary Tree Longest Consecutive Sequence II (二叉树后序遍历好题)
LintCode 614: 二叉树后序遍历好题原创 2024-02-20 16:26:04 · 339 阅读 · 0 评论 -
Leetcode 563. Binary Tree Tilt (二叉树后序遍历好题)
Leetcode 563: 二叉树后序遍历好题原创 2024-02-20 04:02:53 · 1044 阅读 · 0 评论 -
Leetcode 508. Most Frequent Subtree Sum (二叉树后序遍历好题)
Leetcode 508: 后序遍历好题原创 2024-02-20 03:42:31 · 411 阅读 · 0 评论 -
LintCode 650 · Find Leaves of Binary Tree (binary tree 后序遍历非常好的题目!)
LintCode 650: 二叉树后序遍历好题!原创 2024-02-20 02:56:58 · 333 阅读 · 0 评论 -
LeetCode 250. Count Univalue (二叉树后序遍历好题)
Leetcode 250: 二叉树遍历好题原创 2024-02-16 17:41:31 · 488 阅读 · 0 评论 -
Leetcode 333. Largest BST Subtree (二叉树后序遍历好题)
Leetcode 333: 二叉树后序遍历好题原创 2024-02-16 08:01:30 · 495 阅读 · 0 评论 -
LintCode 3687 · Check If an Array Is a Valid Sequence (二叉树遍历和分治好题)
LintCode 3687: 二叉树遍历和分治好题原创 2024-02-07 17:26:59 · 371 阅读 · 0 评论 -
Leetcode 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree (二叉树遍历和分治好题)
Leetcode 1379: 二叉树遍历和分治好题原创 2024-02-07 16:30:49 · 321 阅读 · 0 评论 -
Leetcode 897. Increasing Order Search Tree (二叉树遍历和分治好题)
Leetcode 897:二叉树遍历和分治好题原创 2024-02-06 15:40:21 · 449 阅读 · 0 评论 -
Leetcode 951. Flip Equivalent Binary Trees (二叉树翻转题)
Leetcode 951: 二叉树翻转题原创 2024-01-31 03:16:04 · 367 阅读 · 0 评论 -
LintCode 3693 · Clone N-branch Tree (多叉树构建题)
LintCode 3693: 多叉树构建题原创 2024-01-31 02:06:37 · 372 阅读 · 0 评论 -
LintCode 3690 Clone Binary Tree II (二叉树构建好题)
LintCode 3690: 二叉树构建好题原创 2024-01-30 17:46:39 · 773 阅读 · 0 评论 -
LeetCode 1110. Delete Nodes And Return Forest (二叉树构建非常好的题目!)
Leetcode 1110: 二叉树构建非常好的题目原创 2024-01-30 02:02:09 · 411 阅读 · 0 评论 -
Leetcode 998. Maximum Binary Tree II (二叉树构建好题)
Leetcode 998: 二叉树构建好题原创 2024-01-28 17:46:52 · 459 阅读 · 1 评论 -
Leetcode 894. All Possible Full Binary Trees (二叉树构建好题)
Leetcode 894: 二叉树构建好题原创 2024-01-28 17:15:44 · 456 阅读 · 0 评论 -
LintCode 1534 · Convert Binary Search Tree to Sorted Doubly Linked List (二叉树转双链表好题)
LintCode 1534: 二叉树转双链表好题原创 2024-01-22 16:06:43 · 295 阅读 · 0 评论 -
LintCode 1066 · Verify Preorder Serialization of a Binary Tree (二叉树判断好题)
LintCode 1066: 二叉树判断好题原创 2024-01-18 01:48:46 · 324 阅读 · 0 评论 -
Leetcode 889: Construct Binary Tree from Preorder and Postorder Traversal (二叉树构建好题)
Leetcode 889: 二叉树构建好题原创 2024-01-17 16:19:42 · 348 阅读 · 0 评论 -
Leetcode 1261. Find Elements in a Contaminated Binary Tree (二叉树遍历好题)
Leetcode 1261: 二叉树遍历好题原创 2024-01-13 08:00:13 · 376 阅读 · 0 评论 -
LintCode 1098 · Path Sum IV (二叉树遍历好题)
LintCode 1098: 二叉树遍历好题原创 2024-01-13 06:18:24 · 405 阅读 · 0 评论 -
LintCode 1197 · Find Bottom Left Tree Value (树遍历好题)
LintCode 1197: 树遍历好题原创 2024-01-12 17:00:45 · 330 阅读 · 0 评论 -
Leetcode 437. Path Sum III (二叉树遍历和前缀和好题)
Leetcode 437: 二叉树遍历和前缀和好题原创 2024-01-10 16:44:13 · 495 阅读 · 0 评论 -
Leetcode 1367. Linked List in Binary Tree (二叉树好题)
Leetcode 1367: 二叉树好题原创 2024-01-10 01:45:15 · 759 阅读 · 0 评论 -
Leetcode 3701 · Find Nearest Right Node in Binary Tree (遍历和BFS好题)
Leetcode 3701: 遍历和bfs好题原创 2024-01-08 02:10:08 · 514 阅读 · 0 评论 -
Leetcode 1448. Count Good Nodes in Binary Tree (二叉树遍历题)
Leetcode 1448: 二叉树遍历题原创 2024-01-07 17:36:49 · 454 阅读 · 0 评论 -
Leetcode 1315. Sum of Nodes with Even-Valued Grandparent (二叉树遍历好题)
Leetcode 1315: 二叉树遍历好题原创 2024-01-05 17:49:26 · 433 阅读 · 0 评论 -
Leetcode 993. Cousins in Binary Tree (二叉树遍历好题)
Leetcode 993: 二叉树遍历好题原创 2024-01-05 17:34:55 · 436 阅读 · 0 评论 -
Leetcode 971. Flip Binary Tree To Match Preorder Traversal (二叉树遍历好题)
Leetcode 971: 二叉树遍历好题原创 2024-01-05 02:38:10 · 817 阅读 · 0 评论 -
Leetcode 623. Add One Row to Tree (二叉树遍历好题)
Leetcode 623: 二叉树遍历好题原创 2024-01-02 03:23:35 · 410 阅读 · 0 评论 -
Leetcode 1457. Pseudo-Palindromic Paths in a Binary Tree (二叉树遍历题)
Leetcode 1457: 二叉树遍历题原创 2024-01-01 12:27:06 · 1004 阅读 · 0 评论 -
Leetcode 1022. Sum of Root To Leaf Binary Numbers (树遍历题)
Leetcode 1022: 树遍历题原创 2024-01-01 11:47:59 · 478 阅读 · 0 评论 -
Leetcode 988. Smallest String Starting From Leaf (二叉树遍历好题)
Leetcode 988. 二叉树遍历好题原创 2024-01-01 10:31:38 · 448 阅读 · 0 评论 -
LintCode 1024 · Number of Matching Subsequences (binary search 好题)
LintCode 1024: binary search 好题原创 2023-12-30 17:23:38 · 462 阅读 · 0 评论 -
LintCode 1263 · Is Subsequence (双指针好题)
LintCode 1263: 双指针好题原创 2023-12-30 15:45:02 · 360 阅读 · 0 评论 -
Leetcode 855: Exam Room (排座位好题)
Leetcode 855: 排位置好题原创 2023-12-30 05:59:19 · 874 阅读 · 0 评论 -
Leetcode 43. Multiply Strings (大数乘法好题)
Leetcode 43: 大数乘法好题原创 2023-12-26 14:37:59 · 372 阅读 · 0 评论