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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:12:42+00:00 2026-05-24T05:12:42+00:00

This is a question Im trying to figure out for a job pre-interview questioniar.

  • 0

This is a question Im trying to figure out for a job pre-interview questioniar. and i dont know python that well so im struggling with this problem.

the real questions for the job are big-o performance and making it better but i can do that i just need to understand this code

question A: in is_bar they compare the iterator to the array (if i == b). is this the equivalent of (if i == b.length)?

question B:
so following the flow of the function and assuming the above and (a = [1,2,3] b=[3,4,5]) is true the first comparison is comparing two iterators????

so it would be:

  1. is_bar(b, 0)
  2. for i in b (says a but its b from above)
  3. if 0 == 0
  4. so it evaluates to true and does c.append(0)
  5. does this 3 more times and since its comparing iterators it would append 1,2 than unique (c)
    6.which makes a new array the same size as c and makes every values = 1

but that wouldnt make sense. Appearently there is somthing im missing because a function that takes 2 arrays, then creates an array of equal size of the second array and makes all values = 1 would be stupid.

question C: what does b.keys() return exactly (i looked up the function but it says “list of all the keys used” but that doesnt make sense since it is a one-dimension array)

 def foo(a, b):
         """ a and b are both lists """
         c = []
         for i in a:
             if is_bar(b, i):
                 c.append(i)
         return unique(c)

      def is_bar(a, b):
         for i in a:
             if i == b:
                 return True
         return False

      def unique(arr):
         b = {}
         for i in arr:
             b[i] = 1

         return b.keys()
  • 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-24T05:12:43+00:00Added an answer on May 24, 2026 at 5:12 am

    A: No. It compares each element of a to b. So if b is an element of a it returns True.

    B: Change based on the above.

    C: b is not an array. It’s a dictionary (the b = {}).

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

Sidebar

Related Questions

This might be a little bit odd question, but Im trying to figure out
In looking at this question I was trying to figure out this function _shl:
I'm trying to figure out the answer to this question with the following code,
I apologize if this question is slightly subjective... I am trying to figure out
I'm lead to this question when trying to figure out the difference between jQuery's
Was just thinking about this question while trying to figure out some code written
While trying to answer this question I found that the code int* p =
I've been looking through related LINQ questions here trying to figure this one out,
Following on from this question...I'm trying to unit test the following scenario: I have
This question is a result of what i noticed while trying to answer another

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.