Chewbacca & Number

There are two test cases which are not being passed! Can someone please tell me where did I go wrong with the code?

`#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll num;
cin>>num;
vector arr;
int i=0;
int m=0;
while(num>0){
int t = num%10;
arr.push_back(t);
m = max(t,m);
num/=10;
}
for(ll i=0;i<arr.size();i++){
if(arr[i]==m){
if(arr[arr.size()-1]==9 && i==arr.size()-1)
break;
arr[i] = 9-m;
}
}

for(ll i=arr.size()-1;i>=0;i--){
    cout<<arr[i];
}

}
`