Remove top frequency key word list of list of words năm 2024

Sometimes, in the process of data filtering we have a problem in which we need to remove words which are composite of certain letters. This kind of application is common in data science domain. Let’s discuss certain ways in which this task can be performed.

Method

1 : Using all() + list comprehension The combination of above methods can be used to perform this task. In this, we just check for all list characters using all() in each list and filters out string which has any one of characters.

Python3

from itertools

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

6

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

Time Complexity: O(n) where n is the number of elements in the list “test_list”. Auxiliary Space: O(n), where n is the number of elements in the new res list

Method

2 : Using loop This is brute method in which this task can be performed. In this we use loop and conditional statements to perform this task.

Python3

from itertools

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

05

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

06

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

12

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

15

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

17

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

15

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

23

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

06

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

29

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

30

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

06

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

34

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

36

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

39

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

43

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

45

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

6

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

Time Complexity: O(n*n) Auxiliary Space: O(n), where n is length of list.

Method

3 : Using replace() and len() methods

Python3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

84

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

05

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

88

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

12

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

92

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

94

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

97

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

17

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

00

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

94

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

03

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

07

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

07

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

12

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

14

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

6

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

Time Complexity : O(N*N) Auxiliary space : O(1)

Method

4 : Using Counter() function

Python3

from

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

22

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

05

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

60

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

62

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

88

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

12

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

68

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

70

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

73

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

75

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

76

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

73

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

80

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

68

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

84

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

36

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

89

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

76

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

14

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

6

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

Time Complexity : O(N*N) Auxiliary space : O(N)

Method

5: Using operator.countOf() method

Python3

from itertools

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

03

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

05

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

06

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

12

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

15

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

17

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

53

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

34

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

30

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

06

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

29

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

30

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

06

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

34

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

36

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

39

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

43

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

79

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

6

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

Time Complexity : O(N*N) Auxiliary space : O(1)

Method

6: Using the recursive method.

Python3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

86

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

87

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

89

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

90

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

92

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

07

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

96

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

98

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

99

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

90

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

01

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

34

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

90

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

88

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

11

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

13

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

76

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

01

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

90

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

01

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

34

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

30

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

25

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

26

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

90

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

98

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

29

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

08

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

32

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

67

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

34

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

69

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

6

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

Time Complexity : O(N*N) Auxiliary space : O(N)

Method

7: Using filter() and lambda function:

Python3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

10

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

12

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

14

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

15

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

17

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

18

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

20

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

22

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

24

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

26

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

Time Complexity : O(N*N) Auxiliary space : O(N)

Method

8 : Using set intersection

Python3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

9

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

1

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

42

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

43

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

8

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

47

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

7

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

0

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

10

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

12

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

14

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

15

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

4

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

42

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

70

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

2

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

3

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

5

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] The filtered strings are : ['is', 'best']

6

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : ['g', 'o'] ['is', 'best']

6

Output

The original list is : ['gfg', 'is', 'best', 'for', 'geeks'] The character list is : {'o', 'g'} The filtered strings are : ['is', 'best']

Time complexity: O(N), where N is the number of elements in test_list Auxiliary Space: O(N), in the worst case, all elements in test_list are kept in the resulting list

Explanation: This method uses filter and set to achieve the desired result. set is used to convert the list of characters into a set, which allows for constant time look ups. filter is used to keep only those elements from test_list for which the intersection with char_list is empty.

How to check the frequency of words in a list?

Find frequency of each word in a string in Python.

Approach 1 using list():.

Split the string into a list containing the words by using split function (i.e. string. ... .

Initialize a new empty list..

Now append the word to the new list from previous string if that word is not present in the new list..

How do you remove words from a list of words in Python?

There are three ways in which you can Remove elements from List:.

Using the remove() method..

Using the list object's pop() method..

Using the del operator..

How do I remove common words from a string?

Algorithm :.

Split the two input sentences into lists of words..

Compute the set intersection of the two lists to find common words..

Filter out the common words from both sentences..

Print the remaining words in each sentence..

How do you remove certain words from text in Python?

In Python you can use the replace() and translate() methods to specify which characters you want to remove from the string and return a new modified string result. It is important to remember that the original string will not be altered because strings are immutable.nullPython Remove Character from a String - freeCodeCampwww.freecodecamp.org › news › python-remove-character-from-a-string-...null