Skip to content

Commit fc8b9af

Browse files
committed
i think this method is ask in interview difference btw remove() and remove_if()
1 parent ed7353f commit fc8b9af

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

List.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ int main(){
4747
list1.pop_front();
4848
//? Delete an element from middle in the list
4949
list1.remove(4);
50-
50+
//? Remove_if method
51+
list<int> lst = {1, 2, 3, 4, 5};
52+
lst.remove_if([](int x){ return x % 2 == 0; });
53+
display(lst);
5154

5255
//* Sorting the list
5356
list1.sort();

List.exe

4.53 KB
Binary file not shown.

0 commit comments

Comments
 (0)