hars123's blog

By hars123, history, 6 months ago, In English,

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.

Read more »

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

By hars123, history, 6 months ago, In English,

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.

Read more »

 
 
 
 
  • Vote: I like it
  • +9
  • Vote: I do not like it

By hars123, history, 6 months ago, In English,

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.

Read more »

 
 
 
 
  • Vote: I like it
  • +5
  • Vote: I do not like it

By hars123, history, 8 months ago, In English,

Substring Xor

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

Read more »

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

By hars123, history, 16 months ago, In English,

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!.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By hars123, history, 16 months ago, In English,

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.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it