List Programs
Python programs focused on list creation, traversal, searching, modification, and set-like operations.
25 program solutions
Program Solutions
Sum of List Elements
Calculate the sum of all elements in a list of numbers.
Largest Element in List
Find the largest element in a list of numbers.
Smallest Element in List
Find the smallest element in a list of numbers.
Count Occurrences in List
Count how many times a given element occurs in a list.
Remove Duplicates from List
Remove duplicate elements from a list while preserving order.
Merge Two Lists
Merge two lists into a single list.
Intersection of Lists
Find the common elements between two lists.
Union of Lists
Find the union of two lists (unique elements from both).
Sort List
Sort a list of numbers in ascending order.
Reverse List
Reverse a list in-place using slicing.
Check if List is Sorted
Check whether a list is sorted in non-decreasing order.
Find Second Largest Element
Find the second largest distinct element in a list.
Find N Largest Elements
Find the N largest elements in a list.
Clone / Copy List
Create a shallow copy of a list.
Rotate List
Rotate a list by K positions to the right.
Remove Empty Lists
Remove empty sublists from a list of lists.
Flatten Nested List
Flatten a shallow nested list (list of lists) into a single list.
Find Common Elements of Two Lists
Find elements that appear in both lists (preserving list order of the first).
List Slicing Programs
Demonstrate common list slicing operations (first N, last N, every Kth element).
Replace List Elements
Replace all occurrences of a value in a list with another value.
Remove Element by Value
Remove the first occurrence of a value from a list, if present.
Count Prime Numbers in List
Count how many prime numbers are present in a list of integers.
Pair Sum Problem
Check if there exists a pair of numbers in the list that adds up to a target sum.
Unique Elements from Both Lists
Find elements that appear in exactly one of the two lists (symmetric difference).
List Difference
Find elements that are in the first list but not in the second.