DESTROY - Editorial

My solution:

max(maximum(frequency),(n+1)/2)

Complexity O(NlogN)

Here’s my Solution

6 Likes

I tried the same using multiset but couldn’t get AC. :frowning:

Can anyone please give me a test case where my solution could fail? Thanks!

1 Like

Can someone give a test case for which this submission fails.

@admin SUBMIT button is not available on the practise page of this problem.Pls look into it.

11 Likes

@dushsingh1995 try 1 1 2 2 3 3 answer is 3 your submission gives 4

3 Likes

can someone provide the test case where it fails?

My Submission

@dushsingh1995 your solution gives wa for:
1
6
1 1 2 2 3 3

There is a way to solve this in O(n).

  1. Find out if there is any element occouring more than n/2 times. By Moores Frequency Algo in O(n).
  2. If there is any such element answer is equal to frequency of that element.
    Else answer =n/2+1 or n/2 depending on n being odd or even.
    solution id:9228983
19 Likes

When I click on a solution it says “This XML file does not appear to have any style information associated with it. The document tree is shown below.”

@pushkarmishra I did exactly the same thing. Why does this code give WA then? My Submission Link

@rachit_26_08 why is this O(n) solution correct?

Can someone find mistake in my


[1]


  [1]: https://www.codechef.com/viewsolution/9231730
though i manually checked different test cases.
1 Like

Please can someone provide the test case where it fails?
My Submission

1 Like

I want to submit for this problem but the submit button is not available

1 Like

What is wrong with this


[1]??


  [1]: https://www.codechef.com/viewsolution/9230426
1 Like

@shariquemohd you can directly submit to: CodeChef: Practical coding for everyone ,i had just submitted like this.

Can’t see the solution.XML error.

Can someone please provide any test case in which given code gives wrong output.

Implemented using Max Priority Queue. But still getting WA.
Tried all the above test cases and Passed.
Can Anyone tell other test cases where my code might have failed
here is my link to solution CodeChef: Practical coding for everyone

Want to know where this solution fails.

https://www.codechef.com/viewsolution/9236770

1 Like