自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(83)
  • 收藏
  • 关注

原创 Leetcode 187、重复的DNA序列

Problem Source : https://leetcode-cn.com/problems/repeated-dna-sequences/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0187_RepeatedDNASequences.cpp187、重复的DNA序列所有 DNA 都由一系列缩写为 ‘A’,‘C’,‘G’ 和 ‘T’ 的核苷酸组成,例如:“ACGAATT.

2021-10-08 21:19:37 209

原创 Leetcode 434、字符串中的单词数

Problem Source : https://leetcode-cn.com/problems/number-of-segments-in-a-string/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0434_NumberOfSegmentsInAString.cpp434、字符串中的单词数统计字符串中的单词个数,这里的单词指的是连续的不是空格的字符。请注意,你可以.

2021-10-07 14:32:15 179

原创 快速排序 (Quick Sort)

Source : https://github.com/hujingbo98/algorithm/blob/master/source/algorithm/sort/quickSort.cpp排序问题输入:n 个数的一个序列 {a[0], a[1], ... , a[n-1]}。输出:输出序列的一个排列 {a[0]', a[1]', ... , a[n-1]'},其中 a[0]' <= a[1]' <= ... <= a[n-1]'。快速排序 (Quick Sort)快速排.

2021-10-06 23:47:08 1305

原创 算法 - 分治法

分治法 (Divide and Conquer)将原问题分解为两个或多个规模较小但类似于原问题的子问题,递归地求解这些子问题,然后再合并这些子问题的解来建立原问题的解。许多有用的算法在结构上是递归的,为了解决一个给定的问题,算法一次或多次递归地调用其自身以解决紧密相关的若干子问题,这些算法典型的遵循分治法的思想。分治法在每层递归时都有三个步骤:分解原问题为若干子问题,这些子问题是原问题规模较小的实例。解决这些子问题,递归地求解各子问题。然而,若子问题的规模足够小,则直接求解。合并这些子问题的.

2021-10-06 22:14:55 169

原创 归并排序 (Merge Sort)

Source : https://github.com/hujingbo98/algorithm/blob/master/source/algorithm/sort/mergeSort.cpp排序问题输入:n 个数的一个序列 {a[0], a[1], ... , a[n-1]}。输出:输出序列的一个排列 {a[0]', a[1]', ... , a[n-1]'},其中 a[0]' <= a[1]' <= ... <= a[n-1]'。归并排序 (Merge Sort)归并排.

2021-10-06 22:07:03 123

原创 希尔排序 (Shell Sort)

Source : https://github.com/hujingbo98/algorithm/blob/master/source/algorithm/sort/shellSort.cpp排序问题输入:n 个数的一个序列 {a[0], a[1], ... , a[n-1]}。输出:输出序列的一个排列 {a[0]', a[1]', ... , a[n-1]'},其中 a[0]' <= a[1]' <= ... <= a[n-1]'。希尔排序 (Shell Sort)195.

2021-10-06 17:10:28 119

原创 Leetcode 414、第三大的数

Problem Source : https://leetcode-cn.com/problems/third-maximum-number/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0414_ThirdMaximumNumber.cpp414、第三大的数给你一个非空数组,返回此数组中 第三大的数。如果不存在,则返回数组中最大的数。示例 1:输入:[3, 2, 1].

2021-10-06 14:33:09 67

原创 Leetcode 639、解码方法 II

Problem Source : https://leetcode-cn.com/problems/decode-ways-ii/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0639_DecodeWaysII.cpp639、解码方法 II一条包含字母 A-Z 的消息通过以下的方式进行了编码:‘A’ -> 1‘B’ -> 2…‘Z’ -> 26要解.

2021-10-05 15:29:24 53

原创 Leetcode 284、窥探迭代器

Problem Source : https://leetcode-cn.com/problems/peeking-iterator/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0284_PeekingIterator.cpp284、窥探迭代器请你设计一个迭代器,除了支持 hasNext 和 next 操作外,还支持 peek 操作。实现 PeekingIterator .

2021-10-05 14:28:53 74

原创 Leetcode 437、路径总和 III

Problem Source : https://leetcode-cn.com/problems/path-sum-iii/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0437_PathSumIII.cpp437、路径总和 III给定一个二叉树的根节点 root ,和一个整数 targetSum ,求该二叉树里节点值之和等于 targetSum 的 路径 的数目。路径不.

2021-10-04 20:29:19 65

原创 Leetcode 583、两个字符串的删除操作

Problem Source : https://leetcode-cn.com/problems/delete-operation-for-two-strings/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0583_DeleteOperationForTwoStrings.cpp583、两个字符串的删除操作给定两个单词 word1 和 word2,找到使得 word1 .

2021-10-04 16:16:55 72

原创 Leetcode 482、密钥格式化

Problem Source : https://leetcode-cn.com/problems/license-key-formatting/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0482_LicenseKeyFormatting.cpp482、密钥格式化有一个密钥字符串 S ,只包含字母,数字以及 ‘-’(破折号)。其中, N 个 ‘-’ 将字符串分成了 N+1.

2021-10-04 15:15:56 79

原创 Leetcode 166、分数到小数

Problem Source : https://leetcode-cn.com/problems/fraction-to-recurring-decimal/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0166_FractionToRecurringDecimal.cpp166、分数到小数给定两个整数,分别表示分数的分子 numerator 和分母 denominator.

2021-10-03 20:28:21 171

原创 Leetcode 405、数字转换为十六进制数

Problem Source : https://leetcode-cn.com/problems/convert-a-number-to-hexadecimal/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0405_ConvertANumberToHexadecimal.cpp405、数字转换为十六进制数给定一个整数,编写一个算法将这个数转换为十六进制数。对于负整数,我们.

2021-10-02 22:35:57 106

原创 Leetcode 1436、旅行终点站

Problem Source : https://leetcode-cn.com/problems/destination-city/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/1436_DestinationCity.cpp1436、旅行终点站给你一份旅游线路图,该线路图中的旅行线路用数组 paths 表示,其中 paths[i] = [cityAi, cityBi] 表.

2021-10-01 15:29:42 63

原创 Leetcode 517、超级洗衣机

Problem Source : https://leetcode-cn.com/problems/super-washing-machines/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0517_SuperWashingMachines.cpp517、超级洗衣机假设有 n 台超级洗衣机放在同一排上。开始的时候,每台洗衣机内可能有一定量的衣服,也可能是空的。在每一步操作.

2021-09-30 15:38:10 102

原创 Leetcode 223、矩形面积

Problem Source : https://leetcode-cn.com/problems/rectangle-area/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0223_RectangleArea.cpp223、矩形面积给你二维平面上两个由直线构成的矩形,请你计算并返回两个矩形覆盖的总面积。每个矩形由其左下顶点和右上顶点坐标表示:第一个矩形由其左下顶点 (.

2021-09-30 14:39:02 151

原创 Leetcode 1143、最长公共子序列

Problem Source : https://leetcode-cn.com/problems/longest-common-subsequence/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/1143_LongestCommonSubsequence.cpp1143、最长公共子序列给定两个字符串 text1 和 text2,返回这两个字符串的最长公共子序列的长度。如果.

2021-09-25 23:40:15 89

原创 Leetcode 430、扁平化多级双向链表

Problem Source : https://leetcode-cn.com/problems/flatten-a-multilevel-doubly-linked-list/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0430_FlattenAMultilevelDoublyLinkedList.cpp430、扁平化多级双向链表多级双向链表中,除了指向下一个节点和前一.

2021-09-24 23:27:45 56

原创 Leetcode 326、3的幂

Problem Source : https://leetcode-cn.com/problems/power-of-three/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0326_PowerOfThree.cpp326、3的幂给定一个整数,写一个函数来判断它是否是 3 的幂次方。如果是,返回 true;否则,返回 false。整数 n 是 3 的幂次方需满足:存在整数.

2021-09-23 20:49:20 62

原创 Leetcode 725、分隔链表

Problem Source : https://leetcode-cn.com/problems/split-linked-list-in-parts/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0725_SplitLinkedListInParts.cpp725、分隔链表给你一个头结点为 head 的单链表和一个整数 k ,请你设计一个算法将链表分隔为 k 个连续的部分.

2021-09-23 20:44:15 63

原创 Leetcode 58、最后一个单词的长度

Problem Source : https://leetcode-cn.com/problems/length-of-last-word/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0058_LengthOfLastWord.cpp58、最后一个单词的长度给你一个字符串 s,由若干单词组成,单词前后用一些空格字符隔开。返回字符串中最后一个单词的长度。单词是指仅由字母组成、.

2021-09-21 13:23:58 52

原创 插入排序(Insertion Sort)

Source : https://github.com/hujingbo98/algorithm/blob/master/source/algorithm/sort/insertionSort.cpp排序问题输入:n 个数的一个序列 {a[0], a[1], ... , a[n-1]}。输出:输出序列的一个排列 {a[0]', a[1]', ... , a[n-1]'},其中 a[0]' <= a[1]' <= ... <= a[n-1]'。插入排序(Insertion Sor.

2021-09-21 01:49:04 78

原创 选择排序(Selection Sort)

Source : https://github.com/hujingbo98/algorithm/blob/master/source/algorithm/sort/selectionSort.cpp排序问题输入:n 个数的一个序列 {a[0], a[1], ... , a[n-1]}。输出:输出序列的一个排列 {a[0]', a[1]', ... , a[n-1]'},其中 a[0]' <= a[1]' <= ... <= a[n-1]'。选择排序(Selection Sor.

2021-09-21 01:10:02 61

原创 冒泡排序(Bubble Sort)

Source : https://github.com/hujingbo98/algorithm/blob/master/source/algorithm/bubbleSort.cpp排序问题输入:n 个数的一个序列 {a[0], a[1], ... , a[n-1]}。输出:输出序列的一个排列 {a[0]', a[1]', ... , a[n-1]'},其中 a[0]' <= a[1]' <= ... <= a[n-1]'。冒泡排序冒泡排序是一种简单的排序算法。它重复地走访.

2021-09-21 00:01:19 90

原创 Leetcode 673、最长递增子序列的个数

Problem Source : https://leetcode-cn.com/problems/number-of-longest-increasing-subsequence/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0673_NumberofLongestIncreasingSubsequence.cpp673、最长递增子序列的个数给定一个未排序的整数数组,找到最.

2021-09-20 22:20:23 57

原创 Leetcode 650、只有两个键的键盘

Problem Source : https://leetcode-cn.com/problems/2-keys-keyboard/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0650_2KeysKeyboard.cpp650、只有两个键的键盘最初记事本上只有一个字符 ‘A’ 。你每次可以对这个记事本进行两种操作:Copy All(复制全部):复制这个记事本中的所有字符(.

2021-09-19 17:02:50 152

原创 Leetcode 292、Nim 游戏

Problem Source : https://leetcode-cn.com/problems/nim-game/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0292_NimGame.cpp292、Nim 游戏你和你的朋友,两个人一起玩 Nim 游戏:桌子上有一堆石头。你们轮流进行自己的回合,你作为先手。每一回合,轮到的人拿掉 1 - 3 块石头。拿掉最后一块.

2021-09-18 00:32:13 60

原创 Leetcode 36、有效的数独

Problem Source : https://leetcode-cn.com/problems/valid-sudoku/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0036_ValidSudoku.cpp36、有效的数独请你判断一个 9x9 的数独是否有效。只需要根据以下规则 ,验证已经填入的数字是否有效即可。数字 1-9 在每一行只能出现一次。数字 1-9 在.

2021-09-17 22:45:31 75

原创 Leetcode 212、单词搜索 II

Problem Source : https://leetcode-cn.com/problems/word-search-ii/Soluton Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0212_WordSearchII.cpp212、单词搜索 II给定一个 m x n 二维字符网格 board 和一个单词(字符串)列表 words,找出所有同时在二维网格和.

2021-09-17 00:15:51 115

原创 Leetcode 162、寻找峰值

Problem Source : https://leetcode-cn.com/problems/find-peak-element/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0162_FindPeakElement.cpp162、寻找峰值峰值元素是指其值严格大于左右相邻值的元素。给你一个整数数组 nums,找到峰值元素并返回其索引。数组可能包含多个峰值,在这种情况下.

2021-09-15 01:34:52 56

原创 Leetcode 524、通过删除字母匹配到字典里最长单词

Problem Source : https://leetcode-cn.com/problems/longest-word-in-dictionary-through-deleting/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0524_LongestWordInDictionaryThroughDeleting.cpp524、通过删除字母匹配到字典里最长单词给你一个字.

2021-09-14 23:42:47 70

原创 Leetcode 面试题 17.14、最小K个数

Problem Source : https://leetcode-cn.com/problems/smallest-k-lcci/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/interviewProblem/17_14_SmallestKNumbers.cpp面试题 17.14、最小K个数设计一个算法,找出数组中最小的k个数。以任意顺序返回这k个数均可。示例:输入:arr = [1,3.

2021-09-13 20:10:53 116

原创 Leetcode 剑指 Offer 22、链表中倒数第k个节点

Problem Source : https://leetcode-cn.com/problems/lian-biao-zhong-dao-shu-di-kge-jie-dian-lcof/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/jianzhioffer/22_TheKthNodeFromTheBottomInTheLinkedList.cpp剑指 Offer 22、链表中倒数第k个节点.

2021-09-13 20:10:15 84

原创 Leetcode 剑指 Offer 10- I. 斐波那契数列

Problem Source : https://leetcode-cn.com/problems/fei-bo-na-qi-shu-lie-lcof/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/jianzhioffer/10-I_FibonacciSequence.cpp剑指 Offer 10- I. 斐波那契数列写一个函数,输入 n,求斐波那契(Fibonacci)数列的第 n 项(即F.

2021-09-13 20:09:36 110

原创 Leetcode 165、比较版本号

Problem Source : https://leetcode-cn.com/problems/compare-version-numbersSolution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0165_CompareVersionNumbers.cpp165、比较版本号给你两个版本号 version1 和 version2 ,请你比较它们。版本号由一个或多个修订号组成,各修.

2021-09-13 20:08:22 90

原创 Leetcode 447、回旋镖的数量

Problem Source : https://leetcode-cn.com/problems/number-of-boomerangs/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0447_NumberOfBoomerangs.cpp447、回旋镖的数量给定平面上 n 对 互不相同 的点 points ,其中 points[i] = [xi, yi] 。回旋镖 是由点.

2021-09-13 20:00:23 54

原创 Leetcode 1704、判断字符串的两半是否相似

Problem Source : https://leetcode-cn.com/problems/determine-if-string-halves-are-alike/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/1704_DetermineifStringHalvesAreAlike.cpp1704、判断字符串的两半是否相似给你一个偶数长度的字符串 s。将其拆分成长度.

2021-09-12 23:13:00 177

原创 Leetcode 1221、分割平衡字符串

Problem Source : https://leetcode-cn.com/problems/split-a-string-in-balanced-strings/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/1704_DetermineifStringHalvesAreAlike.cpp1221、分割平衡字符串在一个平衡字符串 中,‘L’ 和 ‘R’ 字符的数量是相同.

2021-09-12 23:07:44 160

原创 Leetcode 704、二分查找

Problem Source : https://leetcode-cn.com/problems/binary-search/Solution Source : https://github.com/hujingbo98/algorithm/blob/master/source/leetcode/0704_BinarySearch.cpp704、二分查找给定一个 n 个元素有序的(升序)整型数组 nums 和一个目标值 target,写一个函数搜索 nums.

2021-09-12 23:00:57 63

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除