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 7649143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:53:22+00:00 2026-05-31T10:53:22+00:00

This is an interesting problem I’ve come across that I feel should have an

  • 0

This is an interesting problem I’ve come across that I feel should have an elegant, provable solution but I haven’t quite been able to get it. I’ve defined it as:

Define a function that takes as input an array of N elements and a
positive integer R, and returns a circular array (or an array that you
treat as circular) where no two identical elements are less than R
apart, or a null if no such ordering is possible.

So f([a,b,d,c,a,d,k,a,d], 3) might return [a,b,d,a,k,d,a,c,d], but f([a,b,d,c,a,d,k,a,d,a,a], 3) would return null. I define two elements as being R apart if they have R-1 elements between them, so in the array [x,a,b,y], x and y are 3 apart on one side and 0 apart on the other.

I feel like this would be a great interview question as well.

  • 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-31T10:53:24+00:00Added an answer on May 31, 2026 at 10:53 am
    1. Split the array into groups of identical elements (with sorting or using a hashtable).
    2. Find the largest group. If its size is greater than floor(N/R), return null.
    3. If size of the largest group equals exactly N/R, partition (partially sort) the list of groups, so that all the groups of size N/R come first in the following step.
    4. For each group, put its elements to the result array (circular buffer), incrementing index by R, while it is possible. If R and N are not co-prime, sometimes – after N/GCD(N,R) increments – index will point to already used element. In such cases increment index by R+1 instead of R and continue.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So this is an interesting problem. I have custom tableviewcells that include a text
Here's an interesting problem: I have some jQuery that looks like this: $(document).ready(function() {
I have an interesting problem. I have a working M/R version of this but
I've come across an interesting problem with a Magento store that deals primarily in
I have an interesting problem and I was looking for a solution; Hoping that
This is an interesting conundrum. We have a WPF app that has a Vista-like
I ran into an interesting problem. I have a MySQL database that contains some
I have a rather interesting problem. I have a parent page that will create
Well, this is an interesting problem. I have an ASP.NET MVC3 Intranet application running
Ok, this is an interesting problem I think I have a list of items

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.