摘要:Point: not necessarily contigous max sub array, at least one element should be selected:def maxSubarrCont(arr, n): ret = arr[0] curr = arr[0] ...
阅读全文
随笔分类 - HackerRank
摘要:In Haskell. Two points: 1. pruning 2. Int suffers from overflow. Integer it is.getPowerSum :: Integer -> [Integer] -> Integer -> IntegergetPowerSum _ ...
阅读全文
摘要:Greedy beats DP this time...I tried several DP solutions first, but all failed with RE\TLE. If you 'feel' the problem, Greedy should be working:(A sol...
阅读全文
摘要:All about pruning and duplication removal. Took me several submissions to get it AC:#include #include #include #include #include #include using namesp...
阅读全文
摘要:An iterative 'simulation' problem:#include #include #include #include #include using namespace std;int main() { int t, n, c, m; cin >> t; whi...
阅读全文
摘要:The punch line to this problem is the support to very very large int handling. I tried C++ code for multiple times, but it only passed first 13~ cases
阅读全文
摘要:You may also have seen this problem in interview questions. Two cases:1. all chars have even numbers of it2. only 1 char have odd numbers of it#includ...
阅读全文
摘要:https://www.hackerrank.com/challenges/angry-childrenAmong N ints, pick K with min 'unfairness' (max of k - min of k). Here's the strategy: larger numb...
阅读全文
摘要:We compare two end' (current) chars and the key is how to check when there's a mismatch - DFS.#include #include #include #include #include #include us...
阅读全文
摘要:A natural thought is brutal-force. But as you may have already thought of, there must be a smarter one. And yes there is.Think like this: XOR gives yo...
阅读全文

浙公网安备 33010602011771号