HTMLify
Day 101
Views: 5 | Author: djdj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class Solution { /** * @param String[] $operations * @return Integer */ function finalValueAfterOperations($operations) { $x = 0; foreach ($operations as $operation) { if ($operation == "--X" || $operation == "X--") { $x--; } elseif ($operation == "++X" || $operation == "X++") { $x++; } } return $x; } } |