Chewbacca and no from array

2 test cases failing please can you tell whats missing

#include <bits/stdc++.h>
using namespace std;

int main() {

string s;
cin>>s;
for(int i=0;i<s.length();i++){
	if(s[i]>='5' && s[0]!='9'){
		int num = s[i];
		num -= 48;
		s[i]=(char)(9-num+48);
	}
}

cout<<s;
return 0;

}

Hey @talhashamim001


refer to comments
otherwise giving wrong results for 999

thank you for your help sir

1 Like