Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #459

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

Merged
pull merged 5 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jun 24, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
δΊŒε‰ζ ‘ηš„ι€’ε½’ιεŽ† add php version
  • Loading branch information
alanx15a2 committed May 30, 2024
commit 692f63a77e55a2b1141b4eac78634db306eb4ec9
56 changes: 56 additions & 0 deletions problems/δΊŒε‰ζ ‘ηš„ι€’ε½’ιεŽ†.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,62 @@ public void Traversal(TreeNode cur, IList<int> res)
}
```

### PHP
```php
// 144.ε‰εΊιεŽ†
function preorderTraversal($root) {
$output = [];
$this->traversal($root, $output);
return $output;
}

function traversal($root, array &$output) {
if ($root->val === null) {
return;
}

$output[] = $root->val;
$this->traversal($root->left, $output);
$this->traversal($root->right, $output);
}
```
```php
// 94.δΈ­εΊιεŽ†
function inorderTraversal($root) {
$output = [];
$this->traversal($root, $output);
return $output;
}

function traversal($root, array &$output) {
if ($root->val === null) {
return;
}

$this->traversal($root->left, $output);
$output[] = $root->val;
$this->traversal($root->right, $output);
}
```
```php
// 145.εŽεΊιεŽ†
function postorderTraversal($root) {
$output = [];
$this->traversal($root, $output);
return $output;
}

function traversal($root, array &$output) {
if ($root->val === null) {
return;
}

$this->traversal($root->left, $output);
$this->traversal($root->right, $output);
$output[] = $root->val;
}
```


<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
Expand Down

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /