Coding Patterns

Minimum Cost to Hire K Workers

There are N workers. The i-th worker has a quality quality and a minimum wage expectation wage. Now you want to hire exactly K workers to form a paid group.…

Rearranging Strings K Distance Apart

Given a non-empty string s and an integer k, rearrange the string such that the same characters are at least distance k apart. If no such arrangement is possible, return…

Find K Pairs with Smallest Sum

You are given two integer arrays nums1 and nums2 sorted in non-decreasing order and two integers k and target. Find k pairs (a, b) from the arrays such that a…

Merge K Sorted Lists

You are given an array of k linked lists, each linked list is sorted in ascending order. Merge all the linked lists into one sorted linked list and return it.

1.6) Find Combination Sum to Target

Given an array of distinct integers candidates and a target integer target, return all possible combinations of candidates where the chosen numbers sum to target. You may use the same…

1.4) Letter Combinations of a Phone Number

Given a string containing digits from 2 to 9 inclusive, return all possible letter combinations that the number could represent on a telephone keypad. The mapping of digits to letters…

1.2) Subsets

Given a set of distinct integers nums, return all possible subsets (the power set) of the set.