Skip to content

Missing Test Case - 3550. Smallest Index With Digit Sum Equal to Index #30540

@Sanjeevan76

Description

@Sanjeevan76

LeetCode Username

samleetcode76

Problem Number, Title, and Link

  1. Smallest Index With Digit Sum Equal to Index

Bug Category

Incorrect test case (Output of test case is incorrect as per the problem statement)

Bug Description

my code giving right answer but it is showing wrong .code give below

Language Used for Code

C++

Code used for Submit/Run operation

class Solution {
public:
    int smallestIndex(vector<int>& nums) {
        int n=nums.size();
        unordered_map<int,int>mp;
        for(int i=0;i<n;i++)
        {
          string s= to_string(nums[i]);
          int x=s.size();
           int sum=0;
            for(int j=0;j<x;j++)
            {
                sum+=s[j]-'0';
            }
            mp[i]=sum;
        }   

        for(auto &pair:mp)
        {
            if(pair.first==pair.second)
            {
                return pair.first;
            }
        }
        return -1;
    }
};

Expected behavior

expecte output for test case nums =[1,10,11] is 1 ,my code also gives 1 but it is showing 2

Screenshots

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions