Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

List subtract

Nice to solve before

Instructions

Given two lists implement a function which will determine witch elements from first list have to be subtracted (removed) to obtain second list (what elements needs to be removed from first list so it it would be equal to second list). There may be more than one element with the same value. For simplicity we assume that input is always correct (it is always possible to remove values from first list to form second list).

Challenge | Solution

Examples

getSubtraction(listOf("A", "B", "C"), listOf("A")) // "B", "C"

getSubtraction(listOf("A", "B", "C"), listOf("A", "B")) // "C"

getSubtraction(listOf("A", "B", "C", "A"), listOf("A", "B")) // "C", "A"
 
getSubtraction(listOf("A", "B", "C"), listOf("A", "B", "C")) // nothing

Hints

Hint 1 Use frequency counter.