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":33966042,"username":"2024-05-19_00:40:59_37v111","email":null,"date_joined":"2024-05-19T00:40:59.484303+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":"","preferred_editor_language":"","is_staff":false,"auth_providers_human_readable_list":"","num_auth_providers":0,"auth_email":""}
×
“ Interview Cake was a great help in preparing for my interview. The hints and detailed explanations allow you to figure problems out for yourself and learn the thought process needed for interviews. Plus, you get a refund if you don't get the job.
—
Philip
. . .