This uses extra space