Counting sort is an integer sorting algorithm that works by counting the number of objects with each key value and using those counts to determine the positions of each key in the output. It has input of n items with non-negative integer keys between 0 and k, and output is the items sorted by key. Counting sort runs in O(n+k) time and O(n+k) space, making it efficient when k is smaller than n.