摘要:
Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the solution from this link:https://github.com/wangyongliang 阅读全文
摘要:
Greedy using priority_queue and hashmap. The basic idea is to have k buckets - and we fill it greedily. And I agree that the code below can be cleaner 阅读全文
摘要:
First you find the Y, and then do a pairing game - hashtable is good. class Solution { public: bool isReflected(vector<pair<int, int>>& points) { int 阅读全文
摘要:
Two tricks here: 1. Counting no. of inversed pairs - using Merge Sort, nothing special 2. How to check 'chaotic'? We simply check if any number is ove 阅读全文
摘要:
A typical solution is heap based - "top K". Complexity is O(nlgk). There is a O(n) one indeed - bucketing the frequencies.https://leetcode.com/discuss 阅读全文
摘要:
A typical CS style DP based solution: But there's a Math based solution: https://leetcode.com/discuss/98249/easy-to-understand-c-with-explanationIn wh 阅读全文
摘要:
Fun one! A combination of Greedy and DP. The solution sparkled in my mind - I almost lost it.. Greedy: we sort the input numbers and always pick k con 阅读全文
摘要:
It is about how to choose btw. BFS and DFS. My init thought was to DFS - TLE\MLE. And its editorial gives a very neat BFS based idea which costs much 阅读全文
摘要:
I caught the sparkle in my mind and got AC1 ! It is a great great experience ! So the basic idea: permute on 3 consecutive items doesn't change the pa 阅读全文
摘要:
It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/CharlesOfria), it looks pretty much like a Brutal-Force 阅读全文