shyam81295's blog

By shyam81295, history, 5 years ago, In English

I have implemented sliding window method in this problem, but there's TLE for testcase 9 . This is the link. I know the solution is wrong, but I want to know where I am going wrong, so that I shouldn't repeat same mistake again. It would be nice if someone of you will guide me to resolve this issue. Thanking in advance.

Read more »

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

By shyam81295, history, 5 years ago, In English

Hello guys, I have been recently reading a lot about Maximum Matching in Bipartite Graph. I have found many articles on the same. But all of them lacked the visualization of Hopcroft Karp Algorithm, or how it actually works (using BFS and DFS).

So I hope if anyone can explain the Hopcroft Karp Algorithm in a better way, I would be very thankful of him.

Read more »

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

By shyam81295, history, 6 years ago, In English

This is good problem and I think my solution is correct but I am getting SIGFPE error for PRIME GENERATOR. The link of my code is here. This problem has been bugging me for hours. If anyone can solve this doubt, it will be a great help!

Read more »

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

By shyam81295, history, 6 years ago, In English

Hello, guys,

I am still learning algorithms and implementing them. But, Sometimes I get stuck when asked about generating prime numbers in O(N) time complexity. Although, I have implemented Sieve of Eratosthenes, but I have read somewhere that, it requires O(N*log(logN)) or something like that. I find this algorithm as good one, but in some practice problems, we need to implement in O(N) time.

It would be nice if someone of you will guide me to generate prime numbers in O(N) time.

Read more »

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

By shyam81295, history, 6 years ago, In English

My first problem of Dynamic Programming

Logic: max (total_1s + max (number_of_0s_in_subarray))

The key to solve this problem is to make use of Kadane's Algorithm. Kadance's Algorithm basically is used to find the maximum sum in a contiguous subarray of an array.

Click here for link for Kadane's Algorithm Explanation

Also, important point to note is that : In input, atleast one number 0 is required for flipping purposes, but if all are 1s in input, then answer will be (total_1s — 1) because atleast one number should be flipped.

Read more »

Tags #dp
 
 
 
 
  • Vote: I like it
  • -6
  • Vote: I do not like it

By shyam81295, 6 years ago, In English

I have runtime error in 9677279 but it is working on my codeblocks. I cant figure out the problem.

Read more »

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