- Prepare
- Algorithms
- Greedy
- Team Formation
- Discussions
Team Formation
Team Formation
+ 0 comments Here is problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-team-formation-problem-solution.html
+ 0 comments This is the lousiest explanation possible. At its core it is a mathematical problem and they attempt to present it like a real-world issue. The problem is they've dressed it up as little more than lip stick on a pig. It's manifestly obvious the lip stick isn't helping describe or understand this problem.
The explanation presents like they want you to form an elite team, but then the output of the first test case contradicts this. Evidenced by the first test case having a team chocked full of low skill set members - all negative numbers. What is this bullock, " largest smaller team size though"? It's a clear clash of terms "largest smaller." What?!#$? Largest in what sense?
+ 0 comments the question was pretty hard but can be solved by maintaining a hashmap of the max element and a multiset of the max lengths for that element.
+ 0 comments Python3 solution
# Enter your code here. Read input from STDIN. Print output to STDOUT import heapq import sys for _ in range(int(sys.stdin.readline())): t = list(map(int, sys.stdin.readline().split())) n = t[0] if n == 0: print(0) continue a = sorted(t[1:]) heap = {} for x in a: if x not in heap: heap[x] = [] if x - 1 in heap and len(heap[x - 1]) > 0: heapq.heappush(heap[x], heapq.heappop(heap[x - 1]) + 1) else: heapq.heappush(heap[x], 1) print(min(heap[x][0] for x in heap if len(heap[x])))
+ 0 comments Can you please explain with the help of example ? spell to break up a relationship
Sort 78 Discussions, By:
Please Login in order to post a comment