₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,657 members, 8,423,013 topics. Date: Tuesday, 09 June 2026 at 08:33 AM

Toggle theme

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

Nairaland ForumScience/TechnologyProgrammingCan You Explain This My Hackerrank Solution For Me? Please(pics) (598 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 JavascriptCan Some Explain This Hackerrank Question For Me please(pics)Pls Explain This For Me234

What Is A Function In JavascriptIs SaaS Currently The Only Way To Finally FreedomDo You Have A Startup?