標籤:: Heap

0

Kth Smallest Element in a Sorted Matrix

Kth Smallest Element in a Sorted MatrixGiven a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is the kth smal

0

Find K Pairs with Smallest Sums

Find K Pairs with Smallest SumsYou are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and

0

Design Twitter

Design TwitterDesign a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user’s news feed. Your design should

0

Top K Frequent Elements

Top K Frequent ElementsGiven a non-empty array of integers, return the k most frequent elements. For example:1Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assume k is always valid, 1 ≤

0

Super Ugly Number

Super Ugly NumberWrite a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4

0

Ugly Number II

Ugly Number IIWrite a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of

0

Kth Largest Element in an Array

Kth Largest Element in an ArrayFind 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. For example,Given [3,2,1,5