We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Dynamic Programming
- Fair Cut
- Discussions
Fair Cut
Fair Cut
Sort by
recency
|
37 Discussions
|
Please Login in order to post a comment
Here's what worked for me:
hard tedious question. the I that minimize unfairness is actually fixed, location depends on parity of n and k. proof is very long and tedious
very fast O(n) method, except for the sort(arr.begin(), arr.end()) which is O(nlog n), the rest of algo is linear time O(n)
how does this works?
i cant remember this is something i did ages ago. i think this question, the I that minimize the fairness is fixed, the proof for why its fixed is very long and i dont think i should post something so long here
im pretty sure what the I is depends on whether k is odd or even, so in the fairCut function there's 2 blocks to calculate I depending on whether k is odd or even
Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Fair Cut Problem Solution
nice code sir
Can someone explain why this code is not clearing all test cases: https://p.ip.fi/0EaF
Can someone explain why this code is not clearing all test cases:
include
define ll long long int
using namespace std;
ll fairCut(int k, vector arr) { int n = arr.size(); vector> dp(n+1, vector (k+1, LLONG_MAX));
}
signed main() { int n, k;
}