Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6752825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:05:23+00:00 2026-05-26T13:05:23+00:00

I tried the sample demo at Codility website, and posted my solution but I’ve

  • 0

I tried the sample demo at Codility website, and posted my solution but I’ve a simple mistake but couldn’t determine it.

The problem is described here (The problem is only described please don’t care about the analysis there as that wasn’t not my solution)

http://codility.com/cert/view/certHNPV9B-7M4GAQR985B54VYF/details

my solution is here:

public static int min_router_peripherality ( int[] T ) {
        // write your code here
        int sum=0;

        for(int i=0;i<T.length;i++) sum+= T[i];

        int min = sum;
        int index = 0;
        int array [] = new int [T.length];

        for(int i=0;i<T.length;i++) { 

             min = sum -T[i];
             array[i] = min;
        }
        int x = array[0];

        for (int i=0; i<array.length;i++)
        {
            if (array[i]<x)
            {
                x = array[i];
                index = i;
            }
        }

        return index;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:05:24+00:00Added an answer on May 26, 2026 at 1:05 pm

    What I see as mistakes are the following:

    for(int i=0;i<T.length;i++) 
        sum+= T[i];
    

    Here you treat T[i] like some weight. But Node-Ids are no weights. Summing up node ids is useless.

    Then: The text says: “if T[P] = Q and P ≠ Q, …”. I don’t see anything which takes this into account.

    Then: Not understanding the algorithm I tried a simple “line” like this:

    int[] T = {1, 2, 3, 4, 5, 6, 7, 8, 9, 9};
    

    The result is 8. But in a line the result should be somewhere in the middle.

    Therefore I doubt that the linked page shows the results of the code you have posted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to compile Ercia Sadun's sample code here , but this error came
I tried to make a simple contact form via HTML and PHP but the
I tried to write a Neural Network system, but even running through simple AND/OR/NOR
I tried to make a simple demo program that use zlib to compress &
i just took the demo jquery UI dialog (model dialog) sample and tried to
Has anyone tried the ActiveRecord Intro Sample with C# 3.5? I somehow have the
I created a sample webservice which contain default 'HelloWorld' function as 'webmethod' when tried
I am currently learning F# and have tried (an extremely) simple example of FizzBuzz.
I am using Visual Studio 2008 Express and I tried creating a simple console
When I tried to do a simple modification of the hello android program that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.