Varun12's blog

By Varun12, history, 6 weeks ago, In English

Given a tree with tree nodes vertices where each vertex denotes a place in a land, find the number of ways such that exactly k vertices have an active connection. A vertex has an active connection when there is a tower in that vertex, or there is a tower in any other vertex directly connected to that vertex. Determine the total number of ways such that exactly k places have an active connection in HackerLand for each k=0,1,2,.,tree nodes. Since the answer can be large, return it modulo (10^9+7).

Read more »

 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it

By Varun12, history, 3 months ago, In English

You are in your kingdom with no troops but your barracks train X troops daily. Initially X = 1. There are N neighbor kingdom each of which has A[i] amount of troops guarding it. To take over a kingdom you need to attack it with at least A[i] troops. Once you capture a kingdom, as a consequence of war, all of your troops die (even if you attacked with > A[i] troops), and X increases by 1. Assuming Attacking and capturing a kingdom takes no time, find the minimum days the worthy king needs to wait to take over the entire globe.

1 <= N <= 20 1 <= A[i] <= 1e6

Test Case 1: Input : A = [4 , 3 , 1] Output : 4

Test Case 2: Input : A = [9 , 9] Output : 14

Read more »

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it