![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 69
casgj16
菜鸟打怪升级之中
展开
-
各个排序算法应用:求取数组中第K大的数( LeetCode 215. Kth Largest Element in an Array )
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example ...原创 2018-05-21 22:45:49 · 369 阅读 · 0 评论 -
C++ sort + vector 应用:求取数组中第K大的数( LeetCode 215. Kth Largest Element in an Array )
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example ...原创 2018-05-22 01:24:46 · 1041 阅读 · 0 评论 -
合并两个有序链表(LeetCode 21. Merge Two Sorted Lists)
双指针链表解法:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: List...原创 2018-05-22 13:11:07 · 149 阅读 · 0 评论 -
输入一个链表,按链表值从尾到头的顺序返回一个ArrayList。
/*** struct ListNode {* int val;* struct ListNode *next;* ListNode(int x) :* val(x), next(NULL) {* }* };*/#include<vector> #include<iostream>usin...原创 2018-07-10 16:35:11 · 2798 阅读 · 0 评论 -
leetcode 树
1.构建树 用前序和中序建树105 用后序和中序建树106 数组构建BST 108 链表构建BST 109 2.树的遍历 前序 144 中序 94 后序 145 层次 102 103 107 3.树的属性 求深度 104 是否平衡是平衡树 110 最小深度 111 4.BST树 判断BST是否合法 98 恢复BST 99 BST实现迭代:173(用到某一遍历) ...原创 2018-08-11 11:55:48 · 134 阅读 · 0 评论