Size: 680 bytes.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "kth_largest_value.h"

#include <stdio.h>

#include "cs/q/priority_queue/priority_queue.h"

int KthLargestValue(int k, int length, int* values) {
  printf("I'm here 3!\n");
  fflush(stdout);
  printf("KthLargestValue()\n");
  fflush(stdout);
  PriorityQueue* pq = NewPriorityQueue(k);
  Print(pq);
  fflush(stdout);
  for (int i = 0; i < length; i++) {
    if (Insert(pq, values[i])) {
      printf("Inserted values[i]=%d into pq.\n", values[i]);
      fflush(stdout);
    } else {
      printf("Did not insert values[i]=%d into pq.\n",
             values[i]);
      fflush(stdout);
    }
    Print(pq);
    fflush(stdout);
  }
  fflush(stdout);
  return PeekMin(pq);
}
v0 (commit) © 2025 @p13i.io | Load balancer proxied to: cs-code-viewer-2:8080 in 4ms.