kodecocodes / swift-algorithm-club

Algorithms and data structures in Swift, with explanations!
MIT License
28.85k stars 5k forks source link

Array2D - Enhance to include ability to create 2D array using either [col][row] or [row][col] subscripting. #991

Open l-rettberg opened 2 years ago

l-rettberg commented 2 years ago

Brief Intro

The Array2D algorithm is based on using column then row, ie [col][row] when accessing cells. Not sure if that is the commonly used approach? I thought the most common was row, column, ie [row][col], but perhaps that's really up to the developer.

More Details

Suggest updating the algorithm to include a boolean flag that the caller can define whether the 2D array should be created as [col][row] or [row][col] for most flexibility.