GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update 034.cpp · hfl15/algorithm@3991c9e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • sword_offer/src
    • 034.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎sword_offer/src/034.cpp‎

Copy file name to clipboardExpand all lines: sword_offer/src/034.cpp
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
方法0: 直接排序然后返回前k个,最好的时间复杂度为 O(nlog(n))
99
方法1: 快排的变种,时间复杂度 O(n),缺点:修改输入;原址,需要把所有数都 load 到内存中
1010
方法2: 利用最大堆作为辅助,时间复杂度 O(n*lg(k)),适用于处理数据量很大的情况。
11+
priority_queue 默认是最大堆的实现。
12+
// https://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof/solution/zui-xiao-de-kge-shu-by-leetcode-solution/
13+
// priority_queue: http://www.cplusplus.com/reference/queue/priority_queue/
1114
方法3:使用红黑树,其查找可以控制在 lg(k),c++ 中 multiset 的实现就是基于红黑树的。
1215
*/
1316

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.