Given two sorted integer arrays nums1 and nums2 and an integer k, return the k pairs with the smallest sums. Each pair consists of one element from nums1 and one element from nums2.
In this game, you must guess a number between 1 and n. Each wrong guess costs you the amount of the guessed number. Your goal is to minimize the total cost while guaranteeing a win. If you run out of money, you lose the game.
A wiggle subsequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences. Given an integer array nums, return the length of the longest wiggle subsequence of nums.
Given an array of distinct positive integers nums and a target integer target, determine the number of possible combinations of elements from nums that sum up to target. You can use any element of nums multiple times in a combination. A combination is considered different if the sequence of numbers is different, even if the same numbers are used.
Given an n x n matrix where each row and column is sorted in ascending order, find the kth smallest element in the matrix. The matrix is sorted in both rows and columns, but the kth smallest element is the one in the sorted order, not necessarily distinct.
Design a data structure that supports three operations: insert, remove, and getRandom. The insert operation adds an element to the set if it is not already present. The remove operation removes an element from the set if it exists. The getRandom operation returns a random element from the set, with each element having an equal probability of being selected.