Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .

0 like 0 dislike
3,698 views

For proper oa or interview experiences list of all top tech companies visit :

https://oa.desiqna.in

https://interview.desiqna.in

 

image

 

in Online Assessments by Expert (44,360 points)

2 Answers

0 like 0 dislike
 
Best answer

Analyzing Arrays
Consider a 1-based array of n integers, arr[n]. For each element arr[i] where 1 <= i < n, determine the value of arr[i] ** arr[i+1] modulo (10 ** 9 + 7).  Return the lowest index of the highest modulo value.

by Expert (44,360 points)
0 like 0 dislike
Solution:

#include <bits/stdc++.h>
using namespace std;
int calculate(int a, int b){
	    return (int)((int)pow(a,b) % (int)(pow(10,9)+7));
	}
int powerArray(vector<int> arr){
    int result = INT_MAX;
    int n = arr.size();
	for(int i=1; i<=n-2; i++){
	    if(calculate(arr[i], arr[i+1])  >= calculate(arr[i+1], arr[i+2])){
	        result = min(result, i);
	    }
	}
	return result+1;
}
by Expert (44,360 points)
...