← 返回 meta 的题目列表Find elements in first list but not in second
类型:online_judge
Given two lists, list1 and list2, find all elements that are in list1 but not in list2, preserving their original order from list1.
Input
list1: List of integers, representing the first list.
list2: List of integers, representing the second list.
Output
list: List of integers, representing elements found in list1 but not in list2.
Example
Input:
list1 = [1, 2, 3, 4, 5]
list2 = [2, 4]
Output:
[1, 3, 5]
Example
Input
list1 = [1, 2, 3, 4, 5]\nlist2 = [2, 4]
Output
[1, 3, 5]