⌘K
Flycodx

Flipkart Cart Partition Meet in Middle

Flipkart Cart Partition Meet in Middle

HardAlgorithms0% accepted

Flipkart customer wants to split cart items into two groups with equal total price. Given n items (n<=40) with prices, check if equal partition is possible. Use meet-in-the-middle for O(2^(n/2) * n/2) instead of brute O(2^n).

Approach

Subset sum for large n using meet-in-the-middle: split array, enumerate both halves, find complement.

Input

4 1 5 11 5

Output

true
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3