Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed to find correct 28 triples
    primarykey
    data
    text
    <p>Hi guys I found interesting question from InterviewSteet site.. I'm little bit confused with question. Help me with understanding question please. I'm getting 35 triples but only 28 is expected from sample. I added my 35triples output. please help me to find 28 triples. wat is my mistake in understanding question. i</p> <p>Question:</p> <blockquote> <p>There is an integer array d which does not contain more than two elements of the same value. How many distinct ascending triples (d[i] &lt; d[j] &lt; d[k], i &lt; j &lt; k) are present?</p> </blockquote> <p>Input format</p> <blockquote> <p>The first line contains an integer N denoting the number of elements in the array. This is followed by a single line containing N integers separated by a single space with no leading/trailing spaces</p> </blockquote> <p>Output format:</p> <blockquote> <p>A single integer that denotes the number of distinct ascending triples present in the array</p> </blockquote> <p>Constraints:</p> <pre><code>N &lt;= 10^5 Every element of the array is present at most twice Every element of the array is a 32-bit positive integer </code></pre> <p>Sample input:</p> <pre><code>6 1 1 2 2 3 4 </code></pre> <p>Sample output:</p> <pre><code> 4 </code></pre> <p>Explanation: The distinct triplets are</p> <pre><code>(1,2,3) (1,2,4) (1,3,4) (2,3,4) </code></pre> <p>my input:</p> <pre><code>10 1 1 5 4 3 6 6 5 9 10 </code></pre> <p>my output:</p> <pre><code>35 </code></pre> <p>Explanation: The distinct triplets are</p> <pre><code>(1,3,4) </code></pre> <p>(1,3,5) (1,3,6) (1,3,9) (1,3,10) (1,4,5) (1,4,6) (1,4,9) (1,4,10) (1,5,6) (1,5,9) (1,5,10) (1,6,9) (1,6,10) (1,9,10) (3,4,5) (3,4,6) (3,4,9) (3,4,10) (3,5,6) (3,5,9) (3,5,10) (3,6,9) (3,6,10) (3,9,10) (4,5,6) (4,5,9) (4,5,10) (4,6,9) (4,6,10) (4,9,10) (5,6,9) (5,6,10) (5,9,10) (6,9,10)</p> <p>Expected output:</p> <pre><code>28 </code></pre> <p>I'm getting <code>35 triples</code> but <code>28</code> is correct answer. wat is my mistake??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload