Skip to content

Commit

Permalink
Update ancestor.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kounkou authored Nov 27, 2024
1 parent 647639d commit 75afd4f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions logic/linked-list/ancestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var question = [
{
id: "Ancestor",
category: "Linked List",
placeHolderCpp: `struct ListNode {\n int data;\n ListNode* next;\n};\n\nListNode* findAncestor(ListNode* head, int target) {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`,
placeHolderCpp: `struct ListNode {\n int data;\n ListNode* next;\n};\n\nListNode* findAncestor(ListNode* head, int t) {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`,
placeHolderGo: `func findAncestor(head *ListNode, target int) *ListNode {\n ...\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n`,
difficulty: "Medium",
question: "Find the Ancestor Element in Linked List",
Expand All @@ -13,11 +13,11 @@ var question = [
ListNode(int v) : val(v), next(nullptr) {}
};
ListNode* findAncestor(ListNode* head, int v) {
ListNode* findAncestor(ListNode* head, int t) {
ListNode* prev = nullptr;
while (head != nullptr) {
if (head->val == v) {
if (head->val == t) {
return prev;
}
prev = head;
Expand Down

0 comments on commit 75afd4f

Please sign in to comment.