Home / Expert Answers / Computer Science / please-write-a-code-to-solve-the-following-problem-in-c-also-explain-the-code-do-please-read-the-pa253

(Solved): Please Write a code to solve the following problem in C. Also, Explain the code. Do Please read the ...



NOTE: the easy and the hard version of the problem vary on the basis of the constraints given. Use of any other libraries apaExamples
\begin{tabular}{|l|l|}
\hline input & Copy \\
\hline 72 \\
6066945659867 \\
457 \\
566 \\
\hline output & Copy \\
\hPlease Write a code to solve the following problem in C. Also, Explain the code. Do Please read the "Note" Given to understand the restrictions to solve the problem. Thanks

NOTE: the easy and the hard version of the problem vary on the basis of the constraints given. Use of any other libraries apart from "stdio.h" is not allowed. Otherwise, your submission will not be graded. Lawrence has bought cupcakes for Kone. But it turns out that Kone doesn't want to eat them. Kone will eat the cupcakes only if Lawrence solves the problem given by him. Kone arranges the cupcakes in a row and assigns a random value to the cupcake. The values assigned to the cupcakes will be given to you in the form of an array . He asks Lawrence to arrange the cupcakes in the ascending order of their values. Now he gives him queries to answer. In each query Kone gives three integers where are indices of the array. Lawrence needs to print the number of subarrays in the subarray which have distinct elements. Constraints: - - - - - Input The first line contains two spaced integers and . The next line contains spaces integers denoting the values of the cupcakes. Each of the next lines contain 3 integers . Output Print the number of subarrays in the subarray which have distinct elements for every query in separate line. Examples \begin{tabular}{|l|l|} \hline input & Copy \\ \hline 72 \\ 6066945659867 \\ 457 \\ 566 \\ \hline output & Copy \\ \hline 0 \\ 0 & \\ \hline \end{tabular}


We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe