+ 5
Array depth
So im writing this code and i figured out i needed something,how to calculate array depth.There are multidimensional arrays,the problem is,how do i calculate an arrays deepest dimension. e.g arr=[ [ [1,2],[3,4] ],6,4,3,7]; as you can see this arrays dimension is three.but if i have arrays with several dimensions how do i find it? e.g2 arr=[ [1,2],[3,4] ]; this is a 2d array,and so on.Im creating arrays with 20+ dimensions and i need a way of figuring out the arrays dimension,thanks.
3 ответов
+ 3
I'm guessing JS code so:
https://code.sololearn.com/WAu11JJbsjQI
+ 4
Sorry for sending links without explanation. These should help:
For C#.NET:
https://msdn.microsoft.com/en-us/library/system.array.length(v=vs.110).aspx
For Python:
https://stackoverflow.com/a/3061789/5087494
For Javascript:
https://stackoverflow.com/a/10237736/5087494
+ 2
In C++, it strongly depends and I need your exact data structure to tell you how it's possible or how to work around it.