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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:07:06+00:00 2026-06-15T10:07:06+00:00

node_marked_array.add(strings[0]); for (int i = 0; i < strings.length; i++) { for (int a

  • 0
node_marked_array.add(strings[0]);

for (int i = 0; i < strings.length; i++) {
    for (int a = 0; a < strings2.length; a = a + 2) {
        if (node_marked_array.get(i).equals(strings2[a])) {
            if (!node_marked_array.get(i).equals(strings2[a + 1])) {
                //    System.out.println("marked node: " + node_marked_array.get(i) + "=" + strings2[a] + ", added node " + strings2[a+1]);
                node_marked_array.add(strings2[a + 1]);
            }
        }
    }
}

I have an array named strings2 of elements each being:

1, 2, 1, 3, 2, 3, 2, 4, 3, 2, 5, 5, 2,

and my code is supposed to go through the array and if it matches for example any of the element that is in the array called strings: {1,2,3,4,5} with that of strings2 for each even element. It checks the i+1 element of the array above to see if the element is already added to the marked array, if it isn’t then it adds it. However I am seeing duplicate values even with

if (!node_marked_array.get(i).equals(strings2[a + 1]))

output: 1 2 3 3 4 2 5 2 5 5

  • 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-15T10:07:07+00:00Added an answer on June 15, 2026 at 10:07 am

    Use Set. Array is the wrong data type for this problem.

    It contains a .toArray() method that will give you back an array after you’ve constructed the set, if that is what you require.

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

Sidebar

Related Questions

HashSet<String> noDuplicate = new HashSet<String>(); for(int i=0;i<strings.length;i++) { for(int a=0;a<strings2.length;a++) { if(noDuplicate.get(i).equals(strings2[a])) //blahblah code
4 node Binary Search tree: 2143. there are 3 ways to insert and get
struct node { node(int _value, node* _next) : value(_value), next(_next) {} int value; node*
struct Node { int value Node* next; } typedef List Node* const Set operator
struct node { int id; float weight; }; int find_last(struct node Prio_Q[]) { int
I have a xml Node as : <description> <p>Results of a national survey of
I have a force-directed graph where on node mouseover the elements which are not
I don't have much experience with Javascript, Node.js or Socket.io. I'm trying to create
I have checked out a directory from my local SVN: server. After changing some
I have the following table: if object_id(N'dbo.Node') is null create table dbo.Node ( ID

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.