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.
- Jesse and Cookies
- Discussions
Jesse and Cookies
Jesse and Cookies
Sort by
recency
|
161 Discussions
|
Please Login in order to post a comment
Scala Solution (imports and I/O omitted for brevity):
For python users: if you've tried everything but are still not meating the time limit, use heapq
I wanted to start doing this to explain how I got the answer. Its not for very good developer but for people like me, who are self thought, and are interested in how to get to the point where this becomes second nature.
Please note the function in the algorithim starts by giving you a vector in C++. Not an array as in other languages, creating a situation where the fuction is "leading you on" to use vectors instead of heaps.
Big Picture Engineering Lessons from this task:
int cookies(int k, std::vector A) { std::priority_queue, std::greater> minHeap(A.begin(), A.end()); int sumvalue = 0;
}
TypeScript solution. Despite some optimizations, it still fails some tests due to time constraints. A JS priority queue / heap queue would be nice...