This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Factory examples |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function evaluateReversePolishNotation($expressionArray) | |
| { | |
| $operators = []; | |
| $stack = new SplStack(); | |
| $answer = null; | |
| foreach ($expressionArray as $v) { | |
| if ($v === '+' || $v === '-' || $v === '*' || $v === '/') { | |
| $operand2 = $stack->pop(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Bunch of algorithms including O analysis from the | |
| * Khan Academy course on algorithms. | |
| * | |
| */ | |
| class Algorithms | |
| { |