reverse(a, a + N) (a[0] ~ a[N-1] を逆順にする)
reverse(a + l, a + r) (a[l] ~ a[r-1] を逆順にする)
計算量は O(N)
int a[8] = {8, 3, 7, 1, 4, 6, 2, 5};
reverse(a + 2, a + 7);
{8, 3, 2, 6, 4, 1, 7, 5}
Go to list of users who liked
More than 1 year has passed since last update.
reverse(a, a + N) (a[0] ~ a[N-1] を逆順にする)
reverse(a + l, a + r) (a[l] ~ a[r-1] を逆順にする)
計算量は O(N)
int a[8] = {8, 3, 7, 1, 4, 6, 2, 5};
reverse(a + 2, a + 7);
{8, 3, 2, 6, 4, 1, 7, 5}
Register as a new user and use Qiita more conveniently
Go to list of users who liked