摘要:It is not a hard one, but I still learnt a good lesson on how to optimize my strategy. My first thought was on the right track: do a O(n) scan and do
阅读全文
随笔分类 - HackerRank
摘要:It is a super interesting problem - it's not about the algorithm SKILLs, it is about algorithm THINKING. In this problem, the goal is actually to have
阅读全文
摘要:Interesting constructive solution. My first reaction was 0-1 Knapsack and I believe it'll work. But you don't have to use it. Think about the min sum
阅读全文
摘要:Key points for this one: - Relate the comparison process to BST search- Reasoning on extreme values: "We can notice that for a fixed the maximum sum o
阅读全文
摘要:Key point of this problem is "New subsets are the all old subsets having a[i]." - A very useful trick. After that, it'll simply be a DP one.
阅读全文
摘要:This is an educational one to Game Tree + Minimax - sounds fancy but actually it is intuitive DFS process. And Simplified Chess Engine II is an variat
阅读全文
摘要:Fancy, classic, STEP-BY-STEP Analysis strategy problem. Here is the approach: 1. Sort input arrays.. so sum[0] is a[0] * k, so we got a[0]2. Then who
阅读全文
摘要:Classic problem to learn Game Theory - an advanced one: how to identify sub-games.. For every move (hit 1\2 bins) on one continuous section, the origi
阅读全文
摘要:DFS + memo.
阅读全文
摘要:Actually, it is a Greedy problem : )
阅读全文
摘要:It is marked as Recursion on HR, but the optimal solution is DP. Step by step, discover internal mechanism.
阅读全文
摘要:The trick of this problem is.. Adding 1+ coins to one pile, means nothing - you add one, then i just remove it.. so it is back to original game. So, b
阅读全文
摘要:A simple NIM game in disguise: move 1 coin to one of previous slot, equals to removing.. Then no surprise, Sprague-Grundy theorem solves the problem.
阅读全文
摘要:Another easy one solved by Sprague-Grundy theorem. Each pile is a sub-game, so you need to XOR SG value of all substates - since you can move # of 1 -
阅读全文
摘要:A matter of OBSERVATION.. draw a triangle of parity, and watch.
阅读全文
摘要:Discrete thinking - Play & Observe! " you can move numbers in any quadrant at the following positions to [x][y]: [x][y] or // upper left quadrant [x][
阅读全文
摘要:Another intuitive of application of Sprague-Grundy theorem.
阅读全文
摘要:An intuitive problem for learning & applying Sprague-Grudy theorem: https://zhuanlan.zhihu.com/maigo/20611132 Lesson learnt, in Sprague-Grundy theorem
阅读全文
摘要:The major trick is from another similar HR problem: subarray with max XOR: Build a binary tree bit by bit, and go from MSB to LSB, greedily. In this o
阅读全文
摘要:Fun Greedy. My first thought was a DFS based solution... however the editorial provides a super neat 2-pass O(n) solution: Pass 1: if s[l] != s[r], ch
阅读全文

浙公网安备 33010602011771号