Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

嵌套数组的环形遍历 #557

Open
Rashomon511 opened this issue Aug 30, 2019 · 0 comments
Open

嵌套数组的环形遍历 #557

Rashomon511 opened this issue Aug 30, 2019 · 0 comments

Comments

@Rashomon511
Copy link
Owner

image

let iterator = (ar) => {
  let m = ar.length;
  let n = ar[0].length;
  for(let i = 0,j = n;i !== j;i++,j--,m--) {
    for(let i2=i;i2<j;i2++) {
      console.log(ar[i][i2]);
    }
    for(let i3=i+1;i3<m;i3++) {
      console.log(ar[i3][m-1]);
    }
    for(let i4=j-1;i4>i;i4--) {
      console.log(ar[m-1][i4-1]);
    }
    for(let i5=m-2;i5>i;i5--) {
      console.log(ar[i5][i])
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant