Help me in solving ARRREM problem

My issue

i stracked too build the logic can you help me

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		int t1=sc.nextInt();
		int arr[]=new int[t1];
		int t2=sc.nextInt();
		int arr1[]=new int[t2];
		/*for(int i=o;i<t1;i++){
		    arr[i]*/
		
	}
}

Problem Link: Array Removal Practice Coding Problem

@ganeshboddula
here , plzz refer my c++ code for better understanding of the logic

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    long long int n;
	    cin>>n;
	    long long int a[n];
	    long long int sm=0,p=1;
	    for(int i=0;i<n;i++)
	    {
	        cin>>a[i];
	        sm=sm|a[i];
	    }
	    while(p<=sm)
	    {
	        long long ch=p&sm;
	        if(ch!=p)
	        {
	            break;
	        }
	        else
	        p=p*2;
	    }
	    int ans=0;
	    for(int i=0;i<n;i++)
	    {
	        if(a[i]>=p)
	        ans++;
	    }
	    cout<<ans<<endl;
	}
	return 0;
}