I am not able to understand how thies code m[i-1]=m[i];is šŸ‘‰ deleting an element from an array useing for loop? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 19

I am not able to understand how thies code m[i-1]=m[i];is šŸ‘‰ deleting an element from an array useing for loop?

can some one explain me thies šŸ‘† https://code.sololearn.com/cTuPAI8J7bTj/?ref=app

28th May 2018, 12:26 PM
Vijay(v-staršŸŒŸ)
Vijay(v-staršŸŒŸ) - avatar
3 Respostas
+ 4
imagine you want to remove 3rd element from this array {1, 2, 3, 4, 5} inorder to remove 3rd element, we need to shift 4th, 5th left once result would be {1, 2, 4, 5} m[i-1] = m[i] does this job for you i.e it shifts [i]th element to the [i-1]'s place
28th May 2018, 12:53 PM
ā€ŽĀ ā€ā€ā€ŽAnonymous Guy
+ 16
thank you Bahubali šŸ˜ƒand Sreejith
28th May 2018, 2:08 PM
Vijay(v-staršŸŒŸ)
Vijay(v-staršŸŒŸ) - avatar
+ 3
in line 19 u are assigning m[2]=m[3] that's why it delete the m[2] and then. n-- make n=4
28th May 2018, 12:50 PM
Bahubali
Bahubali - avatar