According to the problem description we should “not assume that it is possible to record the length of the list”. I want to verify that this restriction does not mean that it’s impossible to know when we’ve reached the end of the list. Rather it only means the numeric distance traversed would be too large to store in memory. Is this interpretation correct?
7.7 Remove k-th last element from a list
testUser
#2
Yes, I would say that your assumption is correct. Else, we would not be able to compute the kth last element.
0 Likes
lgtout
#3
Thanks @testUser.
Another question - May I assume that, since the number k is stored in memory, the restriction on memory storage does not prevent me from introducting a count variable that can store any number up to k? So, since k is an integer, may I store any 32 bit number?
0 Likes
testUser
#4
yep, but that may not be always helpful since your list could be arbitrarily long and you want to return kth element from the last which would be (n-k) from the beginning of the list.
1 Like