### hars123's blog

By hars123, history, 16 months ago, ,

I am trying to find number of elements smaller than or equal to a particular value inside the multiset. I want a logn time approach. I have tried using distance(s.begin(),s.upper_bound(val)). But using distance method could take O(N) time in worst case.Can someone help me.

• -3

By hars123, history, 16 months ago, ,

I have tried this problem a lot and also figured out the states. I am trying to build up a 2D dp table dp[i][j] where first i-1 signs are satisfied and last number in the sequence is j. can someone help me in finding out the transitions for these states and solve this problem in O(N^2). If someone could suggest a top-down approach it would be really helpful as i generally find it difficult to find transitions using bottom-up approach.

• +9

By hars123, history, 16 months ago, ,

I am finding it difficult to find the relation for transition from one state to another. i.e. if dp[i][j] represents no of ways of distributing j candies among positions [1,i]. Can someone explain what should i think to find that transition. Or i am just unable to observe the pattern.

• +5

By hars123, history, 18 months ago, ,

Substring Xor

Can someone explain me the detailed method about how to use tries and binary search to solve this problem.

• -6

By hars123, history, 2 years ago, ,

the constraints for n and k are upto 10^6. I wanted to efficiently precompute all the binomial coefficient (n choose k) and store them somewhere for further use. Please help me!. Thanks in advance!.

• 0

By hars123, history, 2 years ago, ,

I am recently solving a problem to find a^(n!)%m and got stuck. please suggest how to solve this problem and some resources and problems to learn concepts related to modular arithmatic.