Skip to content

Commit b0e4dd3

Browse files
committed
Add solution 151.
1 parent b7f8ac1 commit b0e4dd3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
3+
/**
4+
* @param String $s
5+
* @return String
6+
*/
7+
function reverseWords($s) {
8+
$words = explode(" ", $s);
9+
$sb = "";
10+
11+
for ($i = count($words)-1; $i>= 0; $i--){
12+
if(strlen(trim($words[$i])) != 0){
13+
$sb .= trim($words[$i]);
14+
$sb .= " ";
15+
}
16+
}
17+
return trim($sb);
18+
}
19+
}

0 commit comments

Comments
 (0)