随笔分类 - C/C++
C/C++语言编程相关,算法相关
摘要:题目描述:查找最小的k个元素,输入n个整数,输出其中最小的k个。 一般的排序方法,如快排,时间复杂度为O(n*logn+k); 大顶堆方法,时间复杂度为O(k+(n-k)*logk); 如果建立k个元素的最小堆的话,那么其空间复杂度势为O(N),而建立k个元素的最大堆的空间复杂度为O(k); 当面对
阅读全文
摘要:1 #include 2 #include 3 4 typedef struct BSTreeNode 5 { 6 int m_nValue; 7 BSTreeNode *m_pLeft; 8 BSTreeNode *m_pRight; 9 }BSTreeNode; 10 11 BSTreeNode *pHead=NULL; 12 ...
阅读全文
摘要:LeetCode 345 Reverse Vowels of a String Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "he
阅读全文

浙公网安备 33010602011771号