₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,346 members, 8,511,429 topics. Date: Sunday, 01 November 2026 at 04:09 PM

Toggle theme

Can You Explain This My Hackerrank Solution For Me? Please(pics) - Programming - Nairaland

Nairaland Forum › Science/Technology › Programming › Can You Explain This My Hackerrank Solution For Me? Please(pics) (627 Views)

1 Reply

Can You Explain This My Hackerrank Solution For Me? Please(pics) by TastyFriedPussy(op): 9:56am On Nov 07, 2022
first picture is the problem
second picture is my solution

my solution passed, and I solved it all myself except for the second for loop part, which i had to copy from somewhere. i could not figure out how to make the array print out in reverse order. At first i tried of using swap(), a C++ function, and i never even thought that a loop could used to swap the arrar items, when i copied the for loop code, and it worked, i was like how on earth did this work? i thought i needed a specia function for swapping arrays and i started googling but nothing was working.

so please, can someone explain to me how the for loop is swapping the array elements in reverse order.
see picture below

@qtguru (i know sey i don too dey disturb you but no vex kiss )

honestly, I'm finding it a little hard to understand loops.. sometimes when i do things with loops, it always runs into an infinite loop cry

Re: Can You Explain This My Hackerrank Solution For Me? Please(pics) by qtguru(m): 10:37am On Nov 07, 2022
Tip: Always pay attention to constraint

N = Total Number of Array Length
A[I] = A is Array and i the index in the array
A[N] = Tail of the array
A[0] = Head of Array

Normal flow A[0],A[1]......................A[i] where i is the number
Reverse Flow A[N], A[N-i]...............................................A[0]

What it means is start at the tail to the head instead of the normal flow.

Note: I don clock in, so I won't respond easily peace bro
Re: Can You Explain This My Hackerrank Solution For Me? Please(pics) by qtguru(m): 11:51am On Nov 07, 2022
Update ?
1 Reply

Solve The Fizz - Buzz Hackerrank Challenge In Both Java And Javascript • Can Some Explain This Hackerrank Question For Me please(pics) • Pls Explain This For Me • 2 • 3 • 4

How To Create Components In React - Xutini • How To Set Up Your Koder On Iphone • I Am Beign Threatened With The Commissioner Of Police