You only have free questions left (including this one) .
Delete a node from a singly-linked list, given only a variable pointing to that node.
The input could, for example, be the variable b below:
typedef struct LinkedListNode {
void *data;
struct LinkedListNode *next;
} LinkedListNode;
LinkedListNode * newLinkedListNode(const void *data, size_t dataSize)
{
LinkedListNode *node = calloc(1, sizeof(LinkedListNode));
assert(node != NULL);
node->data = malloc(dataSize);
assert(node->data != NULL);
memcpy(node->data, data, dataSize);
return node;
}
LinkedListNode * newLinkedListNodeWithIntData(int intValue)
{
return newLinkedListNode(&intValue, sizeof(int));
}
void freeLinkedListNode(LinkedListNode *node)
{
if (node != NULL) {
free(node->data);
free(node);
}
}
LinkedListNode *a = newLinkedListNodeWithIntData(1);
LinkedListNode *b = newLinkedListNodeWithIntData(2);
LinkedListNode *c = newLinkedListNodeWithIntData(3);
a->next = b;
b->next = c;
deleteNode(b);
We can do this in time and space! But our answer is tricky, and it could have some side effects...
Start your free trial!
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Where do I enter my password?
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
It's easy and quick. No "reset password" flow. No password to forget.
It lets us avoid storing passwords that hackers could access and use to try to log into our users' email or bank accounts.
It makes it harder for one person to share a paid Interview Cake account with multiple people.
Start your free trial!
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Where do I enter my password?
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
It's easy and quick. No "reset password" flow. No password to forget.
It lets us avoid storing passwords that hackers could access and use to try to log into our users' email or bank accounts.
It makes it harder for one person to share a paid Interview Cake account with multiple people.
Start your free trial!
Log in or sign up with one click to get immediate access to free mock interview questions
We'll never post on your wall or message your friends.
Where do I enter my password?
Actually, we don't support password-based login. Never have. Just the OAuth methods above. Why?
It's easy and quick. No "reset password" flow. No password to forget.
It lets us avoid storing passwords that hackers could access and use to try to log into our users' email or bank accounts.
It makes it harder for one person to share a paid Interview Cake account with multiple people.
Editor
Reset editor
vim/emacs?
regular
vim
emacs
Run
{"id":36028169,"username":"2024-10-30_00:00:39_#@jqmt","email":null,"date_joined":"2024-10-30T00:00:39.378530+00:00","first_name":"","last_name":"","full_name":"","short_name":"friend","is_anonymous":true,"is_on_last_question":false,"percent_done":0,"num_questions_done":0,"num_questions_remaining":46,"is_full_access":false,"is_student":false,"first_payment_date":null,"last_payment_date":null,"num_free_questions_left":3,"terms_has_agreed_to_latest":false,"preferred_content_language":"python","preferred_editor_language":"","is_staff":false,"auth_providers_human_readable_list":"","num_auth_providers":0,"auth_email":""}
×
“ Your site was really indispensable for the Google/Amazon interview process. I've recommended your site to everyone I know that wants to become both a better programmer and a better interviewer. Great work.
—
Eric
. . .