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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:12:01+00:00 2026-06-07T15:12:01+00:00

I was trying to code a simple problem which goes as follows: This week

  • 0

I was trying to code a simple problem which goes as follows:

This week there will be an important meeting of your entire department. You clearly remember your boss telling you about it. The only thing you forgot is the day of the week when the meeting will take place.

You asked six of your colleagues about the meeting. None of them knew the day when it will take place, but each of them remembered one day when it will not take place. The days they remembered were distinct. For a clever programmer like you, this was enough to determine the day of the meeting.

Now I have created two arrays for it, one containig all the weekdays and one containing all the days where the meeting would not take place and then created two lists from them.

public static void main(String[] args) {
    String[] notOnThisDay={"Sunday", "Monday", "Tuesday", "Wednesday",   "Thursday", "Friday"};
    String[] weekdays={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

    List<String> list1=Arrays.asList(weekdays);
    List<String> list2=Arrays.asList(notOnThisDay);
    Iterator<String> iter=list1.iterator();
    
    while(iter.hasNext()) {
        if(list2.contains(iter.next())) {
            iter.remove();
        }
    }

    for(String x:list1) {
        System.out.println(x);
    }
}

My strategy was to traverse through the weekdays list and if I find any day which is also present in the notonThisDay list, then I remove it. As such I am left with the day on which the meeting is to take place, but there seems to be something wrong with the iter.remove() method.

Please point out the error. And give me advice if my algorithm is good. I accept suggestions for a better algorithm if any.

  • 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-07T15:12:03+00:00Added an answer on June 7, 2026 at 3:12 pm

    Your problem is that Arrays.asList() returns a list of fixed size. You’re better to use one of the constructors of a known type of list, such as new ArrayList( ... ) or new LinkedList( ... ).

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

Sidebar

Related Questions

I am trying to write some simple code which will read a text file
Today I'm working with an interesting problem. I'm trying to code simple bookmarks, and
I am trying to understand this simple hashlib code in Python that has been
I'm frustrated with this. What I am trying to code is a simple xml
I am trying to create a simple web form which will give me a
I trying to figure out how to solve this (fairly) simple problem but I
I'm trying to solve a simple problem using LINQ, which I'm just learning. I
I'm trying to code a simple base64 encoder/decoder (to test my programming skill). I
I'm trying to write a simple code in Java to connect to a memcache
I am trying to implement a simple code tester : a very basic version

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.