function isBalanced($str){ $count = 0; $ocount = 0; $ccount = 0; $length = strlen($str); for($i = 0; $i < $length; $i++){ if($str[$i] == '(') $ocount += 1; else if($str[$i] == ')') $ccount += 1; if($ccount == $ocount){ $count = $ocount; }else{ $count = $ccount; } } return $count; } echo isBalanced("))");
its a site that provide source code of php,javascript,mysql,ajex,css,html for different kind of tasks. it help user to solved their problem related to programing and also provide solutions of joomla , wordpress,cubrcart,drupal problems.
Monday, 20 November 2017
codility brackets opening and closing solution
codility you are given a string s consisting of n brackets opening problem solution.
Labels:
brackets,
closing,
codility,
kapil,
kapil sharma,
opening,
php,
programming,
urfusion
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment