
算法
文章平均质量分 72
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 = 2Output: 5Example ...原创 2018-05-21 22:45:49 · 407 阅读 · 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 = 2Output: 5Example ...原创 2018-05-22 01:24:46 · 1118 阅读 · 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 · 176 阅读 · 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 · 2837 阅读 · 0 评论 -
leetcode 树
1.构建树用前序和中序建树105 用后序和中序建树106 数组构建BST 108 链表构建BST 1092.树的遍历前序 144 中序 94 后序 145 层次 102 103 1073.树的属性求深度 104 是否平衡是平衡树 110 最小深度 1114.BST树判断BST是否合法 98 恢复BST 99 BST实现迭代:173(用到某一遍历) ...原创 2018-08-11 11:55:48 · 160 阅读 · 0 评论