Given a list l, return a new list that contains only the elements of l that are strs that contain the character 'x'. Do not alter l.
Is this a homework question? Have you started it yet? Where are you stuck? What language are you using? I don't think it's appropriate use of this site to simply be asking for the answers to homework.
Since robotsari says not to give the answer i won't.. but it's not hard at all, think of the possible data structures you can represent this list and then design an O(nm) algorithm, where m is the average length of each string..
I'm just saying, if you're going to post a question, please explain more. Forums like these should be used to learn. You don't learn by just posting your question and asking for the answer. It'd be better if you said something like, "I need to do this in Python. Here's the approach I tried <details, possibly code>, and here are the problems I'm having <list relevant errors, test cases that are wrong, etc>." You do yourself a massive disservice just copying answers - you won't learn squat.
@robotsari You are right, but giving hints never harmed anyone..
Btw, what language are you using? I'm guessing Python (2.7.x), so this can be done using filter() or a list comprehension.
Join our real-time social learning platform and learn together with your friends!