Skip to content

Missing Test Case - 2529. Maximum Count of Positive Integer and Negative Integer #19103

@Nitin0000

Description

@Nitin0000

LeetCode Username

Nitin93501

Problem number, title, and link

2529 - Maximum Count Of Positive Integer and Negative Integer.
https://leetcode.com/problems/maximum-count-of-positive-integer-and-negative-integer/description/

Category of the bug

  • Problem description
  • Solved examples
  • Problem constraints
  • Problem hints
  • Incorrect or missing "Related Topics"
  • Incorrect test Case (Output of test case is incorrect as per the problem statement)
  • Missing test Case (Incorrect/Inefficient Code getting accepted because of missing test cases)
  • Editorial
  • Programming language support

Description of the bug

One Testcase is Missing In problem - 2529. Maximum Count Of Positive Integer and Negative Integer.
An Array with only one element which is zero i.e [0] is missing.

Language used for code

C++

Code used for Submit/Run operation

class Solution {
public:
    int maximumCount(vector<int>& nums) {
        int n = nums.size();
        if(n<=1) return n;
        int j = n-1;
        int i=0;
        while(i<=j){
            int mid=(i+j)/2;
            if(nums[mid]<0){
                i=mid+1;
            }else if(nums[mid]>0){
                j=mid-1;
            }else{
                int c=0;
                int ind=mid;
                while(mid>=0 && nums[mid]==0){
                    mid--;
                }
                while(ind<n && nums[ind]==0){
                    ind++;
                }
                return max(mid+1,n-ind);
            }
        }
        if(nums[n-1]<0) return n;
        if(nums[i]>0){
            return max(i,n-i);
        }
        return max(i+1,n-i-1);
    }
};

Expected behavior

It is giving Wrong Answer => 1 , But it should give answer => 0

Screenshots

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions