Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

Example 1:

Example 2:

Constraints:

  • 1 <= nums.length <= 8
  • -10 <= nums[i] <= 10

Solution :

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

Example 1:

Example 2:

Example 3:

Constraints:

  • 1 <= nums.length <= 6

Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

Example 1:

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

Return the fewest number of coins that you need to make up that amount. …

You are given an integer num. You can swap two digits at most once to get the maximum valued number.Return the maximum valued number you can get.

Example 1:

Example 2:

Given a string s, reverse only all the vowels in the string and return it.

The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cases.

Example 1:

Example 2:

Constraints:

  • 1 <=…

Two Sum II — Input array is sorted.

Given an array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number.

Return the indices of the two numbers (1-indexed) as an integer array answer of size 2

Vivek Singh

Software Architect

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store