Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW14 #1150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

HW14 #1150

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

Check failure on line 1 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Header blocks must be separated by a single blank line
/**
* Definition for a singly-linked list.
* class ListNode {
* public $val = 0;
* public $next = null;
* function __construct($val) { $this->val = $val; }
* }
*/

class Solution

Check failure on line 11 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Each class must be in a namespace of at least one level (a top-level vendor name)
{
/**
* @param ListNode $head
* @return Boolean
*/
function hasCycle($head)

Check failure on line 17 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Visibility must be declared on method &quot;hasCycle&quot;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Увы, но не проходит полный набор тестов:

Screenshot 2024-03-11 at 01 53 30

{
if ($head == null || $head->next == null) {
return false;
}

$slow = $head;
$fast = $head->next;

while ($slow != $fast) {

Check failure on line 26 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Blank line found at start of control structure

if ($fast == null || $fast->next == null) {
return false;
}

$slow = $slow->next;
$fast = $fast->next->next;
}

return true;
}
}


class Solution2

Check failure on line 41 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Each class must be in a file by itself

Check failure on line 41 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Each class must be in a namespace of at least one level (a top-level vendor name)
{

Check failure on line 42 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Opening brace must not be followed by a blank line

/**
* @param String $digits
* @return String[]
*/
function letterCombinations($digits)

Check failure on line 48 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Visibility must be declared on method &quot;letterCombinations&quot;
{
if (empty($digits)) {
return []; // возвращаем пустой массив для пустой строки ввода
}

$digitMap = [
'2' => ['a', 'b', 'c'],
'3' => ['d', 'e', 'f'],
'4' => ['g', 'h', 'i'],
'5' => ['j', 'k', 'l'],
'6' => ['m', 'n', 'o'],
'7' => ['p', 'q', 'r', 's'],
'8' => ['t', 'u', 'v'],
'9' => ['w', 'x', 'y', 'z'],
];

$result = [];
$currentCombination = '';

$this->generateCombinations($digits, 0, $digitMap, $currentCombination, $result);

return $result;
}

function generateCombinations($digits, $index, $digitMap, $currentCombination, &$result)

Check failure on line 73 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Visibility must be declared on method &quot;generateCombinations&quot;
{
if ($index == strlen($digits)) {
$result[] = $currentCombination;
return;
}

$currentDigit = $digits[$index];
$letters = $digitMap[$currentDigit];

foreach ($letters as $letter) {
$this->generateCombinations($digits, $index + 1, $digitMap, $currentCombination . $letter, $result);
}
}
}

Check failure on line 87 in index.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 newline at end of file; 0 found
Loading