https://www.codechef.com/problems/FLOW007

// this answer satisfies the question given in the link , but it still shows wrong why??
#include
using namespace std;
int n;
int y=0;
int main() {
int t;
cin>>t;

int c[1000000];

while(t--){
    cin>>n;
    int x=0;
    int i=0;
    while(n){
        c[i] = n%10;
        n/=10;
        i++;
        x++;
    }
   
   int a[10];
   int y=0;
   for(int i=0;i<x;i++){
       if(c[i]!=c[i-1]){
           a[y]=c[i];
           y++;
       }
   }
   
    for(int i=0;i<y;i++){
        cout<<a[i];
    }
    
    cout<<endl;
    
}
return 0;

}

I think that’s because the output should be in form of a number N and you are printing an array.

thnx bro for the help but it still showing error
https://www.codechef.com/viewsolution/44032282

[simon@simon-laptop][20:20:52]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling shoyam-FLOW007.cpp
+ g++ -std=c++14 shoyam-FLOW007.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
+ set +x
Successful
[simon@simon-laptop][20:20:54]
[~/devel/hackerrank/otherpeoples]>echo "4
12345
31203
2123
2300" | ./a.out
shoyam-FLOW007.cpp:25:22: runtime error: index -1 out of bounds for type 'int [1000000]'
54321
30213
3212
32
1 Like

thnx again XD , can you be my teacher lol xd…

1 Like