Question: Question 2 5 Max. score: 2 0 . 0 0 OR bit Find the maximum value obtained by performing a bitwise OR operation on any

Question 25
Max. score: 20.00
OR bit
Find the maximum value obtained by performing a bitwise OR operation on any subsequence of a given array.
Function description
Complete the solve() function. The function takes 2 parameters and returns an integer denoting the answer to the question:
N. Represents the number of elements in the array
A: Represents the array
Input format for custom testing
Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code.
The first line contains a single integer 7. which denotes the number of test cases.
For each test case:
The first line contains an integer N, denoting the total elements in the array.
The second line contains N space-separated numbers.
Output format
For each test case, print the answer in a new line.
Constraints
1<=T<=10^4
1<= N <=10^5
0<=|A[i]|<=10^9
Where Ixi represents the absolute value of x.
It's guaranteed that the sum of N over all test cases will not exceed 2*10^5
Sample input
8
10
910-9-704107-2-2
6
-796-2-57
1
8
7
7575-2-9-9
10
Sample output
15
15
8
7
9
11
4
-1
View more
Explanation
Test case 1
Given
. N =10
A =[9,10,-9,-7,0,4,10,7,-2,-2]
Approach
We will select subsequences 10 and 7, as this subsequence gives the maximum Bitwise OR value of 15
Test case 8
Given
N-2
A=9,-7]
Approach
The subsequence consisting of the numbers -9 and -7 will result in the maximum Bitwise OR value of -1
Note:
Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement
Limits
Time Limit. 1.0 sec(s) for each input file
Memory Limit: 256 MB
Source Limit: 1024 KB
Scoring
Score is assigned if any testcase passes
Allowed Languages
Bash, C, C++14, C++17, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java 8, Java 14. Java 17, JavaScript(Node js), Julia, Kotlin, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, Python 3.8, Racket, Ruby, Rust, Crals Cuift Tunnferint Visual Daric
give me thre code in java as given below formate
import java.io.*;
static long solve(int N, int[] A){
// Write your code here
long result =0;
return result;
}
}
give me the code in nice formate so that i can copy

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!