• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • About
  • Life
  • Tech
  • Travel
  • Work
  • Questions
  • Contact

Welcome

.

Climbing the Leaderboard Hackerrank [closed]

April 10, 2020 by

Questions › Climbing the Leaderboard Hackerrank [closed]
0
Vote Up
Vote Down
Garmaine asked 3 years ago
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 6 hours ago.

Problem statement:

  • Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ranking. The game uses Dense Ranking, so its leaderboard works like this:

    1. The player with the highest score is ranked number 1 on the leaderboard.

    2. Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately following ranking number. input:

  • first line contains number of scores on leaderboard
  • second line contains scores on leaderboard
  • third line contains number of alice plays
  • fourth line contains scores of alice

Output:

The position of alice on the leaderboard for each of his score how can I optimize the code so that I can complete it in minimum time.I am getting time complexity error for some inputs in test cases in hackerrank.

'''     

{
    int n,m,i=0,j;
    cin >> n;
    int score[n];
    while(i<n)
    {
        cin >> score[i];
        i++;
    }
    i=0;
    vector<int> v;
    cin >> m;
    int alice[m];
    for(i=0;i<n;i++)
    {
        if(i==0)
        {
            v.push_back(score[i]);
        }
        else if(score[i]!=score[i-1])
        {
           v.push_back(score[i]);
        }
        else
        continue;
    }
    i=0;
    while(i<m)
    {
        cin >> alice[i];
        int p=1;
        for(j=0;j<v.size();j++)
        {
            if(v[j]>alice[i])
            {
                p++;
            }
            else
            {
                break;
            }

        }
        cout << p << endl;
        i++;
    }
    return 0;

}

'''
Are you looking for the answer?
Original Question and Possible Answers can be found on `http://stackoverflow.com`

Question Tags: c++, competitive-coding, time

Please login or Register to submit your answer




Primary Sidebar

Tags

Advancements architecture beautiful life best building calling city commercial convenience employment Finances Cognitive decline Future gadgets Hidden Gems highway Home houses hydration Impact Innovations lamp lighting Mental health military tech Must-See New York City occupation Productivity recreation romance sepia shopping sippy cups smartphones social Technological breakthroughs technology toddlers Treasures turns Uncover Well-being Wonders Work Young onset dementia

Newsletter

Complete the form below, and we'll send you all the latest news.

Footer

Footer Funnies

Who knew that reading the footer could be such a hilarious adventure? As we navigate websites, books, and documents, we often stumble upon the unassuming space at the bottom, only to discover a treasure trove of amusement. In this side-splitting compilation, we present 100 jokes that celebrate the unsung hero of content – the footer. Get ready to chuckle, giggle, and maybe even snort as we dive into the world of footnotes, disclaimers, and hidden comedic gems. Brace yourself for a wild ride through the footer!

Recent

  • Unveiling the Enigma: Almost-Magical Lamp Lights Highway Turns
  • The Impact of Young Onset Dementia on Employment and Finances: Optimizing Post-Diagnostic Approaches
  • 11 Wonders of 2023 Technological Breakthrough – Unveiling the Future
  • Work from Home and Stay Mentally Sane – Achieve Productivity and Well-being
  • Hidden Gems of New York City – Uncover the Must-See Treasures!

Search

Tags

Advancements architecture beautiful life best building calling city commercial convenience employment Finances Cognitive decline Future gadgets Hidden Gems highway Home houses hydration Impact Innovations lamp lighting Mental health military tech Must-See New York City occupation Productivity recreation romance sepia shopping sippy cups smartphones social Technological breakthroughs technology toddlers Treasures turns Uncover Well-being Wonders Work Young onset dementia

Copyright © 2023