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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:46:22+00:00 2026-05-18T03:46:22+00:00

Given an Array arr of size 100000, each element 0 <= arr[i] < 100

  • 0

Given an Array arr of size 100000, each element 0 <= arr[i] < 100. (not sorted, contains duplicates)

Find out how many triplets (i,j,k) are present such that arr[i] ^ arr[j] ^ arr[k] == 0
Note : ^ is the Xor operator. also 0 <= i <= j <= k <= 100000

I have a feeling i have to calculate the frequencies and do some calculation using the frequency, but i just can’t seem to get started.

Any algorithm better than the obvious O(n^3) is welcome. 🙂

It’s not homework. 🙂

  • 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-18T03:46:23+00:00Added an answer on May 18, 2026 at 3:46 am

    I think the key is you don’t need to identify the i,j,k, just count how many.

    Initialise an array size 100

    Loop though arr, counting how many of each value there are – O(n)

    Loop through non-zero elements of the the small array, working out what triples meet the condition – assume the counts of the three numbers involved are A, B, C – the number of combinations in the original arr is (A+B+C)/!A!B!C! – 100**3 operations, but that’s still O(1) assuming the 100 is a fixed value.

    So, O(n).

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

Sidebar

Related Questions

Say I have an array of size 5. I want to take an index
Summary: Given an array {a, b, ..., w, x, ..., z} insert several elements
Is there a way to generically remove an object from an array? (maybe not
here is my problem I have the following array (for example) string[] arr =
I have an array of the length m*n , that stores a list of
I'm trying to generate unique permutations of an array using Math::Combinatorics. As CPAN page
I just made a Java n-tuple which is type-safe. I'm using some unconventional methods
hi am working with NSArrays using foundation tool and i have wrote the following
this question is from Codechef.com [if anyone is still solving this question dont look
Being fully self-taught without actually reading up on JavaScript (It's my job now, believe

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.