Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Класс линейной реализации
- */
- class Solution {
- /**
- * Возвращает ключи суммы
- *
- * @param Integer[] $nums
- * @param Integer $target
- * @return Integer[]
- */
- public static function twoSum(array $nums, int $target) {
- $c = count($nums);
- for ($i = 0; $i < $c; $i++) {
- for ($y = $i + 1; $y < $c; $y++) {
- if ($nums[$i] + $nums[$y] == $target) {
- return [$i, $y];
- }
- }
- }
- return [];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment