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 · 202 阅读 · 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 · 212 阅读 · 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 · 158 阅读 · 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 · 153 阅读 · 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 · 156 阅读 · 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 · 162 阅读 · 0 评论