def twoSum(nums: Array[Int], target: Int): Array[Int] = {

var util:Map[Int,Int] = Map()

var result = new ArrayBufferInt

val loop = new Breaks

loop.breakable{

for (x <- 0 until nums.length){

val left = target - nums(x)

if(!util.contains(nums(x))){

util += (left -> x)

}else{

```
result += util(nums(x))
result += x
loop.break()
}
}
}
result.toArray
}
```