From 613a55174f94ec3cc871ccc837d48df60728da0f Mon Sep 17 00:00:00 2001 From: David Date: Fri, 23 Sep 2022 13:28:49 +0000 Subject: [PATCH] clang-format and clang-tidy fixes for b24ca86e --- search/median_search2.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/search/median_search2.cpp b/search/median_search2.cpp index 9d99b3c5d..1e6fc802f 100644 --- a/search/median_search2.cpp +++ b/search/median_search2.cpp @@ -28,10 +28,10 @@ * Definition for singly-linked list. */ struct ListNode { - int val; ///< the value stored in the node - ListNode* next; ///< pointer to the next node - ListNode() : val(0), next(nullptr) {} ///< default constructor - ListNode(int x) + int val{0}; ///< the value stored in the node + ListNode* next{nullptr}; ///< pointer to the next node + ListNode() {} ///< default constructor + explicit ListNode(int x) : val(x), next(nullptr) {} ///< constructor with value for node->val provided ListNode(int x, ListNode* next) @@ -57,11 +57,12 @@ namespace median_search2 { * @returns Median node of the linked list. */ ListNode* middleNode(ListNode* head) { - if (!head) + if (!head) { return nullptr; + } // Fast and slow pointers - ListNode* fastptr; + ListNode* fastptr = nullptr; ListNode* slowptr = fastptr = head; // fast jumps 2 while slow jumps 1 @@ -79,7 +80,7 @@ ListNode* middleNode(ListNode* head) { * @returns void */ static void test() { - ListNode* head = new ListNode; + auto* head = new ListNode; head->val = 1; ListNode* temp1 = head;