继承人我试图教我自己。我想要一双在嵌套indexArray
元件的指向numberArray
内部元件:非嵌套数组嵌套数组Swift
IOW:IF indexArray
具有[[0,2],[3,4]]
我想要的嵌套元素在numberArray
#0
和
numberArray
#2
和元件3和4点
func findNumIndex(numberArray: [Int], indexArray: [[Int]]) -> Int {
// Use the NESTED index elements to arrive at element index in numberArrray
}
findNumIndex(nums: [0,1,2,3,4,5,6,7,8,9], queries: [[0,1],[1,2],[3,4]])
// We would look at index 0 and 1, index 1 and 2, index 3 and 4 and get the numbers/
起初我想平坦化数组,但这不是我想要的。
Annnnnd我仍然在赚钱......哈哈! –
没有错。我的建议:阅读'map','flatMap','reduce'和'filter'方法。它们在很多情况下非常有用! –