Please read the new rule regarding the restriction on the use of AI tools. ×

How can i optimize my code for better time complexity?

Revision en1, by dorasainath955, 2024-10-08 19:57:25

Submission this is the problem I'm trying to solve, my approach is to create a map that consists of each element and their frequency count, then for intial MEX i try to find elements less than MEX and such that x%(mp[i]-MEX)==0 and mp[i]>1. i try to convert that repeating element into MEX, if i couldn't I'll break out and print the MEX as answer, else I'll repeat the process until i reach size of array n. Where am i going wrong?

Tags brute force, number theory, greedy, math

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English dorasainath955 2024-10-08 19:57:25 549 Initial revision (published)