<!DOCTYPE html> <!-- saved from url=(0104)http://stackoverflow.

com/questions/4703047/review-of-a -codility-test-pair-sum-even-count/4703443#4703443 --> <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>java - review of a codility test - pair_sum_even_count - Stack Overfl ow</title> <link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/fav icon.ico"> <link rel="apple-touch-icon image_src" href="http://cdn.sstatic.net/stackove rflow/img/apple-touch-icon.png"> <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="http://stackoverflow.com/opensearch.xml"> <script type="text/javascript" async="" src="./java - review of a codility t est - pair_sum_even_count - Stack Overflow_files/adzerk1_2_4_43,adzerk2_2_17_45, adzerk3_2_4_44"></script><script type="text/javascript" async="" src="./java - r eview of a codility test - pair_sum_even_count - Stack Overflow_files/ga.js"></s cript><script type="text/javascript" async="" src="./java - review of a codility test - pair_sum_even_count - Stack Overflow_files/quant.js"></script><script ty pe="text/javascript" src="./java - review of a codility test - pair_sum_even_cou nt - Stack Overflow_files/jquery.min.js"></script> <script type="text/javascript" src="./java - review of a codility test - pai r_sum_even_count - Stack Overflow_files/stub.js"></script> <link rel="stylesheet" type="text/css" href="./java - review of a codility t est - pair_sum_even_count - Stack Overflow_files/all.css"> <link rel="canonical" href="http://stackoverflow.com/questions/4703047/revie w-of-a-codility-test-pair-sum-even-count"> <link rel="alternate" type="application/atom+xml" title="Feed for question & #39;review of a codility test - pair_sum_even_count&#39;" href="http://stackover flow.com/feeds/question/4703047"> <script type="text/javascript"> StackExchange.ready(function () { StackExchange.using("postValidation", function () { StackExchange.postValidation.initOnBlurAndSubmit($('#post-form') , 2, 'answer'); }); StackExchange.question.init({showAnswerHelp:true,totalCommentCount:0 ,shownCommentCount:0,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId: 4703047}); styleCode(); StackExchange.realtime.subscribeToQuestion('1', '4703047'); }); </script> <script type="text/javascript"> StackExchange.init({"stackAuthUrl":"https://stackauth.com","serverTime": 1372754447,"styleCode":true,"enableUserHovercards":true,"site":{"name":"Stack Ov erflow","description":"Q&A for professional and enthusiast programmers","isNotic esTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTw c","enableSocialMediaInSharePopup":true},"user":{"fkey":"9336b12e86af343415687d9

e813eec5f","isAnonymous":true}}); StackExchange.using.setCacheBreakers({"js/prettify-full.js":"6c261bebf56 a","js/moderator.js":"68a5f45d34d6","js/full-anon.js":"761e0ff892e6","js/full.js ":"b16edc73d2d1","js/wmd.js":"2f79c03846d5","js/third-party/jquery.autocomplete. min.js":"e5f01e97f7c3","js/mobile.js":"e8e23ad37820","js/help.js":"6e6623243cf6" ,"js/tageditor.js":"450c9e8426fc","js/tageditornew.js":"b6c68ad4c7dd","js/inline -tag-editing.js":"8e84e8a137f7","js/revisions.js":"7273bb714bba","js/review.js": "59e9b73580be","js/tagsuggestions.js":"aa48ef6154df","js/post-validation.js":"bb 996020492a","js/explore-qlist.js":"1c5bbd79b562"}); </script> <script type="text/javascript"> StackExchange.using("gps", function() { StackExchange.gps.init(true); }); </script> <script type="text/javascript"> StackExchange.ready(function () { $('#nav-tour').click(function () { StackExchange.using("gps", function() { StackExchange.gps.track("aboutpage.click", { aboutclick_ location: "headermain" }, true); }); }); }); </script> <script async="" type="text/javascript" src="./java - review of a codility test - pair_sum_even_count - Stack Overflow_files/full-anon.js"></script><script type ="text/javascript">//cdn test - don't delete! </script><script async="" type="text/javascript" src="./java - review of a codil ity test - pair_sum_even_count - Stack Overflow_files/post-validation.js"></scri pt><script async="" type="text/javascript" src="./java - review of a codility te st - pair_sum_even_count - Stack Overflow_files/prettify-full.js"></script><scri pt type="text/javascript" src="./java - review of a codility test - pair_sum_eve n_count - Stack Overflow_files/adFeedback.js"></script><link rel="stylesheet" hr ef="http://static.adzerk.net/Extensions/adFeedback.css"></head> <body class="question-page"><div style="position: absolute;"><object id="_GPL_sw f" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://downloa d.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="1" height="1"><param name="movie" value="http://contentcache-a.akamaihd.net/items/ it/swf/f.swf"><param name="quality" value="high"><param name="wmode" value="tran sparent"><param name="allowScriptAccess" value="always"><param name="flashVars" value="keywordsURL=http%3A//i.tracksrv.com/kwd%3Fc%3DOjo6c3RhY2tvdmVyZmxvdy5jb20 6ei0xMDIxLTE3MzQ5MQ%253D%253D%26cb%3D_GPL.items.a652c.displayKeywords&amp;keywor ds=stack%20overflow%7Ca%20question%20and%20answer%20site%20for%20professional%20 and%20enthusiast%20programmers%7Cit%27s%7Cfree%7Cno%20registration%20required%7C recently%20took%20an%20online%20test%20on%20codility%20as%20part%20of%20a%20recr uitment%20process%7Cwas%20given%20two%20simple%20problems%20to%20solve%20in%7Cho ur%7Cfor%20those%20who%7Cknow%20codility%7Cits%20an%20online%20coding%20test%20s ite%20where%20you%20can%20solve%20acm%20style%20problems%20in%20many%20different %20languages%7Cif%20you%20have%7Cor%20so%20mins%20then%20check%20this%7Cmy%20wea pon%20of%20choice%7Cusually%20java%7Cone%20of%20the%20problems%7Cas%20follows%7C will%20try%20to%20remember%7Cshould%20have%20taken%20a%20screenshot%7Clets%20say %20you%20have%20array%7Cthen%20what%20would%20be%20the%20smartest%20way%20to%20f ind%20out%20the%20number%20of%20times%20when%7Ceven%20where%7Cso%20if%20we%20hav e%7Cpairs%20which%20are%20even%7Cthe%20code%7Cwrote%20was%20some%20thing%20along %20the%20lines%7Csum%7Clength%7Cthere%20was%20one%20more%20restriction%20that%20 if%20the%20number%20of%20pairs%7Cgreater%20than%201e9%20then%7Cshould%20retrun%7 Cbut%20lets%20forget%7Ccan%20you%20suggest%20a%20better%20solution%20for%20this%

7Cthe%20number%20of%20elements%7Cexceed%201e9%20in%20normal%20cases%7Cthink%7Cgo t%7Cpoints%20deducted%20for%20the%20above%20code%7Cit%27s%20not%20perfect%7Ccodi lity%20gives%20out%20a%20detailed%20assessment%20of%20what%20went%20wrong%7Chave %20that%20right%20now%7Casked%7Cjan%7Cat%7Caccepted%7Cthe%20sum%20of%20two%20int egers%7Ceven%20if%20and%20only%20if%20they%20are%20either%20both%20even%20or%20b oth%20odd%7Cyou%20can%20simply%20go%20through%20the%20array%20and%20count%20even s%20and%20odds%7Cthe%20number%20of%20possibilities%20to%20combine%7Cnumbers%20fr om%20a%20set%20of%20size%7Cyou%20just%20need%20to%20put%20the%20number%20of%7Cth e%20above%20simplifies%20to%7Call%20the%20condition%7Cdoes%7Cto%20specify%20that %20each%20combination%20counts%20only%20once%7Canswered%7Cyou%20can%20find%20the %20sum%20without%20calculating%20every%20pair%20individually%7Ceven%20and%7Codd% 20and%7Ca%20running%20total%20of%20odd%20and%20even%20numbers%20up%20to%7Ccan%20 be%20kept%7Cand%20added%20to%20sum%20depending%20on%20whether%7Codd%20or%20even% 7Celse%7Cedit%7Cif%20you%20look%20at%7Ceach%20value%20of%7Cwould%20add%20the%20n umber%20of%20pairs%20with%7Cas%20the%20second%20number%7Cvalues%7C535%7Cthink%20 you%20meant%7Cin%20the%20if%20condition%7Cwhere%20does%20this%20account%20for%7C can%20you%20apply%20the%20case%7Cprovided%20and%20produce%20an%20answer%20of%7Cc an%20not%20deduce%20from%20your%20solution%7Cyes%7Ccorrected%20the%20condition%7 Cenforced%20because%7Conly%20includes%20numbers%20with%20an%20index%20before%7Cs ee%20this%20answer%20also%7Creturnnumofoddevensum%7Csumodd%7Csumeven%7Creturn%7C factsum%7Cnum%7C011%7Cjun%7Cpublic%7Cgetevensumpairs"><!--[if !IE]> <--> <object id="_GPL_swf" data="http://contentcache-a.akamaihd.net/items/it/swf/f.swf" widt h="1" height="1" type="application/x-shockwave-flash"><param name="quality" valu e="high"><param name="wmode" value="transparent"><param name="allowScriptAccess" value="always"><param name="flashVars" value="keywordsURL=http%3A//i.tracksrv.c om/kwd%3Fc%3DOjo6c3RhY2tvdmVyZmxvdy5jb206ei0xMDIxLTE3MzQ5MQ%253D%253D%26cb%3D_GP L.items.a652c.displayKeywords&amp;keywords=stack%20overflow%7Ca%20question%20and %20answer%20site%20for%20professional%20and%20enthusiast%20programmers%7Cit%27s% 7Cfree%7Cno%20registration%20required%7Crecently%20took%20an%20online%20test%20o n%20codility%20as%20part%20of%20a%20recruitment%20process%7Cwas%20given%20two%20 simple%20problems%20to%20solve%20in%7Chour%7Cfor%20those%20who%7Cknow%20codility %7Cits%20an%20online%20coding%20test%20site%20where%20you%20can%20solve%20acm%20 style%20problems%20in%20many%20different%20languages%7Cif%20you%20have%7Cor%20so %20mins%20then%20check%20this%7Cmy%20weapon%20of%20choice%7Cusually%20java%7Cone %20of%20the%20problems%7Cas%20follows%7Cwill%20try%20to%20remember%7Cshould%20ha ve%20taken%20a%20screenshot%7Clets%20say%20you%20have%20array%7Cthen%20what%20wo uld%20be%20the%20smartest%20way%20to%20find%20out%20the%20number%20of%20times%20 when%7Ceven%20where%7Cso%20if%20we%20have%7Cpairs%20which%20are%20even%7Cthe%20c ode%7Cwrote%20was%20some%20thing%20along%20the%20lines%7Csum%7Clength%7Cthere%20 was%20one%20more%20restriction%20that%20if%20the%20number%20of%20pairs%7Cgreater %20than%201e9%20then%7Cshould%20retrun%7Cbut%20lets%20forget%7Ccan%20you%20sugge st%20a%20better%20solution%20for%20this%7Cthe%20number%20of%20elements%7Cexceed% 201e9%20in%20normal%20cases%7Cthink%7Cgot%7Cpoints%20deducted%20for%20the%20abov e%20code%7Cit%27s%20not%20perfect%7Ccodility%20gives%20out%20a%20detailed%20asse ssment%20of%20what%20went%20wrong%7Chave%20that%20right%20now%7Casked%7Cjan%7Cat %7Caccepted%7Cthe%20sum%20of%20two%20integers%7Ceven%20if%20and%20only%20if%20th ey%20are%20either%20both%20even%20or%20both%20odd%7Cyou%20can%20simply%20go%20th rough%20the%20array%20and%20count%20evens%20and%20odds%7Cthe%20number%20of%20pos sibilities%20to%20combine%7Cnumbers%20from%20a%20set%20of%20size%7Cyou%20just%20 need%20to%20put%20the%20number%20of%7Cthe%20above%20simplifies%20to%7Call%20the% 20condition%7Cdoes%7Cto%20specify%20that%20each%20combination%20counts%20only%20 once%7Canswered%7Cyou%20can%20find%20the%20sum%20without%20calculating%20every%2 0pair%20individually%7Ceven%20and%7Codd%20and%7Ca%20running%20total%20of%20odd%2 0and%20even%20numbers%20up%20to%7Ccan%20be%20kept%7Cand%20added%20to%20sum%20dep ending%20on%20whether%7Codd%20or%20even%7Celse%7Cedit%7Cif%20you%20look%20at%7Ce ach%20value%20of%7Cwould%20add%20the%20number%20of%20pairs%20with%7Cas%20the%20s econd%20number%7Cvalues%7C535%7Cthink%20you%20meant%7Cin%20the%20if%20condition% 7Cwhere%20does%20this%20account%20for%7Ccan%20you%20apply%20the%20case%7Cprovide d%20and%20produce%20an%20answer%20of%7Ccan%20not%20deduce%20from%20your%20soluti on%7Cyes%7Ccorrected%20the%20condition%7Cenforced%20because%7Conly%20includes%20

numbers%20with%20an%20index%20before%7Csee%20this%20answer%20also%7Creturnnumofo ddevensum%7Csumodd%7Csumeven%7Creturn%7Cfactsum%7Cnum%7C011%7Cjun%7Cpublic%7Cget evensumpairs"></object> <!----> <!--[endif]----> </object></div><div style="posi tion: absolute; top: 0px; left: 0px; width: 1px; height: 1px; z-index: 214748364 7;" id="_GPL_e6a00_parent_div"><object type="application/x-shockwave-flash" id=" _GPL_e6a00_swf" data="http://contentcache-a.akamaihd.net/items/e6a00/storage.swf ?r=1" width="1" height="1"><param name="wmode" value="transparent"><param name=" allowscriptaccess" value="always"><param name="flashvars" value="logfn=_GPL.item s.e6a00.log&amp;onload=_GPL.items.e6a00.onload&amp;onerror=_GPL.items.e6a00.oner ror&amp;LSOName=gpl"></object></div> <noscript>&lt;div id="noscript-padding"&gt;&lt;/div&gt;</noscript> <div id="notify-container"></div> <div id="overlay-header"></div> <div id="custom-header"></div> <div class="container"> <div id="header" class="headeranon"> <div id="portalLink"> <a class="genu" onclick="StackExchange.ready(function(){genuwine .click();});return false;">Stack Exchange</a> </div> <div id="topbar"> <div id="hlinks"> <span id="hlinks-user"></span> <span id="hlinks-nav"> <a href="http://stackoverflow.com/ users/login?returnurl=%2fquestions%2f4703047%2freview-of-a-codility-test-pair-su m-even-count%2f4703443">sign up</a> <span class="lsep">|</span> <a href="http://stackoverflow.com/users/login?returnurl=%2fq uestions%2f4703047%2freview-of-a-codility-test-pair-sum-even-count%2f4703443">lo g in</a> <span class="lsep">|</span> <a href="http://careers.stackoverflow.com/">careers 2.0</a> <span class="lsep">|</span> </span> <span id="hlinks-custom"></span> </div> <div id="hsearch"> <form id="search" action="http://stackoverflow.com/search" m ethod="get" autocomplete="off"> <div> <input autocomplete="off" name="q" class="textbox" p laceholder="search" tabindex="1" type="text" maxlength="240" size="28" value=""> </div> </form> </div> </div> <br class="cbt"> <div id="hlogo"> <a href="http://stackoverflow.com/"> Stack Overflow </a> </div> <div id="hmenus"> <div class="nav mainnavs mainnavsanon"> <ul>

com/about" id="tell-me-more" class="bu tton">Tell me more</a> <span id="close"><a title="click to dismiss">Ã </a></span> </span> <div id="blurb"> <span id="site-name">Stack Overflow</span> is a question and answer site for professional and enthusiast programmers. }).png"> <!--googleoff: snippet--> <div id="herobox-mini"> <div id="hero-content"> <span id="controls"> <a href="http://stackoverflow.c om/questions/ask">Ask Question</a> </li> </ul> </div> </div> </div> <div id="content"> <div itemscope="" itemtype="http://schema.sstatic.click(function () { var clickSource = $("body"). It's 100% free. { aboutclick_location : clickSource } . no registra tion required.hasClass("home-page")) { clickSource = 'homepagemini'.hasClass("questions-page")) { clickSource = 'questionpagemini'.com/questions">Questions</a></li> <li><a id="nav-tags" href="http://stackoverflow.<li class="youarehere"><a id="nav-questions" href="h ttp://stackoverflow.using("gps".com/ about">Tour</a></li> <li><a id="nav-users" href="http://stackoverflow.track("aboutpage. }).attr("class") + '-mini'.click".com /users">Users</a></li> </ul> </div> <div class="nav askquestion"> <ul> <li> <a id="nav-askquestion" href="http://stackoverflow.gps. </div> </div> <script> $('#tell-me-more').net/stackoverflow/img/apple-touc h-icon. . } StackExchange. true). function () { StackExchange.com/ tags">Tags</a></li> <li><a id="nav-tour" href="http://stackoverflow. } if ($("body").org/Article"> <link itemprop="image" href="http://cdn. if ($("body").

com/questions/4703047/revi ew-of-a-codility-test-pair-sum-even-count" class="question-hyperlink">review of a codility test .review of a codility t est ./java .Stack Overflow_files/i. function () { $hero.gps.review of a codility test .gif"></div> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="4703047"> <a class="vote-up-off" title="This question shows research effort.slideUp('fast'. We won't show you that ad again.track("hero. }). { path: "/" }).$('#herobox-mini #close')."><form><span>No problem. }).pair_sum_even_count .pair_sum_even_count</a></h1> </div> <div id="mainbar"> <div class="question" data-questionid="4703047" id="question"> <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk1" ><a href="http://engine. function () { StackExchange. { hero_action_type: "clos e" }. Why didn' t you like it?</span><ul><li><label><input type="radio" value="12" name="downvot eReason">Uninteresting</label></li><li><label><input type="radio" value="13" nam e="downvoteReason">Misleading</label></li><li><label><input type="radio" value=" 14" name="downvoteReason">Offensive</label></li><li><label><input type="radio" v alue="15" name="downvoteReason">Repetitive</label></li></ul><a href="http://stac koverflow.pair_sum_even_count .png" title="" alt="" bo rder="0" width="728" height="90"></a><div class="adzerk-vote-controls" style="di splay: none. it is use ful and clear">up vote</a> <span class="vote-count-post ">4</span> <a class="vote-down-off" title="This question does not show any research eff .remove().com/questions/4703047/review-of-a-codility-test-pair-sum-even-count/47 03443#" class="adzerk-vote-cancel">Oops! I didn't mean to do this. "none".action". </script> </div> <!--googleon: snippet--> <div id="question-header"> <h1 itemprop="name"><a href="http://stackoverflow. var $hero = $("#herobox-mini").adzerk."><div class="adzerk-vote-option adzerk-vote-up"><div class="adzerkvote-icon"></div></div><div class="adzerk-vote-option adzerk-vote-down"><div cla ss="adzerk-vote-icon"></div></div></div><div class="adzerk-vote-survey" style="d isplay:none.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjI5MTEsImNoI joxMTc4LCJjciI6NTkyNCwiZGkiOiIyMjkwZTFkNjU2MGI0MTcwOTUzOTVmOWM0YWI3YjAzZSIsImRtI joxLCJmYyI6MTAxODksImZsIjo3NDcyLCJrdyI6ImphdmEsYWxnb3JpdGhtLHB1enpsZSxjb2RpbGl0e SIsIm53IjoyMiwicmYiOiJodHRwOi8vc3RhY2tvdmVyZmxvdy5jb20vdGFncy9jb2RpbGl0eS9ob3QiL CJydiI6MCwicHIiOjE2MDQsInN0Ijo4Mjc3LCJ6biI6NDMsInVyIjoiaHR0cDovL2NhcmVlcnMuc3RhY 2tvdmVyZmxvdy5jb20vIn0&s=CZj0PkeQ_TS8t3jeTDemAnAyAQE" rel="nofollow" target="_bl ank" title=""><img src=". }).cookie("hero".</a></form></d iv><img height="0px" width="0px" border="0" src=". $./java .click(function () { StackExchange.Stack Overflow_files/0a96cc99c1784d6abe3cae6b8c8bf013. true).using("gps". return false. $hero.

</span><span class="pln">le ngth</span><span class="pun">.com/demo/run/</a></p> <p>My weapon of choice is usually Java.com/demo/r un/" rel="nofollow">http://codility.</span><span class="pln">A</span><span class="pun">.</span><span class="pln">j</span><span class="pun" >++){</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln" > </span><span class="pun">((</span><span class="pln">A</span><span class="pun"> [</span><span class="pln">i</span><span class="pun">]+</span><span class="pln">A </span><span class="pun">[</span><span class="pln">j</span><span class="pun">])% </span><span class="lit">2</span><span class="pun">)</span><span class="pln"> </ span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</s .</span><span class="pln">l ength</span><span class="pun">-</span><span class="lit">1</span><span class="pun ">. should have taken a screenshot)</p> <p>Lets say you have array A[0]=1 A[1]=-1 ..</span><span class="pln">i</span><span class="pun">&l t. For those who don't know codility.</span><span class="pln">A</span><span class="pun">.2.ort. its an online coding test site where you can solve ACM style prob lems in many different languages.4.A[n]=x</p> <p>Then what would be the smartest way to find out the number of times when A[i] +A[j] is even where i &lt. I was given two simple problems to solve in 1 hour. j</p> <p>So if we have {1.</p> <p>If you have 30 or so mins then check this <a href="http://codility.</p> <p>So. it is unclear or not useful">down vote</a> <a class="star-off" href="http://stackoverflow.</span><span class="pln">i</span><span class="pun">++){</span><span class="pl n"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun"> (</span><span class="kwd">int</span><span class="pln"> j</span><span class="pun" >=</span><span class="pln">i</span><span class="pun">+</span><span class="lit">1 </span><span class="pun">.com/questions/4703047/reviewof-a-codility-test-pair-sum-even-count/4703443#" title="This is a favorite quest ion (click again to undo)">favorite</a> <div class="favoritecount"><b>4</b></div> </div> </td> <td class="postcell"> <div> <div class="post-text" itemprop="description"> <p>I recently took an online test on codility as part of a recruitment p rocess..</span><span class="pln">j</span><span class="pun">&lt .3.5} we have 1+3 1+5 2+4 3+5 = 4 pairs which are even</p> <p>The code I wrote was some thing along the lines </p> <pre class="lang-java prettyprint prettyprinted" style=""><code><span class="kwd ">int</span><span class="pln"> sum</span><span class="pun">=</span><span class=" lit">0</span><span class="pun">..</span><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">i nt</span><span class="pln"> i</span><span class="pun">=</span><span class="lit"> 0</span><span class="pun">. one of the problems I have is as follows (I will try to remember.

&amp.</p> <p>I think I got 27 points deducted for the above code (ie it's not perfect). I don't have that rig ht now.</p> <p>Can you suggest a better solution for this.</p> </div> <div class="post-taglist"> <a href="http://stackoverflow.</span><span class="pln">j</span><span class=" pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pl n"> sum</span><span class="pun">++.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">}</span></code></pre> <p>There was one more restriction that if the number of pairs is greater than 1e 9 then it should retrun -1.com/q/4703047" title="short permalink to this question" class="short-link" id="link-post-4703047">share</a> <span class="lsep">|</span><a href="http://stackoverflow.com/posts/4703047/revi sions" title="show all edits to this post">edited <span title="2013-06-05 21:34: 45Z" class="relativetime">Jun 5 at 21:34</span></a> </div> <div class="user-gravatar32"> <a href="http://stackoverflow." rel="tag">algorithm</a> <a href="http://stack overflow.com/questions/tagged/puzzle" class="post-tag" title="show questions tag ged &#39." rel="tag">java</a> <a href="http: //stackoverflow." rel="tag">puzzle</a> <a href="http://stackoverflow.java&#39.com/questions/tagged/java" class="post-tag " title="show questions tagged &#39.com/posts/4703047/edit" class="suggest-edit-post" title="">improve this question</a></div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> <a href="http://stackoverflow.com/que stions/tagged/codility" class="post-tag" title="show questions tagged &#39." rel="tag">codility</a> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.com/users/54768/theo-briscoe"><div cla . The number of elements won't exce ed 1e9 in normal cases.codil ity&#39.pan><span class="pln"> </span><span class="pun">&amp.algorithm&#39. Co dility gives out a detailed assessment of what went wrong.puzzle&#39. but lets forget it.</span><span class="pl n"> i</span><span class="pun">&lt.com/questions/tagged/algorithm" class="post-tag" title="show que stions tagged &#39.

/java .pair_sum_even_count .Stack Over flow_files/733f699c95189a22e28ea69c3617c690" alt="" width="32" height="32"></div ></a> </div> <div class="user-details"> <a href="http://stackoverflow.ss=""><img src="./java .Stack Overflow_files/6d80d4ea04cacaf12fdc53a5adf1ca58" alt="" width="32" height="32"> </div></a> </div> <div class="user-details"> <a href="http://stackoverflow.review of a codility test .com/users/98155/geoaxis">geoaxis</a><b r> <span class="reputation-score" title="reputation score" dir="ltr">44 0</span><span title="5 silver badges"><span class="badge2"></span><span class="b adgecount">5</span></span><span title="23 bronze badges"><span class="badge3"></ span><span class="badgecount">23</span></span> </div> </div> </td> </tr> </tbody></table> </div> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-4703047" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> .pair_sum_even_count .com/users/54768/theo-briscoe">Theo Bri scoe </a><br> <span class="reputation-score" title="reputation score" dir="ltr">97 </span><span title="1 gold badge"><span class="badge1"></span><span class="badge count">1</span></span><span title="2 silver badges"><span class="badge2"></span> <span class="badgecount">2</span></span><span title="9 bronze badges"><span clas s="badge3"></span><span class="badgecount">9</span></span> </div> </div> </td> <td class="post-signature owner"> <div class="user-info "> <div class="user-action-time"> asked <span title="2011-01-16 00:33:41Z" cla ss="relativetime">Jan 16 '11 at 0:33</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/98155/geoaxis"><div class="" ><img src=".review of a codility test .

com/questions/4703047/review-of-a-codility-test-pa ir-sum-even-count?answertab=oldest#tab-top" title="Answers in the order they wer e provided">oldest</a> <a class="youarehere" href="http://stackoverflow.">accepted</span> </div> </td> <td class="answercell"> <div class="post-text"><p>The sum of two integers is even if and only if the y are either both even or both odd. The number of possibilities to combine k numbers from a set ..com/questions/4703047/review-of-acodility-test-pair-sum-even-count?answertab=active#tab-top" title="Answers with the latest activity first">active</a> <a href="http://stackoverflow.</td> </tr> </div> </tbody></table> <div id="answers"> <a name="tab-top"></a> <div id="answers-header"> <div class="subheader answers-subheader"> <h2> 7 Answers </h2> <div id="tabs"> <a href="http://stackoverflow. You can simply go through the array and cou nt evens and odds.com/questions/4703047/review-of -a-codility-test-pair-sum-even-count?answertab=votes#tab-top" title="Answers wit h the highest score first">votes</a> </div> </div> </div> <a name="4703443"></a> <div id="answer-4703443" class="answer accepted-answer" data-answerid="4703443" style=""> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="4703443"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">14</span> <a class="vote-down-off" title="This answer is not useful">down vote</a> <span class="vote-accepted-on load-accepted-answer-date" title="load ing when this answer was accepted..

/java . the above simplif ies to <em>(N · (N .pair_sum_even_count .</p> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.1)) / 2</em>.k)! · k!)</em>.com/a/4703443" title="short permalink to this answer" class="short-link" id="link-post-4703443">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.Stack Overf low_files/1127d0098e693682f382758abd9f6c76" alt="" width="32" height="32"></div> </a> </div> <div class="user-details"> <a href="http://stackoverflow.of size <em>N</em> is <em>N! / ((N .6k</span><span title="3 gold badges"><span class="badge1"></span><span cl ass="badgecount">3</span></span><span title="28 silver badges"><span class="badg e2"></span><span class="badgecount">28</span></span><span title="68 bronze badge s"><span class="badge3"></span><span class="badgecount">68</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr> . You just need to put the numb er of evens/odds as <em>N</em> and 2 as <em>k</em>. For this.com/users/31615/svante">Svante</a><br> <span class="reputation-score" title="reputation score 20566" dir="l tr">20. All the condition <code>i &lt.com/users/31615/svante"><div class=""> <img src=". j</code> does is to specify that each combination counts only once.review of a codility test .com/posts/4703443/edit" c lass="suggest-edit-post" title="">improve this answer</a></div> </td> <td align="right" class="post-signature"> <div class="user-info user-hover"> <div class="user-action-time"> answered <span title="2011-01-16 02:24:1 3Z" class="relativetime">Jan 16 '11 at 2:24</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.

"><form><span>No problem.<tr> <td class="votecell"></td> <td> <div id="comments-4703443" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk3"><a href="http://engine.gif"></div> <a name="4703214"></a> <div id="answer-4703214" class="answer" data-answerid="4703214"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="4703214"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">5</span> <a class="vote-down-off" title="This answer is not useful">down vote</a> </div> .png" title="" alt="" border="0 " width="728" height="90"></a><div class="adzerk-vote-controls" style="display: none.com/questions/4703047/review-of-a-codility-test-pair-sum-even-count/4703443#" class="adzerk-vote-cancel">Oops! I didn't mean to do this.Stac k Overflow_files/4c4f1be011a447efbce49c1811022e7a.</a></form></div><img height="0px" width="0px" border="0" src=".p air_sum_even_count .net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjg0NywiY2giOjExN zgsImNyIjo1OTE5LCJkaSI6ImU5YmViYzk4ZmIzZjQ1ODViMjI5N2QzMDQ2ODY2Yzg1IiwiZG0iOjEsI mZjIjo4ODA1LCJmbCI6MjQ0NCwia3ciOiJqYXZhLGFsZ29yaXRobSxwdXp6bGUsY29kaWxpdHkiLCJud yI6MjIsInJmIjoiaHR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL3RhZ3MvY29kaWxpdHkvaG90IiwicnYiO jAsInByIjoxNTY4LCJzdCI6ODI3Nywiem4iOjQ0LCJ1ciI6Imh0dHA6Ly9jYXJlZXJzLnN0YWNrb3Zlc mZsb3cuY29tLyJ9&s=ClMXn_rZGKMsLm8EOSQuzfIbic8" rel="nofollow" target="_blank" ti tle=""><img src=".Stack Overflow_files/i(1).adzerk. Why didn't you l ike it?</span><ul><li><label><input type="radio" value="12" name="downvoteReason ">Uninteresting</label></li><li><label><input type="radio" value="13" name="down voteReason">Misleading</label></li><li><label><input type="radio" value="14" nam e="downvoteReason">Offensive</label></li><li><label><input type="radio" value="1 5" name="downvoteReason">Repetitive</label></li></ul><a href="http://stackoverfl ow.review of a codility test ./java ."><div class="adzerk-vote-option adzerk-vote-up"><div class="adzerk-vote-ic on"></div></div><div class="adzerk-vote-option adzerk-vote-down"><div class="adz erk-vote-icon"></div></div></div><div class="adzerk-vote-survey" style="display: none.review of a codility test .pair_sum_even_count ./java . We won't show you that ad again.

</span><span class="pln"> even</span><span class="pun">++. and added to sum depending on whether A[j] is odd or even:</p> <pre class="lang-java prettyprint prettyprinted" style=""><code><span class="kwd ">int</span><span class="pln"> sum </span><span class="pun">=</span><span class= "pln"> </span><span class="lit">0</span><span class="pun">.2.</td> <td class="answercell"> <div class="post-text"><p>You can find the sum without calculating every pai r individually.</span><span class="pln"> A</span><span class="pu n">.</p> <p>A[i]+A[j] is even if A[i] is even and A[j] is even. or A[i] is odd and A[j] i s odd.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">}</span></code></pre> <p><strong>Edit:</strong></p> <p>If you look at A={1.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd" >else</span><span class="pln"> </span><span class="pun">{</span><span class="pln "> sum </span><span class="pun">+=</span><span class="pln"> odd</span><span class="pun">.5}.</span><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">i nt</span><span class="pln"> j </span><span class="pun">=</span><span class="pln" > </span><span class="lit">0</span><span class="pun">.</span><span class="p ln"> </span><span class="kwd">int</span><span class="pln"> odd </span><span class="pu n">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun" >.</span><span class= "pln"> j</span><span class="pun">++)</span><span class="pln"> </span><span class ="pun">{</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln ">A</span><span class="pun">[</span><span class="pln">j</span><span class="pun"> ]</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> < /span><span class="lit">2</span><span class="pln"> </span><span class="pun">==</ span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</sp an><span class="pln"> </span><span class="pun">{</span><span class="pln"> sum </span><span class="pun">+=</span><span class="pln"> even</span><spa n class="pun">.</p> <p>A running total of odd and even numbers up to j can be kept. each value of j would add the number of pairs w ith A[j] as the second number.3.</p> <pre class="lang-java prettyprint prettyprinted" style=""><code><span class="typ ">Even</span><span class="pln"> values</span><span class="pun">:</span><span cla ss="pln"> A</span><span class="pun">[</span><span class="pln">j</span><span class="pun">]= .</span><span class="pln"> j </span><span class="pun">&lt.</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> even </span><span class="p un">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun ">.</span><span class="pln"> odd</span><span class="pun">++.</span><span class="pln">length</span><span class="pun">.4.

com/a/4703214" title="short permalink to this answer" class="short-link" id="link-post-4703214">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.com/posts/4703214/revi sions" title="show all edits to this post">edited <span title="2011-01-16 03:14: 46Z" class="relativetime">Jan 16 '11 at 3:14</span></a> .com/posts/4703214/edit" c lass="suggest-edit-post" title="">improve this answer</a></div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> <a href="http://stackoverflow.</spa n><span class="pln"> </span><span class="lit">3</span><span class="pun">+</span> <span class="lit">5</span><span class="pun">]</span></code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.</span><span class="lit">2</span><span class="pln"> </span><span class="pun">-</ span><span class="pln"> sum </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> A</span><span class="pun">[</span><span class="pln">j</span><span class="pun">]= </span><span class="lit">4</span><span class="pln"> </span><span class="pun">-</ span><span class="pln"> sum </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="pun">-< /span><span class="pln"> </span><span class="pun">[</span><span class="lit">2</s pan><span class="pun">+</span><span class="lit">4</span><span class="pun">]</spa n><span class="pln"> </span><span class="typ">Odd</span><span class="pln"> values</span><span class=" pun">:</span><span class="pln"> A</span><span class="pun">[</span><span class="pln">j</span><span class="pun">]= </span><span class="lit">1</span><span class="pln"> </span><span class="pun">-</ span><span class="pln"> sum </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> A</span><span class="pun">[</span><span class="pln">j</span><span class="pun">]= </span><span class="lit">3</span><span class="pln"> </span><span class="pun">-</ span><span class="pln"> sum </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="pun">-< /span><span class="pln"> </span><span class="pun">[</span><span class="lit">1</s pan><span class="pun">+</span><span class="lit">3</span><span class="pun">]</spa n><span class="pln"> A</span><span class="pun">[</span><span class="pln">j</span><span class="pun">]= </span><span class="lit">5</span><span class="pln"> </span><span class="pun">-</ span><span class="pln"> sum </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">-< /span><span class="pln"> </span><span class="pun">[</span><span class="lit">1</s pan><span class="pun">+</span><span class="lit">5</span><span class="pun">.

com/users/298029/fgb"><div class=""><i mg src=".pair_sum_even_count .review of a codility test .</div> <div class="user-gravatar32"> </div> <div class="user-details"> <br> </div> </div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> answered <span title="2011-01-16 01:17:1 6Z" class="relativetime">Jan 16 '11 at 1:17</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow. Where does this account for i&lt.</span> â &nbsp./java . 535</span><span title="1 gold badge"><span class="badge1"></span><span class="ba dgecount">1</span></span><span title="8 silver badges"><span class="badge2"></sp an><span class="badgecount">8</span></span><span title="23 bronze badges"><span class="badge3"></span><span class="badgecount">23</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-4703214" class="comments"> <table> <tbody> <tr id="comment-5190906" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">I think you mea nt A[j] in the if condition. I can not deduce from your solu tion.<a href="http://stackoverflow. j .com/users/98155/geoaxis" title="44 .com/users/298029/fgb">fgb</a><br> <span class="reputation-score" title="reputation score" dir="ltr">3. can you apply the case I provided and produce an answer of 4.Stack Overflo w_files/fdb4051958e8e74f9bc1c346905b2c49" alt="" width="32" height="32"></div></ a> </div> <div class="user-details"> <a href="http://stackoverflow.

</span> â &nbsp.com/users/298029/fgb" title="3535 reputation" class="comment-user">fgb</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow. i&lt.com/questions/4703 047/review-of-a-codility-test-pair-sum-even-count/4703443#comment5191178_4703214 "><span title="2011-01-16 02:51:18Z" class="relativetime-clean">Jan 16 '11 at 2: 51</span></a></span></div></td> </tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="6357558"></a> <div id="answer-6357558" class="answer" data-answerid="6357558"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="6357558"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">1</span> <a class="vote-down-off" title="This answer is not useful">down vote</a> </div> </td> <td class="answercell"> <div class="post-text"><p>See this answer also</p> <pre class="lang-java prettyprint prettyprinted" style=""><code><span class="kwd ">int</span><span class="pln"> returnNumOFOddEvenSum</span><span class="pun">(</ span><span class="kwd">int</span><span class="pln"> </span><span class="pun">[]< /span><span class="pln"> A</span><span class="pun">){</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> sumOdd</span><span cla ss="pun">=</span><span class="lit">0</span><span class="pun">.0 reputation" class="comment-user owner">geoaxis</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow.j is enforced because odd/even only includes numbers with an index before j.<a href="http://stackoverflow. I correcte d the condition.com/questions/47030 47/review-of-a-codility-test-pair-sum-even-count/4703443#comment5190906_4703214" ><span title="2011-01-16 01:52:20Z" class="relativetime-clean">Jan 16 '11 at 1:5 2</span></a></span><span class="edited-yes" title="this comment was edited"></sp an></div></td> </tr> <tr id="comment-5191178" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">Yes.</span><span class .

</span><span class="pln"> i</span><span class= "pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> sum</span><span class="pun">+=</span><span class="pln">i</span><span cla ss="pun">.=</span><span class="pln">num</span><span class="pun">-</span><span class ="lit">1</span><span class="pun">.</span><span class="pln"> i</span><span class="pu n">&lt.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> factSum</span><span class= "pun">(</span><span class="kwd">int</span><span class="pln"> num</span><span cla ss="pun">){</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> sum</span><span class= "pun">=</span><span class="lit">0</span><span class="pun">.</span><span class="pln">length</span><span class=" pun">==</span><span class="lit">0</span><span class="pun">)</span><span class="p ln"> </span><span class="kwd">return</span><span class="pln"> </span><span cl ass="lit">0</span><span class="pun">.</span><span class="pln">A</span><span class="pun">.</span><span class="p ln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="kw d">int</span><span class="pln"> i</span><span class="pun">=</span><span class="l it">1</span><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> sum</span><span cla ss="pun">.</span><span clas s="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class="pln ">A</span><span class="pun">.</span><span class="pln"> i</span><span class="pu n">&lt.="pln"> </span><span class="kwd">int</span><span class="pln"> sumEven</span><span cl ass="pun">=</span><span class="lit">0</span><span class="pun">.</span><span class="p ln">length</span><span class="pun">.</span><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="kw d">int</span><span class="pln"> i</span><span class="pun">=</span><span class="l it">0</span><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span></code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt"> .</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> sumOdd</span><span class="pun">++.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> factSum</span><span class="pun">(</span><span class="pln">sumEven</span><span class="pun">)+</span> <span class="pln">factSum</span><span class="pun">(</span><span class="pln">sumO dd</span><span class="pun">).</span><span class="pln"> i</span><span clas s="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class= "pln">A</span><span class="pun">[</span><span class="pln">i</span><span class="p un">]%</span><span class="lit">2</span><span class="pun">==</span><span class="l it">0</span><span class="pun">)</span><span class="pln"> sumEven</span><span class="pun">++.

com/users/463139/stealthyninja"><div c lass=""><img src=".com/posts/6357558/edit" c lass="suggest-edit-post" title="">improve this answer</a></div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> <a href="http://stackoverflow./java .Sta ck Overflow_files/5f2b4416fa5d321a643e3714705a7ca8" alt="" width="32" height="32 "></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.pair_sum_even_count ./java .review of a codility test .review of a codility test .<div class="post-menu"><a href="http://stackoverflow.pair_sum_even_count . 011</span><span title="6 gold badges"><span class="badge1"></span><span class="b adgecount">6</span></span><span title="19 silver badges"><span class="badge2"></ span><span class="badgecount">19</span></span><span title="26 bronze badges"><sp an class="badge3"></span><span class="badgecount">26</span></span> </div> </div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> answered <span title="2011-06-15 12:18:0 8Z" class="relativetime">Jun 15 '11 at 12:18</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/posts/6357558/revi sions" title="show all edits to this post">edited <span title="2012-02-09 21:03: 28Z" class="relativetime">Feb 9 '12 at 21:03</span></a> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.Stack Overflow_files/030393b2bf55e2ab43236414ea1e3218" alt="" width="32" height="32">< /div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/760511/user760511">user76051 1</a><br> .com/a/6357558" title="short permalink to this answer" class="short-link" id="link-post-6357558">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.com/users/760511/user760511"><div clas s=""><img src=".com/users/463139/stealthyninja">stealt hyninja</a><br> <span class="reputation-score" title="reputation score" dir="ltr">7.

<span class="reputation-score" title="reputation score" dir="ltr">20 </span><span title="4 bronze badges"><span class="badge3"></span><span class="ba dgecount">4</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-6357558" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="9643933"></a> <div id="answer-9643933" class="answer" data-answerid="9643933"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="9643933"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">1</span> <a class="vote-down-off" title="This answer is not useful">down vote</a> </div> </td> <td class="answercell"> <div class="post-text"><pre class="lang-java prettyprint prettyprinted" styl e=""><code><span class="kwd">public</span><span class="pln"> </span><span class= "kwd">int</span><span class="pln"> getEvenSumPairs</span><span class="pun">(</sp an><span class="kwd">int</span><span class="pun">[]</span><span class="pln"> arr ay</span><span class="pun">){</span><span class="pln"> .

</span><span class="pln"> j</span><span class="p un">&lt.</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> evenSum</span><spa n class="pun">.</span><span class=" pln"> </span><span class="kwd">int</span><span class="pln"> odd</span><span class= "pun">=</span><span class="lit">0</span><span class="pun">.</span><span clas s="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="k wd">int</span><span class="pln"> j</span><span class="pun">=</span><span class=" lit">0</span><span class="pun">.</span><span cla ss="pln">length</span><span class="pun">.</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> odd</span><spa n class="pun">++.</span><span class="pln"> </span><span class="pun">++</span><span class="pln">j</span><span class="pun">){</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span cla ss="pln">array</span><span class="pun">[</span><span class="pln">j</span><span c lass="pun">]%</span><span class="lit">2</span><span class="pun">==</span><span c lass="lit">0</span><span class="pun">)</span><span class="pln"> even</span><span class="pun">++.</span><span class="kwd">int</span><span class="pln"> even</span><span class ="pun">=</span><span class="lit">0</span><span class="pun">.com/posts/9643933/edit" c lass="suggest-edit-post" title="">improve this answer</a></div> </td> <td align="right" class="post-signature"> .</span><span class="p ln"> </span><span class="kwd">int</span><span class="pln"> evenSum</span><span cl ass="pun">=</span><span class="lit">0</span><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span></code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> evenSum</span><span class="pun">=((</span><span class="pln">even</span><spa n class="pun">*(</span><span class="pln">even</span><span class="pun">-</span><s pan class="lit">1</span><span class="pun">)/</span><span class="lit">2</span><sp an class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="pun">(</span><span class="pln">odd </span><spa n class="pun">*(</span><span class="pln">odd</span><span class="pun">-</span><sp an class="lit">1</span><span class="pun">)/</span><span class="lit">2</span><spa n class="pun">)</span><span class="pln"> </span><span class="pun">.com/a/9643933" title="short permalink to this answer" class="short-link" id="link-post-9643933">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.</span><span class="pln">array</span><span class="pun">.

<div class="user-info user-hover"> <div class="user-action-time"> <a href="http://stackoverflow.9k</span><span title="11 gold badges"><span class="badge1"></span><span c lass="badgecount">11</span></span><span title="30 silver badges"><span class="ba dge2"></span><span class="badgecount">30</span></span><span title="50 bronze bad ges"><span class="badge3"></span><span class="badgecount">50</span></span> </div> </div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> answered <span title="2012-03-10 04:28:0 5Z" class="relativetime">Mar 10 '12 at 4:28</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.review of a codility test .com/posts/9643933/revi sions" title="show all edits to this post">edited <span title="2012-03-10 14:11: 03Z" class="relativetime">Mar 10 '12 at 14:11</span></a> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.Stack Overflow_files/ayujB.review of a codility test .com/users/1260598/mathew-kurian"><div class=""><img src=".pair_sum_e ven_count ./java .pair_sum_even_count .com/users/1260598/mathew-kurian">Mathe w_Kurian</a><br> <span class="reputation-score" title="reputation score" dir="ltr">11 </span><span title="1 bronze badge"><span class="badge3"></span><span class="bad gecount">1</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr> .jpg" alt=""></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/203657/kleopatra">kleopatra< /a><br> <span class="reputation-score" title="reputation score 23900" dir="l tr">23.com/users/203657/kleopatra"><div class ="gravatar-wrapper-32"><img src="./java .St ack Overflow_files/c33710b572a6af7d00cab54457a53f30" alt="" width="32" height="3 2"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.

</span><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="kw d">int</span><span class="pln"> i </span><span class="pun">=</span><span class=" pln"> </span><span class="lit">0</span><span class="pun">.</span><span class="pln"> a</span><span class .<tr> <td class="votecell"></td> <td> <div id="comments-9643933" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="4935657"></a> <div id="answer-4935657" class="answer" data-answerid="4935657"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="4935657"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">0</span> <a class="vote-down-off" title="This answer is not useful">down vote</a> </div> </td> <td class="answercell"> <div class="post-text"><p>A Java implementation that works great based on th e answer by "Svante":</p> <pre class="lang-java prettyprint prettyprinted" style=""><code><span class="kwd ">int</span><span class="pln"> getNumSumsOfTwoEven</span><span class="pun">(</sp an><span class="kwd">int</span><span class="pun">[]</span><span class="pln"> a</ span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</sp an><span class="pln"> </span><span class="kwd">long</span><span class="pln"> numOdd </span><span c lass="pun">=</span><span class="pln"> </span><span class="lit">0</span><span cla ss="pun">.</span><span class="pln"> </span><span class="kwd">long</span><span class="pln"> numEven </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span cl ass="pun">.</span><span class="pl n"> i </span><span class="pun">&lt.

even nums or nu m odd nums.</span><span class="pln"> </span> <span class="pun">((</span><span class="kwd">long</span><span class="pun">)</spa n><span class="lit">1e9</span><span class="pun">))</span><span class="pln"> </sp an><span class="pun">{</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span cl ass="pun">-</span><span class="lit">1</span><span class="pun">.</span><span cl ass="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span c lass="pun">{</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(</span><span class= "pln">a</span><span class="pun">[</span><span class="pln">i</span><span class="p un">]</span><span class="pln"> </span><span class="pun">%</span><span class="pln "> </span><span class="lit">2</span><span class="pln"> </span><span class="pun"> ==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">) </span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </ span><span class="com">//even</span><span class="pln"> numOdd</span><span class="pun">++.="pun">.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="com">//N! / ((N .k)! · k!).</span><span class="pln"> numSumOfTwoEven </span><span class="pun">+=</span><span class="pln"> </span> <span class="pun">(</span><span class="kwd">long</span><span class="pun">)(</spa n><span class="pln">fact</span><span class="pun">(</span><span class="pln">numEv en</span><span class="pun">)</span><span class="pln"> </span><span class="pun">/ </span><span class="pln"> </span><span class="pun">(</span><span class="pln">fac t</span><span class="pun">(</span><span class="pln">numEven </span><span class=" pun">-</span><span class="pln"> </span><span class="lit">2</span><span class="pu n">)</span><span class="pln"> </span><span class="pun">*</span><span class="pln" > </span><span class="lit">2</span><span class="pun">)).</span><span class="pln">length</span><span class="pun">. where N = num.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class=" kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class= "pln"> numEven</span><span class="pun">++.</span><span clas s="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> numSumOfTwoEven</sp an><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="com">// This is a recursive function to calculate factorials </span><span class="pln"> </span><span class="kwd">long</span><span class="pln"> fact</span><span class="p un">(</span><span class="kwd">int</span><span class="pln"> i</span><span class=" pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pl n"> . k = 2</span><span class="pln"> </span><span class="kwd">long</span><span class="pln"> numSumOfTwoEven </spa n><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span> <span class="kwd">long</span><span class="pun">)(</span><span class="pln">fact</ span><span class="pun">(</span><span class="pln">numOdd</span><span class="pun"> )</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> < /span><span class="pun">(</span><span class="pln">fact</span><span class="pun">( </span><span class="pln">numOdd </span><span class="pun">-</span><span class="pl n"> </span><span class="lit">2</span><span class="pun">)</span><span class="pln" > </span><span class="pun">*</span><span class="pln"> </span><span class="lit">2 </span><span class="pun">)).</span><span class="pln" > </span><span class="kwd">if</span><span class="pun">(</span><span class="pln ">numSumOfTwoEven </span><span class="pun">&gt.

355</span><span title="7 silver badges"><span class="badge2"></span><span class= "badgecount">7</span></span><span title="10 bronze badges"><span class="badge3"> </span><span class="badgecount">10</span></span> </div> </div> </td> .Stack Overfl ow_files/6df83c44cc2b1fcbe19a5d393af6ddee" alt="" width="32" height="32"></div>< /a> </div> <div class="user-details"> <a href="http://stackoverflow.review of a codility test .</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> i </span><span clas s="pun">*</span><span class="pln"> fact</span><span class="pun">(</span><span cl ass="pln">i</span><span class="pun">-</span><span class="lit">1</span><span clas s="pun">).com/a/4935657" title="short permalink to this answer" class="short-link" id="link-post-4935657">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.</span><span class="kwd">if</span><span class="pun">(</span><span class="pln ">i </span><span class="pun">==</span><span class="pln"> </span><span class="lit ">0</span><span class="pun">)</span><span class="pln"> </span><span class="pun"> {</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span cl ass="lit">1</span><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span></code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.com/posts/4935657/edit" c lass="suggest-edit-post" title="">improve this answer</a></div> </td> <td align="right" class="post-signature"> <div class="user-info user-hover"> <div class="user-action-time"> answered <span title="2011-02-08 16:36:1 3Z" class="relativetime">Feb 8 '11 at 16:36</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow./java .pair_sum_even_count .com/users/438466/rabi">Rabi</a><br> <span class="reputation-score" title="reputation score" dir="ltr">1.com/users/438466/rabi"><div class="">< img src=".

You might run into serious outofrange exceptions wh en counting bigger factorials.</tr> </tbody></table> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-4935657" class="comments"> <table> <tbody> <tr id="comment-5953043" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">I think that yo u could (should :)) simplify the enumeration of N!/(N-k)! * k!.</span> â &nbsp.</a> <span class="com ment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow. That's it.com/ques tions/4703047/review-of-a-codility-test-pair-sum-even-count/4703443#comment59530 43_4935657"><span title="2011-03-12 12:40:42Z" class="relativetime-clean">Mar 12 '11 at 12:40</span></a></span><span class="edited-yes" title="this comment was edited"></span></div></td> </tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="7900493"></a> <div id="answer-7900493" class="answer" data-answerid="7900493"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="7900493"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">0</span> <a class="vote-down-off" title="This answer is not useful">down vote</a> </div> </td> . and the recursion might be also performance problem.com/users /330754/pz" title="491 reputation" class="comment-user">Pz. You might count it as N*(N-1)/2 (where N is numEven or numOdd]). since you know t hat k = 2.<a href="http://stackoverflow. as Svante corre ctly figured out. You don't need to count factorials at all.

</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="pun">( </span><span class="kwd">int</span><span class="pln"> aA </span><span class="pun ">:</span><span class="pln"> A</span><span class="pun">)</span><span class="pln" > </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun"> (</span><span class="pln">aA </span><span class="pun">%</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="pun">== </span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</ span><span class="pln"> </span><span class="pun">{</span><span class="pln"> evenNumbersCount</span><span class="pun">++.</span></code></ pre> .</span><span class="pln">length </span><span clas s="pun">&lt.</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> oddNumberCount </span><spa n class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> evenNumbersCount </span><s pan class="pun">=</span><span class="pln"> </span><span class="lit">0</span><spa n class="pun">.</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> i </span><span class="p un">&gt.<td class="answercell"> <div class="post-text"><p>Please check this</p> <pre class="lang-java prettyprint prettyprinted" style=""><code><span class="kwd ">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln" >A </span><span class="pun">==</span><span class="pln"> </span><span class="kwd" >null</span><span class="pln"> </span><span class="pun">||</span><span class="pl n"> A</span><span class="pun">.</span><span class="pln"> </span><span class="lit">1000000000</span><spa n class="pln"> </span><span class="pun">?</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pln"> </span><span cl ass="pun">:</span><span class="pln"> i</span><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> i </span><span class="pun" >=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">e venNumbersCount </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="pln">evenNumbersCount </span><span class="pun" >-</span><span class="pln"> </span><span class="lit">1</span><span class="pun">) )</span><span class="pln"> </span><span class="pun">/</span><span class="pln"> < /span><span class="lit">2</span><span class="pln"> </span><span class="pun">+</s pan><span class="pln"> </span><span class="pun">(</span><span class="pln">oddNum berCount </span><span class="pun">*</span><span class="pln"> </span><span class= "pun">(</span><span class="pln">oddNumberCount </span><span class="pun">-</span> <span class="pln"> </span><span class="lit">1</span><span class="pun">))</span>< span class="pln"> </span><span class="pun">/</span><span class="pln"> </span><sp an class="lit">2</span><span class="pun">.</span><span class="pln"> </span><span class="lit">2</span><span cla ss="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class ="pln"> </span><span class="kwd">return</span><span class="pln"> </span><span class="l it">0</span><span class="pun">.</span><span class="pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">e lse</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> oddNumberCount</span><span class="pun">++.

com/a/7900493" title="short permalink to this answer" class="short-link" id="link-post-7900493">share</a><s pan class="lsep">|</span><a href="http://stackoverflow. When you have it imagine that this as a problem with a meeting. As you have here two separate "parties" going on you have to count them independently.<p>If someone has a problem with understanding what Sante said here is another e xplanation: Only odd+odd and even+even gives even. This is the same problem as how many pairs will say hallo to each other at th e party.com/posts/7900493/edit" c lass="suggest-edit-post" title="">improve this answer</a></div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> <a href="http://stackoverflow.com/posts/7900493/revi sions" title="show all edits to this post">edited <span title="2011-10-26 08:53: 00Z" class="relativetime">Oct 26 '11 at 8:53</span></a> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <br> </div> </div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> answered <span title="2011-10-26 08:47:0 .</p> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow. and you have to shake n-1 peoples hands and divide by 2 because the other person cant count your shake as distinct one. You have to find how many even and odd nu mbers are there. The answer is n*(n-1)/2 because there are n people. This is also the number of edges in full graph. How many people distinkt pairs are in the odd numbers list and even numbers lis t.

Stack Ove rflow_files/2e4f43385b9a51f157648c738b912def" alt="" width="32" height="32"></di v></a> </div> <div class="user-details"> <a href="http://stackoverflow.review of a codility test .com/users/281191/goroncy">goroncy</a>< br> <span class="reputation-score" title="reputation score" dir="ltr">17 6</span><span title="1 silver badge"><span class="badge2"></span><span class="ba dgecount">1</span></span><span title="4 bronze badges"><span class="badge3"></sp an><span class="badgecount">4</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-7900493" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="10346842"></a> <div id="answer-10346842" class="answer" data-answerid="10346842"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="10346842"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">0</span> <a class="vote-down-off" title="This answer is not useful">down vote</a> ./java .5Z" class="relativetime">Oct 26 '11 at 8:47</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.pair_sum_even_count .com/users/281191/goroncy"><div class=" "><img src=".

</span><span class ="pln">length</span><span class="pun">.</span><span class=" pln"> </span><span class="pun">}</span><span class="pln"> </span><span class="typ">System</span><span class="pun">.</span><span cla ss="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span cl ass="pun">{</span><span class="pln"> total </span><span class="pun">+=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">A</span><span class="pun">[</span><span cl ass="pln">size</span><span class="pun">-</span><span class="lit">1</span><span c lass="pun">]</span><span class="pln"> </span><span class="pun">-</span><span cla ss="pln"> A</span><span class="pun">[</span><span class="pln">i</span><span clas s="pun">])</span><span class="pln"> </span><span class="pun">/</span><span class ="pln"> </span><span class="lit">2</span><span class="pun">.</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> size </span><span clas s="pun">=</span><span class="pln"> A</span><span class="pun">.</span><span class="pln">println</span><span class="pun">(</span><span class="str">"Total : "</span><span class="pln"> </span ><span class="pun">+</span><span class="pln"> total</span><span class="pun">).com/posts/10346842/edit " class="suggest-edit-post" title="">improve this answer</a></div> </td> <td align="right" class="post-signature"> .com/a/10346842" title="shor t permalink to this answer" class="short-link" id="link-post-10346842">share</a> <span class="lsep">|</span><a href="http://stackoverflow.</span><span class="pln"> i </span><span class="p un">&lt.</div> </td> <td class="answercell"> <div class="post-text"><pre class="lang-java prettyprint prettyprinted" styl e=""><code><span class="pln"> </span><span class="kwd">int</span><span class= "pln"> total </span><span class="pun">=</span><span class="pln"> </span><span cl ass="lit">0</span><span class="pun">.</span><span class="pln"> size</span><span class="pun">.</span><span class= "pln">out</span><span class="pun">.</span><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class="kw d">int</span><span class="pln"> i</span><span class="pun">=</span><span class="l it">0</span><span class="pun">.</ span><span class="pln"> </span></code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.

pair_sum_even_count .Stack Overflow_files/2831ea4e4e9a8ba8a61fbf3c741632ca" alt="" width="32" height="32">< /div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1360581/subha-roy">Subha Roy </a><br> <span class="reputation-score" title="reputation score" dir="ltr">9< /span><span title="1 bronze badge"><span class="badge3"></span><span class="badg ecount">1</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-10346842" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="new-answer"></a> <form id="post-form" action="http://stackoverflow.split(" ").com/questions/4703047/answ er/submit" method="post" class="post-form"> <input type="hidden" id="post-id" value="4703047"> <h2 class="space">Your Answer</h2> <script type="text/javascript"> StackExchange.ready(function() { initTagRenderer("".<div class="user-info "> <div class="user-action-time"> answered <span title="2012-04-27 07:52:5 9Z" class="relativetime">Apr 27 '12 at 7:52</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow. ./java .review of a codility test . "".split(" ")).com/users/1360581/subha-roy"><div clas s=""><img src=".

"></span></li><li id="wmd-spacer1" class="wmd-spacer" style= "left: 50px.immediatelyShowMarkdownHelp:true })."><span style="background-position: 0px -20px."></span>< /li><li id="wmd-code-button" class="wmd-button" style="left: 125px."><span style="background-position: -60px -20px.</div> <div id="draft-saved" class="draft-saved community-option fl" style="margintop: 8px. height:24px."></span></li><li id=" wmd-heading-button" class="wmd-button" style="left: 250px."><span style="background-po sition: -20px -20px. height:24px.prepareEditor({ heartbeatType: 'answer'."><span style="b ackground-position: -200px -20px."><span style ="background-position: -80px -20px."></span></li><li id="wmd-image-button" class ="wmd-button" style="left: 150px."></span></li><li id="wmd-undo-button" class="w md-button" style="left: 325px."><span style="backgroun d-position: -40px -20px. })."></span></li><li id="wmd-quote-button" class="wmd-butto n" style="left: 100px."><span style="background-position: -100px -20p x."><span style="background-position: -140px -20px."> <div class="wmd-container"> <div id="wmd-button-bar" class="wmd-button-bar"><ul id="wmd-button-r ow" class="wmd-button-row"><li id="wmd-bold-button" class="wmd-button" style="le ft: 0px."></span> </li><li id="wmd-spacer3" class="wmd-spacer" style="left: 300px."><sp an style="background-position: -120px -20px.">draft discarded</div> <div id="wmd-preview" class="wmd-preview"></div> <div></div> <div class="edit-block"> ."><span style="background-position: -180px -20px. display:none."></span></li><li id="wmd-ulist-button" class="wmd-button" style="lef t: 225px."></span></li><li id ="wmd-link-button" class="wmd-button" style="left: 75px. onDemand: true."></span></li><li id="wmd-olist-butt on" class="wmd-button" style="left: 200px."></span></li></ul></div> <textarea id="wmd-input" class="wmd-input" name="post-text" cols="92 " rows="15" tabindex="101" data-min-length=""></textarea> </div> </div> <div class="fl" style="margin-top: 8px."><span style="background-position: -200px -20px."><s pan style="background-position: -220px -20px."><span style="backgro und-position: -160px -20px.">draft saved</div> <div id="draft-discarded" class="draft-discarded community-option fl" style= "margin-top: 8px.discard-answer" . </script> <div id="post-editor" class="post-editor"> <div style="position: relative. discardSelector: ". height:24px."><span style="background-position: -1 20px -20px." ></span></li><li id="wmd-redo-button" class="wmd-button" style="left: 350px.">&nbsp."></span></li><li id="wmd-spacer2" class="wmd-spacer" style="left: 175px. display:none."></span></li><li id="wmd-hr-button" class="wmd-butto n" style="left: 275px. bindNavPrevention: true."><span style="background-position: -40px -20px. postfix: ""."></span></li><li id="wmditalic-button" class="wmd-button" style="left: 25px.

bindHelpOverlayEvents($('.com/users/login?returnurl=%2fquestions%2f4703047%2freview-of-a-codility-tes t-pair-sum-even-count%23new-answer">log in</a></h3> <script type="text/javascript"> StackExchange.vm input')). </script> <td class="vm"> <div> <label for="display-name">Name</label> <input id="display-name" name="display-name" type="text" siz e="30" maxlength="30" value="" tabindex="105"> </div> <div> <label for="m-address">Email</label> <input id="m-address" name="m-address" type="text" size="30" maxlength="100" value="" tabindex="106"> <span class="edit-field-overlay">required."> <div class="form-item new-post-login"> <div class="new-login-form"> <div class="new-login-left"> <h3>Sign up or <a id="login-link" href="http://stackover flow.<input id="fkey" name="fkey" type="hidden" value="9336b12e86af343415687d 9e813eec5f"> <input id="author" name="author" type="text"> </div> </div> <div style="position: relative. but not shown</sp an> .helpers. }). </script> <div class="preferred-login google-login"> <p><span class="icon"></span><span>Sign up using Goo gle</span></p> </div> <div class="preferred-login facebook-login"> <p><span class="icon"></span><span>Sign up using Fac ebook</span></p> </div> <div class="preferred-login stackexchange-login"> <p><span class="icon"></span><span>Sign up using Sta ck Exchange</span></p> </div> </div> <input type="hidden" name="manual-openid" class="manual-open id"> <input type="hidden" name="use-facebook" class="use-facebook " value="false"> <input type="button" class="submit-openid" value="Submit" st yle="display:none"> <div class="new-login-right"> <h3>Post as a guest</h3> <div class="form-item"> <table> <tbody><tr> <script type="text/javascript"> StackExchange. }).ready(function () { StackExchange.helpers.onClickDraftSave('#login-l ink').ready(function () { StackExchange.

/div&gt.vm input')).initPostLogin('. &lt.openid. &lt. &lt. you agree to the <a href="http://stackexchange.tr&gt. &lt. but not sho wn&lt. &lt. </noscript> </div> <div class="form-submit cbt"> <input id="submit-button" type="submit" value="Post Your Answer" tab index="110"> <a href="http://stackoverflow.input id="m-address" name="m-address" type="text" size=" 30" maxlength="100" value="" tabindex="106"&gt./span&gt./div&gt./div&gt.ready(function () { StackExchange. '% 2fquestions%2f4703047%2freview-of-a-codility-test-pair-sum-even-count%23new-answ er').script type="text/javascript"&gt.input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105"&gt. &lt.helpers. &lt. &lt.span class="edit-field-overlay"&gt.table&gt.div&gt./td&gt. &lt. </script> <noscript> &lt.td class="vm"&gt.div class="form-item"&gt.com/questions/4703047/review-of-a-codi lity-test-pair-sum-even-count/4703443#" class="discard-answer dno">discard</a> <p class="privacy-policy-agreement"> By posting your answer.Post as a guest&lt.h3&gt./script&gt.com/legal/privacy-policy" target="_blank"> privacy policy</a> and <a href="http://stackexchange. &lt./label&gt.label for="m-address"&gt.required. &lt.div&gt./h3&gt. }). &lt. &lt./label&gt. &lt. } ). &lt.new-post-login'. .label for="display-name"&gt.bindHelpOverlayEvents($('. &lt.Name&lt. &lt./tr&gt. &lt. StackExchange.ready( function () { StackExchange.Email&lt.com/legal/terms-of-service" target="_blank ">terms of service</a>.</div> </td> </tr> </tbody></table> </div> </div> </div> </div> <script type="text/javascript"> StackExchange./table&gt. &lt.

puzzle&#39." rel="tag">a lgorithm</a> <a href="http://stackoverflow." rel="tag">algorithm</a>&nbsp." rel="tag">codility</a>&nbsp.java&#39.<span class ="item-multiplier"><span class="item-multiplier-x">Ã </span>&nbsp.com/questions/tagged/codility" class="post-tag" title ="show questions tagged &#39.</p> <input type="hidden" name="legalLinksShown" value="1"> </div> </form> <h2 class="bottom-notice"> Not the answer you're looking for? Browse other questions tagged <a href="http://stackoverflow." rel="tag">puzzle</a> <a href="http://stackoverflow." rel="tag">puzzle</a>&nbsp. </h2> </div> </div> <div id="sidebar" class="show-votes"> <div class="module question-stats"> <p class="label-key">tagged</p> <div class="tagged"><a href="http://stackoverflow.codility&#39.<span class= "item-multiplier-count">21</span></span><br> </div> <table id="qinfo"> <tbody><tr> <td><p class="label-key">asked</p></td> <td style="padding-left:10px"><p class="label-key" title="2011-0 1-16 00:33:41Z"><b>2 years ago</b></p></td> </tr> <tr> <td><p class="label-key">viewed</p></td> <td style="padding-left:10px"> <p class="label-key"> <b>9533 times</b> </p> </td> </tr> <tr> <td><p class="label-key">active</p></td> <td style="padding-left:10px"><p class="label-key"><b><a href="h .codility&#39." rel="tag">codility</a> or <a href="http://stackoverflow.com/questions/tagged/j ava" class="post-tag" title="show questions tagged &#39.algorithm&#39.algorithm&#39." rel="tag">java</a> <a href="http://stackoverflow.<span cla ss="item-multiplier-count">30772</span></span><br> <a href="http://stackoverflow.<span class="item-multiplier-count">439096</span></span><br> <a href="http://stackoverflow.<span class="item-multiplier"><span class="item-multiplier-x">Ã </span>&nbsp.com/ques tions/tagged/java" class="post-tag" title="show questions tagged &#39.com/questions/ask">ask your own question</a>.com/questions/tagged/algorithm" class="post-tag" t itle="show questions tagged &#39.java&#39.com/questions/tagged/puzzle" class="post-tag" titl e="show questions tagged &#39.com/questions/tagged/puzzle" class="p ost-tag" title="show questions tagged &#39.com/questions/tagged/algorithm " class="post-tag" title="show questions tagged &#39." rel="tag">jav a</a>&nbsp.puzzle&#39.<span class="itemmultiplier-count">534</span></span><br> <a href="http://stackoverflow.<s pan class="item-multiplier"><span class="item-multiplier-x">Ã </span>&nbsp.com/questions/tagged/codility" class="post-tag" ti tle="show questions tagged &#39.<span class="item-multiplier"><span class="item-multiplier-x">Ã </span>&n bsp.

s).ready(function() { var z = document.adzerk2_2_17_45. else scriptSrc += "?".net/z/8277/adzerk1_2_4 _43.codility".referrer.</a></form></div><img height="0px" width="0px" border="0" src=".createElement("script").test(scriptSrc)) scriptSrc += "&".careers_adurl="http://careers.stackoverflow. s.com/gethired/js".ttp://stackoverflow.insertBefore(z. z.async = "true"./java .caree . if (document. </script> <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk2"><di v id="careersadsdoublehigh" style="display:none.puzzle.type = "text/javascript".revi ew of a codility test .stackoverflow."><div class="adzerk-vote-option adzerk-vote-up">< div class="adzerk-vote-icon"></div></div><div class="adzerk-vote-option adzerk-v ote-down"><div class="adzerk-vote-icon"></div></div></div><div class="adzerk-vot e-survey" style="display:none.adzerk.Stack Overflow_files/i(2).pair_sum_even_count .getElementsByTagName("script")[0].gif"></d iv> <div id="hireme"> <script type="text/javascript"> window.window.adzerk3_2_4_44?keywords=java. } StackExchange.src = scriptSrc.algorithm."></div><div class="adzerk-votecontrols" style="display:none.c om/?cb=1" class="event-date" target="_blank">blog</a></div> <div class="bulletin-item-content"> <a href="http://blog. We won't show you that a d again.parentNode. Why didn't you like it?</span><ul><li><label><input type="radio" value= "12" name="downvoteReason">Uninteresting</label></li><li><label><input type="rad io" value="13" name="downvoteReason">Misleading</label></li><li><label><input ty pe="radio" value="14" name="downvoteReason">Offensive</label></li><li><label><in put type="radio" value="15" name="downvoteReason">Repetitive</label></li></ul><a href="http://stackoverflow. var s = document.com/questions/4703047/review-of-a-codility-test-pair-sum-eve n-count/4703443?lastactivity" class="lastactivity-link" title="2013-06-05 21:34: 45Z">26 days ago</a></b></p></td> </tr> </tbody></table> </div> <div class="module community-bulletin" data-tracker="cb=1"> <h4>Community Bulletin</h4> <div class="related"> <div class="spacer"> <div class="bulletin-item-type"><a href="http://blog.com/2013/07/say-hi-to-nine-of -our-newest-newbies/?cb=1" class="question-hyperlink" target="_blank">Say Hi to Nine of Our Newest Newbies</a> </div> <br class="cbt"> </div> </div> </div> <script type="text/javascript"> var scriptSrc = "http://engine. })."><form><span>No problem.com/questions/4703047/review-of-a-codility-test-pair -sum-even-count/4703443#" class="adzerk-vote-cancel">Oops! I didn't mean to do t his. z. scriptSrc += "xReferrer=" + document.referrer) { if (/\?/. z.stackoverflow.

sstatic.net/careers/gethired/company".com/questions/2338402/faster-implementation-of-sum -for-codility-test?rq=1" class="question-hyperlink">faster implementation of sum ( for Codility test )</a> </div> <div class="spacer"> <a href="http://stackoverflow.d ownvotes)"> <div class="answer-votes default">0</div> </a> <a href="http://stackoverflow.com/questions/8624083/dictionary-runtime-codilitytest-repost?rq=1" class="question-hyperlink">Dictionary runtime (Codility Test) Repost</a> </div> <div class="spacer"> <a href="http://stackoverflow.dataType:"script".css?v=78ccbfa5c59f".com/questions/4599009/confused-about-codility-demo -test?rq=1" class="question-hyperlink">Confused about Codility demo test</a> </div> <div class="spacer"> <a href="http://stackoverflow.css?v=17be6ca0 db4b".window.window.rs_cssurl="//cdn-careers.d ownvotes)"> <div class="answer-votes answered-accepted default">0</div> </a> <a href="http://stackoverflow.com/q/9099036?rq=1" title="Vote score (upvotes .hireme.com/q/8623924?rq=1" title="Vote score (upvotes .StackExchange.sst atic.ajax({url:"//cdn-careers.cache:!0})}) </script> </div> <div class="module sidebar-related"> <h4 id="h-related">Related</h4> <div class="related" data-tracker="rq=1"> <div class="spacer"> <a href="http://stackoverflow.com/questions/9099036/codility-k-sparse-test-spoil ers?rq=1" class="question-hyperlink">Codility K-Sparse Test **Spoilers**</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/9439352?rq=1" title="Vote score (upvotes .sstatic.net/care ers/gethired/loader.d ownvotes)"> <div class="answer-votes default">0</div> </a> <a href="http://stackoverflow.min.d ownvotes)"> <div class="answer-votes answered-accepted default">0</div> </a> <a href="http://stackoverflow.min.careers_companycssurl="//cdn-careers.js?v=607ab2dda910".window. div#hi reme".careers_adselector="div.sstatic.net/careers/gethired/sidebar.d .com/q/2338402?rq=1" title="Vote score (upvotes .net/careers/gethir ed/ninja.com/questions/8623924/dictionary-runtime-codilitytest?rq=1" class="question-hyperlink">Dictionary runtime (Codility Test)</a> </div> <div class="spacer"> <a href="http://stackoverflow.ready(function(){$.min.careers_leaderboardcssurl="//cdn-careers.com/q/4599009?rq=1" title="Vote score (upvotes .d ownvotes)"> <div class="answer-votes answered-accepted default">7</div> </a> <a href="http://stackoverflow.com/q/8624083?rq=1" title="Vote score (upvotes .

}).get('/posts/4703047/ivc/7ea7').div&gt.com/q/12417383?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes answered-accepted default">9</div> </a> <a href="http://stackoverflow.com/questions/10146093/codility-extreme-large-numb er-error?rq=1" class="question-hyperlink">Codility extreme large Number error</a > </div> <div class="spacer"> <a href="http://stackoverflow.&lt.img src="/posts/4703047/ivc/7ea7" class="dno" alt="" width="0 " height="0"&gt.com/feeds/question/47 03047" title="feed of this question and its answers"><span class="feed-icon"></s pan>question feed</a></div> </div> <script type="text/javascript"> StackExchange./div&gt. </noscript><div style="display:none" id="prettify-lang">lang-java</div></div> .com/q/10146093?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes default">0</div> </a> <a href="http://stackoverflow.ownvotes)"> <div class="answer-votes answered-accepted default">2</div> </a> <a href="http://stackoverflow.&lt.com/questions/15740266/do-you-know-any-codility-li ke-tests-for-front-end-developement?rq=1" class="question-hyperlink">Do you know any Codility-like tests for Front-end Developement?</a> </div> </div> </div> </div> <div id="feed-link"> <div id="feed-link-text"><a href="http://stackoverflow.com/questions/14042447/counting-disk-intersections -using-treeset?rq=1" class="question-hyperlink">Counting Disk Intersections usin g TreeSet</a> </div> <div class="spacer"> <a href="http://stackoverflow.ready(function(){$.com/q/15740266?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes default">1</div> </a> <a href="http://stackoverflow.Codility .com/q/14042447?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes answered-accepted default">3</div> </a> <a href="http://stackoverflow.com/questions/12417383/programming-test-codility-d ominator?rq=1" class="question-hyperlink">Programming Test .com/questions/9439352/codility-fibonacci-solution? rq=1" class="question-hyperlink">Codility Fibonacci Solution</a> </div> <div class="spacer"> <a href="http://stackoverflow. </script> <noscript> &lt.Dominato r</a> </div> <div class="spacer"> <a href="http://stackoverflow.

stackexchange.com/">feedback</a> </b> </div> <div id="footer-sites"> <table> <tbody><tr> <th colspan="3"> Technology </th> <th> Life / Arts </th> <th> Culture / Recreation </th> <th> Science </th> <th> Other </th> </tr> <tr> <td> <ol> <li><a href="http://stackoverflow.com/" title="Ubuntu users .com/?blb=1">blog</a> <a href="http://chat.switchMobile(&quot.net/redirect/0/2776/2751/0/4de 3c60f719c4dfcb1a57531c7050090/0">advertising info</a> <a onclick="StackExchange.stackexchange.) ">mobile</a> <b><a href="http://stackoverflow./questions/4703047/review-of-a-codility-test-pair-sum-even-count/4703443&quot.stackexchange.</div> </div> <div id="footer" class="categories"> <div class="footerwrap"> <div id="footer-menu"> <div class="top-footer-links"> <a href="http://stackoverflow.com/legal/privacy-policy">priv acy policy</a> <a href="http://stackexchange.com/" title="professiona l system and network administrators">Server Fault</a></li> <li><a href="http://superuser..com/" title="p ower users of web applications">Web Applications</a></li> <li><a href="http://askubuntu.com/about/hiring">jobs</a> <a href="http://engine.com/contact">contact us</a> </b> <b><a href="http://meta.com/legal">legal</a> <a href="http://stackexchange.com/help">help</a> <a href="http://stackoverflow.on&quot.adzerk.com/" title="computer enth usiasts and power users">Super User</a></li> <li><a href="http://webapps.com/" title="professio nal and enthusiast programmers">Stack Overflow</a></li> <li><a href="http://serverfault. &quot .stackoverflow.com/about">about</a> <a href="http://stackoverflow.stackoverflow.com/">data</a> <a href="http://stackexchange.com/">chat</a> <a href="http://data.com/help/badges">badges</a > <a href="http://blog.

stackexchange.stackexchange.stackexchange.com/" title="datab ase professionals who wish to improve their database skills and learn from other s in the community">Database Administrators</a></li> <li><a href="http://drupal. geographers and GIS professionals">Geographic Information Systems</a>< /li> <li><a href="http://electronics.com/" titl e="professional programmers interested in conceptual questions about software de velopment">Programmers</a></li> <li><a href="http://unix.com/" title="user s of Linux.stackexchange.stackexchange. LaTeX.stackexchange. students.stackexchange.stackexchange.com/" titl e="electronics and electrical engineering professionals.stackexchange.com/" title="p rofessional and amateur chefs">Seasoned Advice (cooking)</a></li> <li><a href="http://diy. enthusiast and amateur photographers">Photography</a></li> <li><a href="http://scifi.stackexchange.LaTeX</a></li> </ol></td><td><ol> <li><a href="http://programmers.stackexchange.stackexchange. and related typesetting systems">TeX .com/" titl e="users of Mathematica">Mathematica</a></li> <li> <a href="http://stackexchange. FreeBSD and other Un*x-like operating systems.com/" title="Dr upal developers and administrators">Drupal Answers</a></li> <li><a href="http://sharepoint.com/" title="pro fessional.stackexchange.com/" title="pow er users of Apple hardware and software">Ask Different (Apple)</a></li> <li><a href="http://wordpress.">Unix &amp.and developers">Ask Ubuntu</a></li> <li><a href="http://webmasters.stackexchange.com/" title="users of TeX.stackexchange.stackexchange.stackexchange. Linux</a> </li> <li><a href="http://apple.stackexchange.com/" title ="SharePoint enthusiasts">SharePoint</a></li> <li><a href="http://ux. Fantasy</a></li> <li><a href="http://cooking.stackexchange.com/" title="user e xperience researchers and experts">User Experience</a></li> <li><a href="http://mathematica.stackexchange.com/" title ="pro webmasters">Webmasters</a></li> <li><a href="http://gamedev.com/" title=" IT security professionals">IT Security</a></li> </ol></td><td><ol> <li><a href="http://dba. ConTeXt.com/" title="e nthusiasts and power users of the Android operating system">Android Enthusiasts< /a></li> <li><a href="http://security.com/" title="p rofessional and independent game developers">Game Development</a></li> <li><a href="http://tex.com/" title="sci ence fiction and fantasy enthusiasts">Science Fiction &amp. and enthusias ts">Electrical Engineering</a></li> <li><a href="http://android.com/" title="contr actors and serious DIYers">Home Improvement</a></li> .com/sites#technology" class="more"> more (13) </a> </li> </ol> </td> <td> <ol> <li><a href="http://photo.com/" title="carto graphers.com/" title= "WordPress developers and administrators">WordPress Answers</a></li> <li><a href="http://gis.

and serious English language enthusiasts">English Langua ge &amp. experts in Christianity and those interested in learni ng more">Christianity</a></li> <li><a href="http://gaming.stackexchange. or commute on bi cycles">Bicycles</a></li> <li><a href="http://rpg.stackexchange.stackexchange. people who train cycling.com/" title="l inguists.com/sites#science" cla ss="more"> . paper-and-pencil role-playing games">Role-playin g Games</a></li> <li> <a href="http://stackexchange.stackexchange.com/" title=" scientific skepticism">Skeptics</a></li> <li><a href="http://judaism.com/" title="gamem asters and players of tabletop.com/" title="peop le studying math at any level and professionals in related fields">Mathematics</ a></li> <li><a href="http://stats.stackexchange. Usage</a></li> <li><a href="http://skeptics.stackexchange. etymologists.com/" title="sta tisticians.com/" title="pa ssionate videogamers on all platforms">Arqade (gaming)</a></li> <li><a href="http://bicycles. data miners and data visualization experts">Cross Val idated (stats)</a></li> <li><a href="http://cstheory.com/" title="t hose who base their lives on Jewish law and tradition and anyone interested in l earning more">Mi Yodeya (Judaism)</a></li> <li><a href="http://travel.stackexchange.com/" title=" people who build and repair bicycles.net/" title="mathematic ians">MathOverflow</a></li> <li> <a href="http://stackexchange.com/" title="a ctive researchers. data analysts.<li> <a href="http://stackexchange.com/sites#culturerecre ation" class="more"> more (21) </a> </li> </ol> </td> <td> <ol> <li><a href="http://math.com/sites#lifearts" cl ass="more"> more (13) </a> </li> </ol> </td> <td> <ol> <li><a href="http://english.com/" title="ro ad warriors and seasoned travelers">Travel</a></li> <li><a href="http://christianity.stackexchange.com/" tit le="committed Christians.stackexchange.stackexchange. academics and students of physics">Physics</a></li> <li><a href="http://mathoverflow.com/" title=" theoretical computer scientists and researchers in related fields">Theoretical C omputer Science</a></li> <li><a href="http://physics.stackexchange.stackexchange.

'|java|algorithm|puzzle|codility| ']). scripts .798 </div> </div> </div> <noscript> &lt.push(['_trackPageview']). (function(){ var s=document.com/">Stack Ov erflow Careers</a></li> </ol> </td> </tr> </tbody></table> </div> </div> <div id="copyright"> site design / logo © 2013 stack exchange inc.com/" title="pr oposing new sites in the Stack Exchange network">Area 51</a></li> <li><a href="http://careers.async=true.createElement('script'). </noscript> <script type="text/javascript">var _gaq=_gaq||[].1.google-analytics.com/2009/06/attributionrequired/" rel="license">attribution required</a> </div> <div id="footer-flair"> <a href="http://creativecommons._gaq. ga.stackoverflow.7.type='text/javascript'.com/" title="apps.&lt.s). 'tags'.div id="noscript-warning"&gt. ga.createElement('script').0/" class=" cc-wiki-link"></a> </div> <div id="svnrev"> rev 2013. _gaq.getElementsByTagName('script')[0].com/" title="meta -discussion of the Stack Exchange family of Q&amp. 1.img src="http://pixel. user contributions licensed under <a href="http://creativecommon s.stackoverflow./div&gt. ga. and development with the Stack Exchange API">Stack Apps</a></li> <li><a href="http://meta.com/pixel/p-c1rF4kxgLUzNc.push(['_setCustomVar'.org/licenses/by-sa/3.A websites">Meta Stack Overflo w</a></li> <li><a href="http://area51.gif" al t="" class="dno"&gt.'U A-5620270-1']).parentNode.more (7) </a> </li> </ol> </td> <td> <ol> <li><a href="http://stackapps. var _qevents = _qevents || [].com/ga.push(['_setAccount'.stackexchange.insertBefore(ga. s.org/licenses/by-sa/3.quantserve.0/" rel="license">cc-wiki</a> with <a href="http://blog.Stack Overflow works best with JavaScri pt enabled&lt. var ga=document. var sc=document.src='http://www.stackoverflow. .js'. _gaq.

sc.sc.s).parentNode. sc. </script> </body></html> .async=true. </script> <script type="text/javascript"> _qevents. s. })().type='text/javascript'.quantserve.src='http://edge.js'.com/quant.push({ qacct: "p-c1rF4kxgLUzNc" }).insertBefore(sc.