From 917aecb33fe20d3b90b679da483b8d796e851162 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sat, 23 Jul 2022 13:12:05 +0200 Subject: [PATCH] chore: format sources Signed-off-by: Matej Focko --- problems/can-place-flowers.cpp | 16 +++++++++------- problems/middle-of-the-linked-list.cpp | 7 ++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/problems/can-place-flowers.cpp b/problems/can-place-flowers.cpp index 4a63f31..31df119 100644 --- a/problems/can-place-flowers.cpp +++ b/problems/can-place-flowers.cpp @@ -4,8 +4,9 @@ using std::vector; class Solution { - public: - bool canPlaceFlowers(vector &flowerbed, int n) { +public: + bool canPlaceFlowers(vector& flowerbed, int n) + { int count = 0; int left = 0, right; @@ -24,20 +25,21 @@ class Solution { } }; -int main() { +int main() +{ Solution s; - std::vector flowers{1, 0, 0, 0, 1}; + std::vector flowers { 1, 0, 0, 0, 1 }; assert(s.canPlaceFlowers(flowers, 1)); assert(!s.canPlaceFlowers(flowers, 2)); - flowers = {1, 0, 0, 0, 0, 1}; + flowers = { 1, 0, 0, 0, 0, 1 }; assert(!s.canPlaceFlowers(flowers, 2)); - flowers = {1, 0, 0, 0, 1, 0, 0}; + flowers = { 1, 0, 0, 0, 1, 0, 0 }; assert(s.canPlaceFlowers(flowers, 2)); - flowers = {0, 0, 1, 0, 0}; + flowers = { 0, 0, 1, 0, 0 }; assert(s.canPlaceFlowers(flowers, 1)); return 0; diff --git a/problems/middle-of-the-linked-list.cpp b/problems/middle-of-the-linked-list.cpp index 847d914..897e7ea 100644 --- a/problems/middle-of-the-linked-list.cpp +++ b/problems/middle-of-the-linked-list.cpp @@ -10,10 +10,11 @@ */ class Solution { public: - ListNode* middleNode(ListNode* head) { + ListNode* middleNode(ListNode* head) + { auto slow = head; auto fast = head ? head->next : nullptr; - + while (fast != nullptr) { slow = slow->next; fast = fast->next; @@ -21,7 +22,7 @@ public: fast = fast->next; } } - + return slow; } };