I have a “pointer” which keeps incrementing and I need to return the “head” of the pointer finally. I am in a dilemma to use either “pointer[0]” or have another variable called “head” and initialize it and return at the end. The former I feel makes the code looks soiled and later costs little memory. Any clean suggestion?
Share
You will always need two variables:
You cannot really implement it much differently because
tail[0] != head(unless the list is empty).Showing the code and telling us what exactly you try to achieve might lead to better answers.