Given an array A[n], write a C program to find P and Q (P>Q) such that A[P] - A[Q] is maximum
AnswerBot
1y
C program to find P and Q (P>Q) such that A[P] - A[Q] is maximum
Iterate through array and keep track of maximum difference and corresponding indices
Initialize P and Q to first two elements and update ...read more
JEYA BELLA D
7d
A[P] - A[Q] represents the difference between the value at index P and the value at index Q. To maximize this difference, you need to select the largest possible value for A[P] and the smallest possib...read more
Anonymous
17d
Work work & smart work need.
Anonymous
3mo
Sir I really hard work and growth your company business
Venkatesh Karthik
5mo
Maximum difference and minimum index
Kavya Narkuti
6mo
Max minimum
MANVEL M
7mo
After the loop, the values of P and Q represent the indices where A[P] - A[Q] is maximum, with P > Q.
punam kadam
7mo
Max minimum
Anonymous
7mo
23 minutes
Anonymous
7mo
Maximus and minimum
Susheela SUSHEELA
7mo
Maximum and minimum
Anonymous
7mo
Maximum
Anonymous
7mo
Maximum A(p)
Minimum A(Q)
Manoj Kumar sharma
8mo
Maximum & Maximum
subtlestarfish
8mo
works at
RAM SINGH CHAUHAN
This is the simple way but take a mind
subtlestarfish
8mo
works at
RAM SINGH CHAUHAN
Initialize two variables to keep track of the maximum difference and the indices π P and π Q. Iterate through the array while maintaining the minimum value found so far and its index. For each ele
Simran Pathan
8mo
Simply find the maximum element of the array as per procedure and catch that index in one variable. Same with the minimum element of the array. And then print the indexes of minimum and maximum number...read more
Ashwini Jolapuram
8mo
Maximum and minimum
Anonymous
9mo
C program to find p and q (p>q) such that A(p) -A(q) is macimumltere through arry and jeep track of maximum difference and corresponding indiceslnitialize p and 1 to first two elements and u
Anonymous
9mo
Minimum
Nisha Sushil Chavan
9mo
A(p) minimum
Anonymous
9mo
max-min
Farhan Mahbub
9mo
Initialize two variables to keep track of the maximum difference and the indices π P and π Q. Iterate through the array while maintaining the minimum value found so far and its index. For each element...read more
Anonymous
9mo
C=o
Venkatesan Gopalakrishnan
10mo
3 turns
ABHISHEK SHUKLA
11mo
C=O
Anonymous
11mo
Is c= 0
Bhulendra Patel
12mo
P
Shaik Bilal
1y
A
Satveer Mahar
1y
C=O
Sk Nadim
1y
C program to find P and Q (P>Q) such that A(P)-A(Q) is maximum Iterate through array and keep track of maximum difference and corresponding indices Initialize P and Q to first two elements and updated...read more
Ganesh Chotugiri Gosavi
1y
This is the simple way but take a mind
Anonymous
1y
C program to find p and q (p>q) such that A(p) -A(q) is macimumltere through arry and jeep track of maximum difference and corresponding indiceslnitialize p and 1 to first two elements and u
Abhay H Kashyap
2y
I dont think the below solution will work because of the condition P>Q. the maximum element is present before the minimum element in the array then it will give the wrong answer.
Maintaing a variabl...read more
shafee ah
2y
this the simple way !! :)
shafee ah
2y
we can write two function
The first one - will find the where the maximue value in the array - then return the index of this item
The secound - will find the minum of the value of the array - then r...read more
Add answer anonymously...
Top Qualcomm Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Qualcomm Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app