
LeetCode
文章平均质量分 61
kacakaca-gogogo
这个作者很懒,什么都没留下…
展开
-
最大堆, 最小堆, priority_queue
最大堆,最小堆最大堆:每个节点的孩子节点都小于该节点最小堆:每个节点的孩子节点都大于该节点由于堆是一棵完全二叉树,所以如果堆中的节点i有左右孩子节点,则:左孩子节点:i x 2 + 1右孩子节点:i x 2 + 2如果堆中的节点j有父节点,则:父节点:(j-1)/2建立最大堆:void AdjustHeap(std::vector<int> & heap, int cur, int length){ int left = cur * 2 + 1..原创 2021-05-10 17:27:49 · 214 阅读 · 1 评论 -
LeetCode 143 Reorder List Add to List
题目:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it原创 2016-12-25 17:18:49 · 221 阅读 · 0 评论 -
[leetcode刷题 C++] 2. Add Two Numbers
[leetcode刷题 C++] 2. Add Two Numbers题目You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a singl...原创 2019-01-19 00:10:29 · 166 阅读 · 0 评论 -
[leetcode刷题 C++] 1. Two Sum
[leetcode刷题 C++] 1. Two Sum题目Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solutio...原创 2019-01-16 22:24:58 · 162 阅读 · 0 评论 -
[leetcode刷题 C++] 3. Longest Substring Without Repeating Characters
[leetcode刷题 C++] 3. Longest Substring Without Repeating Characters题目Given a string, find the length of the longest substring without repeating characters.Example 1: Input: &quot;abcabcbb&quot; Output: 3 ...原创 2019-02-05 18:08:56 · 164 阅读 · 0 评论 -
[leetcode刷题 C++] 5. Longest Palindromic Substring
[leetcode刷题 C++] 5. Longest Palindromic Substring题目Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1: Input: "babad" O...原创 2019-05-04 23:52:09 · 174 阅读 · 0 评论