Help regarding c++ Mode program. | Sololearn: Learn to code for FREE!

+2

Help regarding c++ Mode program.

Here my code:(its working BUT Why arr[i] is always equal to arr[j] even if all the elements are unique) arr is a sorted vector containing all the numbers and "a" is the number of elements in vector. for example arr[10]=64630 11735 14216 99233 14470 4978 73429 38120 51135 67060 https://code.sololearn.com/cXkB2o1jOZ2l/?ref=app from line 28 to 49 Here question link: https://www.hackerrank.com/challenges/s10-basic-statistics/problem

11/6/2019 11:51:13 AM

Aditya Kumar

5 Answers

New Answer

+1

so changing value at line 30 [j=j+1] (initially j=1) and at line 36 [==0] (initially ==1), made it work as should be I am dumb sometime😛

+1

+1

Aditya Kumar When i and j values are same, then arr[i] == arr[j] print i and j values when arr[i] == arr[j] What you are trying to do there, i didn't tried to understand.

0

~swim~ Well i was checking the elements are unique or not, if not increase the value of arrTemp[i] by One

0

Please looks at code again and post unencrypted comment