Help in code, 0 is getting printed in all 3 example cases

This post was flagged by the community and is temporarily hidden.

// corrected code

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

int main() {
	// your code goes here
	int t;
	cin>>t;

while(t--)
{
    
    int n,	 temp,	 cnt=0,	 ans= INT_MAX;
    vector<int>arr;
	  cin>>n;
	    
	    for(int i=0; i<n; i++){
	        cin>>temp;
	        arr.push_back(temp);
	    }
	    
	    for(int i=0; i<n; i++){
	        cnt=0;
	        while(arr[i]%2==0){
	            arr[i]= arr[i]/2;
	            cnt++;
	        }
	        ans= min(cnt, ans);
	    }
	    
	    cout<<ans<<endl;
	    
	}
	
	return 0;
}
for(int i=0; i<t; i++){  

if already there is a loop running outside then why have you put another loop with the same variable i inside .???

use while(t--)
  1. You need to declare arr inside 1st for loop(i.e. for(int i=0;i<t;i++)
  2. You also need to declare ans variable inside 1st for loop and initialize it so some INT_MAX
  3. I hope this works