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 maxProfit($A) { | |
| $maxProfit = 0; | |
| for ($P = 0, $N = count($A); $P < $N; ++$P) { | |
| for ($Q = $P; $Q < $N; ++$Q) { | |
| if ( | |
| $A[$Q] >= $A[$P] && | |
| $A[$Q] - $A[$P] > $maxProfit | |
| ) { |
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
| class User extends CActiveRecord { | |
| public static function model($className=__CLASS__) | |
| { | |
| return parent::model($className); | |
| } | |
| public function relations() | |
| { | |
| return array( |
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
| class User extends Eloquent { | |
| public $rules = array( | |
| 'email' => 'required|email|unique:users', | |
| 'password' => 'between:8,50' | |
| ); | |
| public function posts() | |
| { | |
| return $this->has_many('Post'); | |
| } |
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
| class User extends AppModel { | |
| public $validate = array( | |
| 'email' => array( | |
| 'isUnique' => array( | |
| 'rule' => 'isUnique', | |
| 'message' => 'This email is already used.' | |
| ), | |
| 'email' => array( | |
| 'rule' => 'email', |
NewerOlder