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

Anonymous
2mo
Sir I really hard work and growth your company business
Venkatesh Karthik
4mo
Maximum difference and minimum index
Kavya Narkuti
5mo
Max minimum
MANVEL M
5mo
After the loop, the values of P and Q represent the indices where A[P] - A[Q] is maximum, with P > Q.
punam kadam
5mo
Max minimum
Anonymous
5mo
23 minutes
Anonymous
6mo
Maximus and minimum
Susheela SUSHEELA
6mo
Maximum and minimum
Anonymous
6mo
Maximum
Anonymous
6mo
Maximum A(p) Minimum A(Q)
Manoj Kumar sharma
6mo
Maximum & Maximum
subtlestarfish
7mo
works at
RAM SINGH CHAUHAN
This is the simple way but take a mind
subtlestarfish
7mo
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
7mo
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
7mo
Maximum and minimum
Anonymous
7mo
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
7mo
Minimum
Nisha Sushil Chavan
7mo
A(p) minimum
Anonymous
8mo
max-min
Farhan Mahbub
8mo
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
8mo
C=o
Venkatesan Gopalakrishnan
9mo
3 turns
ABHISHEK SHUKLA
9mo
C=O
Anonymous
10mo
Is c= 0
Bhulendra Patel
10mo
P
Shaik Bilal
10mo
A
Satveer Mahar
11mo
C=O
Sk Nadim
12mo
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...
Qualcomm Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❀️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter