crackAlgo

Find the location Id | Wipro previous year question paper solution

Find the location Id | Wipro previous year question paper solution Problem:-

Weather Today’ is a media company that provides online weather forecasting services. To create a new location ID in a state the company first prepares a list of N existing location IDs. Each location in the list is identified by a location ID that ranges from 0 to N-1. The list consists of the location’s daily average temperature (denoted by positive or negative numbers). The sum of the location IDs of the two locations whose product of temperatures are highest is the new generated location ID.

Write an algorithm to generate the new location ID from the existing list of N location IDs,

Input:- 

The first line of the input consists of an integer- num Of Locations, representing the number of existing

locations (N).

The last line of input consists of N space-separated integers – temp0,temp1., tempN-1 representing the

temperatures of the selected locations.

Output:-

Print an integer representing the new location ID generated from the existing list of N location IDs.

Note:– Only locations with distinct temperatures will be considered.

Example:

Input:

7

-3 8 -6 9 -7 8 10

Output:

9

Explanation:

The maximum product of the temperatures is 90, Le. 9*10. So, the sum of the IDs of the location is 9.

Code of Find the location Id | Wipro previous year question paper solution:-

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

int main()
{
   int n;
   int a[n];
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   int s1,s2,max;
   max=a[0]*a[1];
   s1=0;
   s2=1;
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           if((a[i]*a[j])>max)
           {
               s1=i;
               s2=j;
               max=a[i]*a[j];
           }
       }
   }
   cout<<s1+s2;
    return 0;
}

 

Output:-

7
-3 8 -6 9 -7 8 10
9

 

Recommended Post:

Full C course:-    

Key points:-

Cracking the coding interview:-

Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

  • Engineering mathematics -4 MCQs
  • CSS (Computer cyber security ) MCQS
  •  

    Wipro previous question paper solution , wipro previous year question papers with answers pdf,
    wipro previous year questions, wipro question paper 2021,wipro online assessment test questions and answers,wipro model papers 2020,wipro previous year coding questions,wipro online assessment test questions and answers 2022,wipro aptitude questions with answers pdf,wipro question paper 2021,wipro model papers 2020,wipro previous year coding questions,10 wipro placement papers,
    wipro previous year question papers with answers pdf

Leave a Reply

Your email address will not be published.