Challenge: Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not written. Do the above modifications to the input array in place, do not return anything from your function.
This is one of those times that I have truly amazed myself. I overthought this problem so much and ended up with a solution that had such a long runtime. Lesson learnt!
This is me overcomplicating my life |
An insanely simple solution by someone with more braincells than me |
Comments
Post a Comment