Bug Report, please add test case


  • 0
    X

    My Code gets AC but it's wrong with test case [3,2,3]

    class Solution {
    public:
    	int majorityElement(vector<int>& nums) {
    	int i = 0, j = nums.size() - 1;
    	int x = nums[0];
    
    	while(i < j){
    		while(i < j && nums[j] > x)
    			j--;
    		if(i < j)
    			nums[i++] = nums[j];
    		while(i < j && nums[i] <= x)
    			i++;
    		if(i < j)
    			nums[j--] = nums[i];
    	}
    	nums[i] = x;
    	return nums[nums.size()/2];
    }
    };

  • 0

    Thanks, your test case was just added.


  • 0

    @1337c0d3r Is all the potential bugs should be reported in this way? Thanks!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.