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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:35:36+00:00 2026-06-07T02:35:36+00:00

I have n integers and I need a quick logic test to see that

  • 0

I have n integers and I need a quick logic test to see that they are all different, and I don’t want to compare every combination to find a match…any ideas on a nice and elegant approach?

I don’t care what programming language your idea is in, I can convert!

  • 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-06-07T02:35:37+00:00Added an answer on June 7, 2026 at 2:35 am

    You don’t have to check every combination thanks to commutivity and transitivity; you can simply go down the list and check each entry against each entry that comes after it. For example:

    bool areElementsUnique( int[] arr ) {
        for( int i=0; i<arr.Length-1; i++ ) {
            for( int j=i+1; j<arr.Length; j++ ) {
                if( arr[i] == arr[j] ) return false;
            }
        }
        return true;
    }
    

    Note that the inner loop doesn’t start from the beginning, but from the next element (i+1).

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

Sidebar

Related Questions

I have a text box that accepts integers, and I need it to run
Background: I have a large 2D array of integers that I need to load
I have a list of integers or of strings and need to pass it
I have a local collection of record Id's (integers). I need to retrieve records
I have buffer/payload of integers where every 4 bytes is a field which i
After a quick scan of related questions on SO, I have deduced that there's
I have a need to create a quick class with just 2 properties (left
I want to subtract two signed 8bit integers in JavaScript. As JavaScript doesn't have
I need to store objects that have a number (>2) of integer member variables
Say you need to have a list/array of integers which you need iterate frequently,

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.