Please tell me the *time* and *space* complexity of this program? I believe it should be : O(*n*) and O(*1*) respectively.
#include<stdio.h> #include<string.h> #define SET_BIT(x,k) (x|=(1<<(k))) #define CHECK_BIT(x,k) (x&(1<<(k))) int main() { unsigned int i,ascii; int count1=0,count2=0; const char* str = "geekszforgeeks"; for(i=0;i<strlen(str);i++) { ascii=str[i]; if(CHECK_BIT(count1,ascii-'a')) SET_BIT(count2,ascii-'a'); else SET_BIT(count1,ascii-'a'); } for(i=0;i<strlen(str);i++) { ascii=str[i]; if(!CHECK_BIT(count2,ascii-'a')) { printf("\nThe first non-repeated character is : %c\n",str[i]); break; } else continue; } return 0; } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/RBLnRACm8HwJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.