mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-10 00:09:06 +01:00
chore: format sources
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
b59f949d8f
commit
917aecb33f
2 changed files with 13 additions and 10 deletions
|
@ -4,8 +4,9 @@
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
class Solution {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
bool canPlaceFlowers(vector<int> &flowerbed, int n) {
|
bool canPlaceFlowers(vector<int>& flowerbed, int n)
|
||||||
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
int left = 0, right;
|
int left = 0, right;
|
||||||
|
@ -24,20 +25,21 @@ class Solution {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
Solution s;
|
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, 1));
|
||||||
assert(!s.canPlaceFlowers(flowers, 2));
|
assert(!s.canPlaceFlowers(flowers, 2));
|
||||||
|
|
||||||
flowers = {1, 0, 0, 0, 0, 1};
|
flowers = { 1, 0, 0, 0, 0, 1 };
|
||||||
assert(!s.canPlaceFlowers(flowers, 2));
|
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));
|
assert(s.canPlaceFlowers(flowers, 2));
|
||||||
|
|
||||||
flowers = {0, 0, 1, 0, 0};
|
flowers = { 0, 0, 1, 0, 0 };
|
||||||
assert(s.canPlaceFlowers(flowers, 1));
|
assert(s.canPlaceFlowers(flowers, 1));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
*/
|
*/
|
||||||
class Solution {
|
class Solution {
|
||||||
public:
|
public:
|
||||||
ListNode* middleNode(ListNode* head) {
|
ListNode* middleNode(ListNode* head)
|
||||||
|
{
|
||||||
auto slow = head;
|
auto slow = head;
|
||||||
auto fast = head ? head->next : nullptr;
|
auto fast = head ? head->next : nullptr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue