Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 829e1bc

Browse files
author
Rohit Dandnayak
committed
array data structure added
1 parent 5c12f45 commit 829e1bc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function rotateArray(arr) {
2+
let temp = arr[0];
3+
let len = arr.length;
4+
for (var i = 0; i < len - 1; i++) {
5+
arr[i] = arr[i + 1];
6+
}
7+
arr[i] = temp;
8+
return arr;
9+
}
10+
11+
function rotateArrayBy(arr, d) {
12+
for (let i = 0; i < d; i++) {
13+
rotateArray(arr);
14+
}
15+
return arr;
16+
}
17+
18+
console.log(rotateArrayBy([1, 2, 3, 4, 5], 2));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function gcd(a, b) {
2+
if (a === 0) return b;
3+
let remainder = b % a;
4+
return gcd(remainder, a);
5+
}
6+
7+
console.log(gcd(22, 24));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /