Tip 1 : Practice DSA a lot
Tip 2 : Have good knowledge about your projects and don't copy them.
Tip 3 : Revise core subjects before the interview
Tip 1 : Write only those things that you know well.
Tip 2 : Do not exaggerate your skills
Tip 3 : Include your projects at least two minimum
Method 1 : A naive solution to this problem is to generate all configurations of different pieces and find the highest-priced configuration. This solution is exponential in terms of time complexity. Let us see how this problem possesses both important properties of a Dynamic Programming (DP) Problem and can efficiently be solved using Dynamic Programming.
We have 2 choices for a coin of a particular denomination, either i) to include, or ii) to exclude.
If we are at coins[n-1], we can take as many instances of that coin ( unbounded inclusion ) i.e count(coins, n, sum – coins[n-1] ); then we move to coins[n-2].
After moving to coins[n-2], we can’t move back and can’t make choices for coins[n-1] i.e count(coins, n-1, sum).
Fin...
diff = no of ways when color of last
two posts is different
same = no of ways when color of last
two posts is same
total ways = diff + same
for n = 1
diff = k, same = 0
total = k
for n = 2
diff = k * (k-1) //k choices for
first post, k-1 for next
same = k //k choices for common
color of two posts
total = k + k * (k-1)
for n = 3