'What's the quickest way to swap values of 2d array in swift?

I'm trying to efficiently flip values of a 2d array from [[a, b], [a, b], [a, b]] to [[b, a], [b, a], [b, a]]



Solution 1:[1]

You can combine the map and reversed function.

As per Swift documentation

for map function time complexity is O(N)

for reversed - time complexity is O(1)

The total time complexity is = O(N)

var arr = [["a", "b"], ["a", "b"], ["a", "b"]]
arr = arr.map { $0.reversed() }
print(arr)

Solution 2:[2]

The problem has been resolved after I added Pub/Sub Subscriber role to the service account. So it is the IAM issue...

Looks like the Dataflow is creating a subscription on the fly when it runs, that's why only admin role on resources level(topic/subscription) was not enough, it needs to add on service account IAM.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Louis Chen