Leetcode 0698. Partition to K Equal Sum Subsets

Posted on Tue 10 December 2024 in Leetcode • Tagged with subset-sum, backtracking

Question Link : https://leetcode.com/problems/partition-to-k-equal-sum-subsets/

Difficulty: Medium

Premium: False

Question

Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.   Example 1:

Input: nums = [4,3,2,3,5,2 …


Continue reading

Leetcode 0494. Target Sum

Posted on Sun 24 November 2024 in Leetcode • Tagged with backtracking, dp, knapsack-1-0

Question Link : https://leetcode.com/problems/target-sum/

Difficulty: Medium

Premium: False

Question

You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers …


Continue reading

Leetcode 0039. Combination Sum

Posted on Tue 19 November 2024 in Leetcode • Tagged with backtracking

Question Link : https://leetcode.com/problems/combination-sum/

Difficulty: Medium

Premium: False

Question

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same …


Continue reading

Leetcode 0093. Restore IP Addresses

Posted on Sat 21 January 2023 in Leetcode • Tagged with backtracking

Question Link : https://leetcode.com/problems/restore-ip-addresses/

Difficulty: Medium

Premium: False

Question

A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros.

For example, "0.1.2.201" and "192.168.1.1" are …


Continue reading