摘要:
It should be categorized as 'Advanced' I think ... Anyway, Fenwick tree is the key.Editorial:https://www.hackerrank.com/challenges/candles-2/editorial... 阅读全文
摘要:
No big difference with "Breadth First Search: Shortest Reach", but this statement is crucial:If there are edges between the same pair of nodes with di... 阅读全文
摘要:
A combination of different DP passes.https://www.hackerrank.com/challenges/lego-blocks/editorial#include #include #include using namespace std;typedef... 阅读全文
摘要:
My initial thought was recursive (a op b) evaluation, which doesn't work quite well.The correct way is to split by op. And, we can cache calculaton re... 阅读全文
摘要:
Classic.. just classic. It is a mix of Greedy and DP. The naive DP is, iterate over all [1..Bi] which is O(n^3). However, deeper thought into the prob... 阅读全文
摘要:
Intuition: 2D DP. Basic idea: compose square at dp[i][j] from dp[i-1][j-1]. You need 2 facility 2D matrix: accumulated horizontal\vertical number of 1... 阅读全文
摘要:
Interesting one.. It is more about data structure design actually. After you figure out how to represent cells, the DP formula will be very intuitive ... 阅读全文
摘要:
Monotonic Queue is getting more popular, and finally LeetCode put it on.Typical Solution: element in array will be pushed\popped in\from a sorted data... 阅读全文
摘要:
Actually I think it should belong to category of 'Bits Manipulation'.. but still, a really good one.My first reaction was, how to derive from a ^ (b #... 阅读全文
摘要:
Question 1: without division. We can simply compose left\right accumulated product arrays:typedef long long LL;class Solution {public: vector produ... 阅读全文