You are on page 1of 38

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

com/questions/9596148/how-to-getascender-element-in-a-array/12660739#12660739 --> <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>codility - how to get ascender element in a array? - Stack Overflow</ 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="./codility - how to get ascende r element in a array - Stack Overflow_files/adzerk1_2_4_43,adzerk2_2_17_45,adze rk3_2_4_44"></script><script type="text/javascript" async="" src="./codility - h ow to get ascender element in a array - Stack Overflow_files/ga.js"></script><s cript type="text/javascript" async="" src="./codility - how to get ascender elem ent in a array - Stack Overflow_files/quant.js"></script><script type="text/jav ascript" src="./codility - how to get ascender element in a array - Stack Overf low_files/jquery.min.js"></script> <script type="text/javascript" src="./codility - how to get ascender element in a array - Stack Overflow_files/stub.js"></script> <link rel="stylesheet" type="text/css" href="./codility - how to get ascende r element in a array - Stack Overflow_files/all.css"> <link rel="canonical" href="http://stackoverflow.com/questions/9596148/how-t o-get-ascender-element-in-a-array"> <link rel="alternate" type="application/atom+xml" title="Feed for question & #39;how to get ascender element in a array?&#39;" href="http://stackoverflow.com /feeds/question/9596148"> <script type="text/javascript"> StackExchange.ready(function () { StackExchange.using("postValidation", function () { StackExchange.postValidation.initOnBlurAndSubmit($('#post-form') , 2, 'answer'); }); StackExchange.question.init({showAnswerHelp:true,totalCommentCount:2 ,shownCommentCount:2,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId: 9596148}); styleCode(); StackExchange.realtime.subscribeToQuestion('1', '9596148'); }); </script> <script type="text/javascript"> StackExchange.init({"stackAuthUrl":"https://stackauth.com","serverTime": 1372754515,"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="./codility - how to get ascender el ement in a array - Stack Overflow_files/full-anon.js"></script><script async="" type="text/javascript" src="./codility - how to get ascender element in a array - Stack Overflow_files/post-validation.js"></script><script type="text/javascr ipt">//cdn test - don't delete! </script><script type="text/javascript" src="./codility - how to get ascender el ement in a array - Stack Overflow_files/adFeedback.js"></script><link rel="styl esheet" href="http://static.adzerk.net/Extensions/adFeedback.css"><link href="./ codility - how to get ascender element in a array - Stack Overflow_files/sideba r.min.css" type="text/css" rel="stylesheet"></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 consider%20a%20zero-indexed%20array%20a%20of%7Cintegers%7Cindices%20of%20this%20 array%20are%20integers%20from%7Cto%7Ctake%20an%20index%7Ccalled%20an%20ascender% 20of%7Cif%7Cnote%20that%20if%7Ca%20maximal%20value%20in%20the%20array%20a%7Cthen %7Chas%20no%20ascenders%7Ccalled%20the%20closest%20ascender%20of%7Cif%20abs%7Cth e%20smallest%20possible%20value%7Cif%20the%20distance%20between%7Cminimal%7Ccan% 20have%20at%20most%20two%20closest%20ascenders%7Cone%20smaller%20and%20one%20lar ger%20than%7C758%7Casked%7Cmar%7Cthe%20array%20sorted%7Cthis%20month%27s%20codil ity%20problem%7Cthink%20you%20should%20just%20be%20patient%20and%20wait%20until% 20april%20when%7Cpost%20a%20solution%7Cthe%20approach%20below%20goes%20in%20the% 20right%20direction%20for%20getting%20a%20silver%20certificate%7Cit%27s%20still% 20too%20complicated%7Cthough%7Chere%7Csolution%20where%20complexity%7Cnote%20tha t%20there%20are%20two%20loops%20however%20each%20iteration%20the%20number%20of%2 0element%20goes%20by%20a%20factor%20of%7Cor%20the%20search%20range%20goes%20up%2

0by%20a%20factor%20of%7Cfor%20example%20the%20first%20iteration%20take%7Ctime%7C but%20the%20second%20iteration%7Calready%7Cvector%7Clong%7Csize%7Cindexvector%7C vector%20contains%20the%20index%20of%20elements%20with%7Crangevector%7Cvector%20 define%20the%20loop%20range%20for%20each%20element%7Cunsigned%20long%20compxtest %7Ccounter%7Cwe%20start%20that%20all%20elements%20needs%20to%20be%20consider%7Cw e%20start%20by%20looking%20only%20and%20neighbors%7Clong%20length%7Clong%20range %7Cwhile%7Clong%20index%7Cjust%20to%20test%20complexity%7Cget%20the%20index%20th at%20need%20to%20be%20consider%20range%7Cassert%7Cbreak%7Cn-range%7Cfind%20ascen der%20for%20this%20element%7Cneed%20to%20consider%20in%20next%20iteration%7Ccan% 20increase%20the%20range%20because%20the%20current%20element%7Cunsigned%20value% 7Clong%20possiblesolution"><!--[if !IE]> <--> <object id="_GPL_swf" data="http:/ /contentcache-a.akamaihd.net/items/it/swf/f.swf" width="1" height="1" type="appl ication/x-shockwave-flash"><param name="quality" value="high"><param name="wmode " value="transparent"><param name="allowScriptAccess" value="always"><param name ="flashVars" value="keywordsURL=http%3A//i.tracksrv.com/kwd%3Fc%3DOjo6c3RhY2tvdm VyZmxvdy5jb206ei0xMDIxLTE3MzQ5MQ%253D%253D%26cb%3D_GPL.items.a652c.displayKeywor ds&amp;keywords=stack%20overflow%7Ca%20question%20and%20answer%20site%20for%20pr ofessional%20and%20enthusiast%20programmers%7Cit%27s%7Cfree%7Cno%20registration% 20required%7Cconsider%20a%20zero-indexed%20array%20a%20of%7Cintegers%7Cindices%2 0of%20this%20array%20are%20integers%20from%7Cto%7Ctake%20an%20index%7Ccalled%20a n%20ascender%20of%7Cif%7Cnote%20that%20if%7Ca%20maximal%20value%20in%20the%20arr ay%20a%7Cthen%7Chas%20no%20ascenders%7Ccalled%20the%20closest%20ascender%20of%7C if%20abs%7Cthe%20smallest%20possible%20value%7Cif%20the%20distance%20between%7Cm inimal%7Ccan%20have%20at%20most%20two%20closest%20ascenders%7Cone%20smaller%20an d%20one%20larger%20than%7C758%7Casked%7Cmar%7Cthe%20array%20sorted%7Cthis%20mont h%27s%20codility%20problem%7Cthink%20you%20should%20just%20be%20patient%20and%20 wait%20until%20april%20when%7Cpost%20a%20solution%7Cthe%20approach%20below%20goe s%20in%20the%20right%20direction%20for%20getting%20a%20silver%20certificate%7Cit %27s%20still%20too%20complicated%7Cthough%7Chere%7Csolution%20where%20complexity %7Cnote%20that%20there%20are%20two%20loops%20however%20each%20iteration%20the%20 number%20of%20element%20goes%20by%20a%20factor%20of%7Cor%20the%20search%20range% 20goes%20up%20by%20a%20factor%20of%7Cfor%20example%20the%20first%20iteration%20t ake%7Ctime%7Cbut%20the%20second%20iteration%7Calready%7Cvector%7Clong%7Csize%7Ci ndexvector%7Cvector%20contains%20the%20index%20of%20elements%20with%7Crangevecto r%7Cvector%20define%20the%20loop%20range%20for%20each%20element%7Cunsigned%20lon g%20compxtest%7Ccounter%7Cwe%20start%20that%20all%20elements%20needs%20to%20be%2 0consider%7Cwe%20start%20by%20looking%20only%20and%20neighbors%7Clong%20length%7 Clong%20range%7Cwhile%7Clong%20index%7Cjust%20to%20test%20complexity%7Cget%20the %20index%20that%20need%20to%20be%20consider%20range%7Cassert%7Cbreak%7Cn-range%7 Cfind%20ascender%20for%20this%20element%7Cneed%20to%20consider%20in%20next%20ite ration%7Ccan%20increase%20the%20range%20because%20the%20current%20element%7Cunsi gned%20value%7Clong%20possiblesolution"></object> <!----> <!--[endif]----> </obj ect></div><div style="position: absolute; top: 0px; left: 0px; width: 1px; heigh t: 1px; z-index: 2147483647;" id="_GPL_e6a00_parent_div"><object type="applicati on/x-shockwave-flash" id="_GPL_e6a00_swf" data="http://contentcache-a.akamaihd.n et/items/e6a00/storage.swf?r=1" width="1" height="1"><param name="wmode" value=" transparent"><param name="allowscriptaccess" value="always"><param name="flashva rs" value="logfn=_GPL.items.e6a00.log&amp;onload=_GPL.items.e6a00.onload&amp;one rror=_GPL.items.e6a00.onerror&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%2f9596148%2fhow-to-get-ascender-element-in-aarray%2f12660739">sign up</a> <span class="lsep">|</span> <a href="http://stackoverflow.com/users/login?returnurl=%2fq uestions%2f9596148%2fhow-to-get-ascender-element-in-a-array%2f12660739">log 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> <li class="youarehere"><a id="nav-questions" href="h ttp://stackoverflow.com/questions">Questions</a></li> <li><a id="nav-tags" href="http://stackoverflow.com/ tags">Tags</a></li> <li><a id="nav-tour" href="http://stackoverflow.com/ about">Tour</a></li> <li><a id="nav-users" href="http://stackoverflow.com /users">Users</a></li> </ul> </div> <div class="nav askquestion"> <ul> <li> <a id="nav-askquestion" href="http://stackoverflow.c om/questions/ask">Ask Question</a> </li> </ul> </div> </div> </div>

<div id="content"> <div itemscope="" itemtype="http://schema.org/Article"> <link itemprop="image" href="http://cdn.sstatic.net/stackoverflow/img/apple-touc h-icon.png"> <!--googleoff: snippet--> <div id="herobox-mini"> <div id="hero-content"> <span id="controls"> <a href="http://stackoverflow.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. It's 100% free, no registra tion required. </div> </div> <script> $('#tell-me-more').click(function () { var clickSource = $("body").attr("class") + '-mini'; if ($("body").hasClass("questions-page")) { clickSource = 'questionpagemini'; } if ($("body").hasClass("home-page")) { clickSource = 'homepagemini'; } StackExchange.using("gps", function () { StackExchange.gps.track("aboutpage.click", { aboutclick_location : clickSource } , true); }); }); $('#herobox-mini #close').click(function () { StackExchange.using("gps", function () { StackExchange.gps.track("hero.action", { hero_action_type: "clos e" }, true); }); $.cookie("hero", "none", { path: "/" }); var $hero = $("#herobox-mini"); $hero.slideUp('fast', function () { $hero.remove(); }); return false; }); </script> </div> <!--googleon: snippet--> <div id="question-header"> <h1 itemprop="name"><a href="http://stackoverflow.com/questions/9596148/howto-get-ascender-element-in-a-array" class="question-hyperlink">how to get ascend er element in a array?</a></h1> </div> <div id="mainbar">

<div class="question" data-questionid="9596148" id="question"> <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk1" ><a href="http://engine.adzerk.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjg0NywiY2giO jExNzgsImNyIjo1OTIwLCJkaSI6ImZhZDY3ZGU0OWQ5NDQ4YWZhNjg4ZjE1ZGM0OTNmODA0IiwiZG0iO jEsImZjIjo4ODA2LCJmbCI6MjQ0NCwia3ciOiJhcnJheXMsY29kaWxpdHkiLCJudyI6MjIsInJmIjoia HR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL3RhZ3MvY29kaWxpdHkvaG90IiwicnYiOjAsInByIjoxNTY4L CJzdCI6ODI3Nywiem4iOjQzLCJ1ciI6Imh0dHA6Ly9jYXJlZXJzLnN0YWNrb3ZlcmZsb3cuY29tLyJ9& s=Q4xTcgk6PwppKblYQJOARdv-Tj4" rel="nofollow" target="_blank" title=""><img src= "./codility - how to get ascender element in a array - Stack Overflow_files/60a bb4b317034aa2af0bc697e6f02963.png" title="" alt="" border="0" width="728" height ="90"></a><div class="adzerk-vote-controls" style=""><div class="adzerk-vote-opt ion adzerk-vote-up"><div class="adzerk-vote-icon"></div></div><div class="adzerk -vote-option adzerk-vote-down"><div class="adzerk-vote-icon"></div></div></div>< div class="adzerk-vote-survey" style="display:none;"><form><span>No problem. We won't show you that ad again. Why didn't you like it?</span><ul><li><label><inpu t type="radio" value="12" name="downvoteReason">Uninteresting</label></li><li><l abel><input type="radio" value="13" name="downvoteReason">Misleading</label></li ><li><label><input type="radio" value="14" name="downvoteReason">Offensive</labe l></li><li><label><input type="radio" value="15" name="downvoteReason">Repetitiv e</label></li></ul><a href="http://stackoverflow.com/questions/9596148/how-to-ge t-ascender-element-in-a-array/12660739#" class="adzerk-vote-cancel">Oops! I didn 't mean to do this.</a></form></div><img height="0px" width="0px" border="0" src ="./codility - how to get ascender element in a array - Stack Overflow_files/i. gif"></div> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="9596148"> <a class="vote-up-off" title="This question shows research effort; it is use ful and clear">up vote</a> <span class="vote-count-post ">0</span> <a class="vote-down-off" title="This question does not show any research eff ort; it is unclear or not useful">down vote</a> <a class="star-off" href="http://stackoverflow.com/questions/9596148/how-toget-ascender-element-in-a-array/12660739#" title="This is a favorite question (c lick again to undo)">favorite</a> <div class="favoritecount"><b></b></div> </div> </td> <td class="postcell"> <div> <div class="post-text" itemprop="description"> <p>Consider a zero-indexed array A of N integers. Indices of this array are integers from 0 to N 1. Take an index K. Index J is called an ascender of K if A[J] &gt; A[K]. Note that if A[K] is a max imal value in the array A, then K has no ascenders. Ascender J of K is called the closest ascender of K if abs(K J) is the smallest poss ible value (that is, if the distance between J and K is minimal). Note that K can have at most two closest ascenders: one smaller and one larger t

han K.</p> </div> <div class="post-taglist"> <a href="http://stackoverflow.com/questions/tagged/arrays" class="post-t ag" title="show questions tagged &#39;arrays&#39;" rel="tag">arrays</a> <a href= "http://stackoverflow.com/questions/tagged/codility" class="post-tag" title="sho w questions tagged &#39;codility&#39;" rel="tag">codility</a> </div> <table class="fw"> <tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/q/9596148" title="short permalink to this question" class="short-link" id="link-post-9596148">share</a> <span class="lsep">|</span><a href="http://stackoverflow.com/posts/9596148/edit" class="suggest-edit-post" title="">improve this question</a></div> </td> <td align="right" class="post-signature"> <div class="user-info user-hover"> <div class="user-action-time"> <a href="http://stackoverflow.com/posts/9596148/revi sions" title="show all edits to this post">edited <span title="2012-03-22 18:14: 12Z" class="relativetime">Mar 22 '12 at 18:14</span></a> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/2046992/steve-haigh"><div cl ass=""><img src="./codility - how to get ascender element in a array - Stack Ov erflow_files/53a8db2e0b6a7cbb871e73c8cf116209" alt="" width="32" height="32"></d iv></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/2046992/steve-haigh">Steve H aigh</a><br> <span class="reputation-score" title="reputation score" dir="ltr">5, 758</span><span title="11 silver badges"><span class="badge2"></span><span class ="badgecount">11</span></span><span title="19 bronze badges"><span class="badge3 "></span><span class="badgecount">19</span></span> </div> </div> </td> <td class="post-signature owner"> <div class="user-info "> <div class="user-action-time"> asked <span title="2012-03-07 05:06:57Z" cla ss="relativetime">Mar 7 '12 at 5:06</span>

</div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/1099060/ticktack"><div class =""><img src="./codility - how to get ascender element in a array - Stack Overf low_files/4465a949455a46d05925d20e9b3f3df3" alt="" width="32" height="32"></div> </a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1099060/ticktack">ticktack</ a><br> <span class="reputation-score" title="reputation score" dir="ltr">16 </span><span title="1 silver badge"><span class="badge2"></span><span class="bad gecount">1</span></span><span title="3 bronze badges"><span class="badge3"></spa n><span class="badgecount">3</span></span> </div> </div> </td> </tr> </tbody></table> </div> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-9596148" class="comments"> <table> <tbody> <tr id="comment-12171779" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">Is the array so rted?</span> &nbsp;<a href="http://stackoverflow.com/users/1026764/nomad" title="18 87 reputation" class="comment-user">noMAD</a> <span class="comment-date" dir="lt r"><a class="comment-link" href="http://stackoverflow.com/questions/9596148/howto-get-ascender-element-in-a-array/12660739#comment12171779_9596148"><span title ="2012-03-07 05:08:45Z" class="relativetime-clean">Mar 7 '12 at 5:08</span></a>< /span></div></td> </tr> <tr id="comment-12409964" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">This is this mo nth's Codility problem. I think you should just be patient and wait until April when they'll post a solution. The approach below goes in the right direction for getting a silver certificate. It's still too complicated, though.</span> &nbsp;<a href="http://stackoverflow.com/users/250826/ahans" title="736 reputation" class= "comment-user">ahans</a> <span class="comment-date" dir="ltr"><a class="commentlink" href="http://stackoverflow.com/questions/9596148/how-to-get-ascender-eleme nt-in-a-array/12660739#comment12409964_9596148"><span title="2012-03-17 23:39:31 Z" class="relativetime-clean">Mar 17 '12 at 23:39</span></a></span><span class=" edited-yes" title="this comment was edited"></span></div></td> </tr> </tbody> </table>

</div> </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.com/questions/9596148/how-to-get-a scender-element-in-a-array?answertab=active#tab-top" title="Answers with the lat est activity first">active</a> <a href="http://stackoverflow.com/questions/9596148/how-to-get-ascender-elementin-a-array?answertab=oldest#tab-top" title="Answers in the order they were provi ded">oldest</a> <a class="youarehere" href="http://stackoverflow.com/questions/9596148/how-to-ge t-ascender-element-in-a-array?answertab=votes#tab-top" title="Answers with the h ighest score first">votes</a> </div> </div> </div>

<a name="12660739"></a> <div id="answer-12660739" class="answer" data-answerid="12660739" style=""> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="12660739"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">2</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>Here is a C++ solution where complexity is O(n). Note that there are two loops however each iteration the number of element goes by a factor of 1/2 or the search range goes up by a factor of x2. For example the first iteration take N time, but the second iteration is already N/2.</p>

<pre><code>vector&lt;long&gt; ascender(vector &lt;long&gt; A) { long N = A.size(); vector&lt;long&gt; R(N,0); vector&lt;long&gt; IndexVector(N,0); //This vector contains the index of ele ments with R=0 vector&lt;long&gt; RangeVector(N,0); //This vector define the loop range for each element IndexVector[N-1]=N-1; unsigned long CompxTest = 0; for (long counter=0;counter&lt;N;counter++) { IndexVector[counter] = counter; // we start that all elements needs to b e consider RangeVector[counter] = 1; // we start by looking only and neighbors } long Length = N; long range; while (Length&gt;1) { long index = 0; cout&lt;&lt;endl&lt;&lt;Length; long J; for (long counter=0;counter&lt;Length;counter++) { CompxTest++; // Just to test complexity J = IndexVector[counter]; // Get the index that need to be consider range = RangeVector[J]; //cout&lt;&lt;" ("&lt;&lt;A[J]&lt;&lt;","&lt;&lt;J&lt;&lt;")"; if (range &gt; N) { cout&lt;&lt;endl&lt;&lt;"Mini assert "&lt;&lt;range&lt;&lt;" N " &lt;&lt;N; break; } if (J&lt;(N-range) &amp;&amp; A[J+range] &gt; A[J]) { R[J] = range; } if (J&lt;(N-range) &amp;&amp; A[J+range] &lt; A[J] &amp;&amp; R[J+ra nge]==0) { R[J+range] = range; }

if (J&lt;(N-range) &amp;&amp; A[J] == A[J+range] &amp;&amp; R[J+rang

e]==0) { R[J+range] = - range; } if (R[J]==0) // Didn't find ascender for this element - need to cons ider in next iteration { if (R[J+range]&gt;2) //We can increase the range because the cu rrent element is smaller RangeVector[J] += R[J+range]-2; if (R[J+range]&lt;-2) RangeVector[J] += -R[J+range]-2; RangeVector[J]++; IndexVector[index] = J; index++; } } Length = index; } for (long counter=0;counter&lt;N;counter++) { if (R[counter] &lt; 0) { unsigned Value = abs(R[counter]); if (counter+Value&lt;N &amp;&amp; A[counter]&lt;A[counter+Value]) R[counter] = Value; if (counter &gt; Value &amp;&amp; R[counter-Value]==0) R[counter] = 0; R[counter] = Value + R[counter-Value]; if (counter &gt; Value &amp;&amp; Value &lt; R[counter - Value]) { long PossibleSolution = R[counter - Value] + Value; if (PossibleSolution &lt;N &amp;&amp; A[PossibleSolution]&gt;A[ counter]) R[counter] = abs(counter - PossibleSolution); } } } cout&lt;&lt;endl&lt;&lt;"Complex "&lt;&lt;CompxTest; return R; } </code></pre> </div> <table class="fw">

<tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/a/12660739" title="shor t permalink to this answer" class="short-link" id="link-post-12660739">share</a> <span class="lsep">|</span><a href="http://stackoverflow.com/posts/12660739/edit " class="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"> answered <span title="2012-09-30 11:04:3 6Z" class="relativetime">Sep 30 '12 at 11:04</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/1709666/adam"><div class=""> <img src="./codility - how to get ascender element in a array - Stack Overflow_ files/579299e25d63bfc780b5228aaf6480a5" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1709666/adam">Adam</a><br> <span class="reputation-score" title="reputation score" dir="ltr">21 </span><span title="2 bronze badges"><span class="badge3"></span><span class="ba dgecount">2</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr>

<tr> <td class="votecell"></td> <td> <div id="comments-12660739" 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.adzerk.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjI5MTEsImNoIjoxM Tc4LCJjciI6NTkxOSwiZGkiOiIzMjlhMTQ2N2NlNDE0NzlhOTU2NjQxMTYwMDg3Nzk1ZiIsImRtIjoxL CJmYyI6MTAxODQsImZsIjo3NDcyLCJrdyI6ImFycmF5cyxjb2RpbGl0eSIsIm53IjoyMiwicmYiOiJod HRwOi8vc3RhY2tvdmVyZmxvdy5jb20vdGFncy9jb2RpbGl0eS9ob3QiLCJydiI6MCwicHIiOjE2MDQsI nN0Ijo4Mjc3LCJ6biI6NDQsInVyIjoiaHR0cDovL2NhcmVlcnMuc3RhY2tvdmVyZmxvdy5jb20vIn0&s =aCOjoX3VTCmzSyjTskInYOKLp5M" rel="nofollow" target="_blank" title=""><img src=" ./codility - how to get ascender element in a array - Stack Overflow_files/4c4f 1be011a447efbce49c1811022e7a.png" title="" alt="" border="0" width="728" height= "90"></a><div class="adzerk-vote-controls" style="display:none;"><div class="adz erk-vote-option adzerk-vote-up"><div class="adzerk-vote-icon"></div></div><div c lass="adzerk-vote-option adzerk-vote-down"><div class="adzerk-vote-icon"></div>< /div></div><div class="adzerk-vote-survey" style="display:none;"><form><span>No problem. We won't show you that ad again. Why didn't you like it?</span><ul><li> <label><input type="radio" value="12" name="downvoteReason">Uninteresting</label ></li><li><label><input type="radio" value="13" name="downvoteReason">Misleading </label></li><li><label><input type="radio" value="14" name="downvoteReason">Off ensive</label></li><li><label><input type="radio" value="15" name="downvoteReaso n">Repetitive</label></li></ul><a href="http://stackoverflow.com/questions/95961 48/how-to-get-ascender-element-in-a-array/12660739#" class="adzerk-vote-cancel"> Oops! I didn't mean to do this.</a></form></div><img height="0px" width="0px" bo rder="0" src="./codility - how to get ascender element in a array - Stack Overf low_files/i(1).gif"></div>

<a name="10728839"></a> <div id="answer-10728839" class="answer" data-answerid="10728839"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="10728839"> <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><code>// // C++ using multimap. -- INCOMPLETE // The multimap MM is effectively the "inverse" of the input array AA

// since it is ordered by pair(value, index), where index refers to the index in // input array AA, and value is the value in AA at that index. // Input AA is of course ordered as (index, value). // So when we read out of MM in value order, (a sorted set of values), each valu e // is mapped to the index in the original array AA. // int ascender(int AA[], int N, int RR[]) { multimap&lt;int, int&gt; MM; // simply place the AA array into the multimap int i; for (i = 0; i &lt; N; i++) { int value = AA[i]; int index = i; MM.insert(make_pair(value, index)); } // // // // // // simply read the multimap in order, and set output RR as the distance from one value's original index to the next value's original index. THIS code is incomplete, since it is wrong for duplicate values.

multimap&lt;int, int&gt;::iterator pos; for (pos = MM.begin(); pos != MM.end(); ++pos) { int value = pos-&gt;first; int index = pos-&gt;second; ++pos;//temporarily move ahead to next item // NEED to FURTHER CONSIDER repeat values in setting RR RR[index] = (pos)-&gt;second - index; --pos; } return 1; } </code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/a/10728839" title="shor t permalink to this answer" class="short-link" id="link-post-10728839">share</a> <span class="lsep">|</span><a href="http://stackoverflow.com/posts/10728839/edit " class="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"> answered <span title="2012-05-23 22:38:0 9Z" class="relativetime">May 23 '12 at 22:38</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/1406106/chris-c-napier"><div class=""><img src="./codility - how to get ascender element in a array - Stack Overflow_files/594446289b77d7d35397e370b45a7a40" alt="" width="32" height="32"> </div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1406106/chris-c-napier">Chri s C Napier</a><br> <span class="reputation-score" title="reputation score" dir="ltr">21 </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>

<tr> <td class="votecell"></td> <td> <div id="comments-10728839" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="9596186"></a> <div id="answer-9596186" class="answer" data-answerid="9596186"> <table> <tbody><tr> <td class="votecell">

<div class="vote"> <input type="hidden" value="9596186"> <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"><pre><code> 1. Sort the array (if not pre-sort ed) 2. Subtract every element with its adjacent element and store result in another array. Example: 1 3 5 6 8 -----&gt; (after subtraction) 2 2 1 2 3. Find the minimal element in the new array. 4. Device a logic which would relate the minimal element in the new arra y to the two elements in the original one. </code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/a/9596186" title="short permalink to this answer" class="short-link" id="link-post-9596186">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.com/posts/9596186/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="2012-03-07 05:12:2 6Z" class="relativetime">Mar 7 '12 at 5:12</span> </div> <div class="user-gravatar32">

<a href="http://stackoverflow.com/users/1026764/nomad"><div class="" ><img src="./codility - how to get ascender element in a array - Stack Overflow _files/0fb18252a50d4490a6e330025f3299dd" alt="" width="32" height="32"></div></a > </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1026764/nomad">noMAD</a><br> <span class="reputation-score" title="reputation score" dir="ltr">1, 887</span><span title="8 silver badges"><span class="badge2"></span><span class= "badgecount">8</span></span><span title="30 bronze badges"><span class="badge3"> </span><span class="badgecount">30</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr>

<tr> <td class="votecell"></td> <td> <div id="comments-9596186" class="comments"> <table> <tbody> <tr id="comment-12198740" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">Write a functio n: class Solution { public int[] array_closest_ascenders(int[] A); } that, given a zero-indexed array A of N integers, returns a zero-indexed arr ay R of N integers, such that (for K = 0,..., N-1): if K has the closest ascender J, then R[K] = abs(K-J); that is, R[K] is equa l to the distance between J and K, if K has no ascenders then R[K] = 0.</span> &nbsp;<a href="http://stackoverflow .com/users/1099060/ticktack" title="16 reputation" class="comment-user owner">ti cktack</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="ht tp://stackoverflow.com/questions/9596148/how-to-get-ascender-element-in-a-array/ 12660739#comment12198740_9596186"><span title="2012-03-08 07:30:15Z" class="rela tivetime-clean">Mar 8 '12 at 7:30</span></a></span></div></td> </tr> <tr id="comment-12198809" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">Write a functio n: class Solution { public int[] array_closest_ascenders(int[] A); } that, given a zero-indexed array A of N integers, returns a zero-indexed arr ay R of N integers, such that (for K = 0,..., N-1): if K has the closest ascender J, then R[K] = abs(K-J); that is, R[K] is equa l to the distance between J and K, if K has no ascenders then R[K] = 0.</span> &nbsp;<a href="http://stackoverflow .com/users/1099060/ticktack" title="16 reputation" class="comment-user owner">ti cktack</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="ht tp://stackoverflow.com/questions/9596148/how-to-get-ascender-element-in-a-array/ 12660739#comment12198809_9596186"><span title="2012-03-08 07:36:15Z" class="rela

tivetime-clean">Mar 8 '12 at 7:36</span></a></span></div></td> </tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="9664296"></a> <div id="answer-9664296" class="answer" data-answerid="9664296"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="9664296"> <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"><pre><code>public class Solution { final static int MAX_INTEGER = 2147483647; public static int maximal(int[] A) { int max = A[0]; int length = A.length; for (int i = 1; i &lt; length; i++) { if (A[i] &gt; max) { max = A[i]; } } return max; } public static int ascender(int[] a,int length, int k) { int smallest = MAX_INTEGER; int index = 0; if (k&lt;0 || k&gt;length-1) { return -1; } for (int i = 0; i &lt; length; i++) { // Index J is called an ascender of K if A[J] &gt; A[K]. if(a[i] &gt; a[k]) { int abs = Math.abs(i-k);

if ( abs &lt; smallest) { smallest = abs; index = i; } } } return index; } public static int[] array_closest_ascenders(int[] A) { int length = A.length; int[] R = new int[length]; for (int K = 0; K &lt; length; K++) { // Note that if A[K] is a maximal value in the array A, // then K has no ascenders. // if K has no ascenders then R[K] = 0. if (A[K] == maximal(A)) { R[K] = 0; break; } // if K has the closest ascender J, then R[K] = abs(K-J); // that is, R[K] is equal to the distance between J and K int J = ascender(A, A.length, K); if (J != -1) { R[K] = Math.abs(K - J); } } return R; } public static void main(String[] args) { int[] a = { 4, 3, 1, 4, -1, 2, 1, 5, 7 }; /* int[] a = {-589630174, 806785750, -495838474, -648898313, 149290786, -798171892, 584782920, -288181260, -252589640, 133741336, -174886978, -897913872 }; */ int[] R = array_closest_ascenders(a); for (int element : R) { System.out.print(element + " "); } } } </code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/a/9664296" title="short permalink to this answer" class="short-link" id="link-post-9664296">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.com/posts/9664296/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/9664296/revi sions" title="show all edits to this post">edited <span title="2012-03-12 22:17: 33Z" class="relativetime">Mar 12 '12 at 22:17</span></a> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/147463/egrunin"><div class=" "><img src="./codility - how to get ascender element in a array - Stack Overflo w_files/9b001cdbbc7253c67d888bf27c959acc" alt="" width="32" height="32"></div></ a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/147463/egrunin">egrunin</a>< br> <span class="reputation-score" title="reputation score 13689" dir="l tr">13.7k</span><span title="1 gold badge"><span class="badge1"></span><span cla ss="badgecount">1</span></span><span title="13 silver badges"><span class="badge 2"></span><span class="badgecount">13</span></span><span title="53 bronze badges "><span class="badge3"></span><span class="badgecount">53</span></span> </div> </div> </td>

<td align="right" class="post-signature owner">

<div class="user-info "> <div class="user-action-time"> answered <span title="2012-03-12 09:15:0 1Z" class="relativetime">Mar 12 '12 at 9:15</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/1099060/ticktack"><div class =""><img src="./codility - how to get ascender element in a array - Stack Overf low_files/4465a949455a46d05925d20e9b3f3df3" alt="" width="32" height="32"></div> </a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1099060/ticktack">ticktack</

a><br> <span class="reputation-score" title="reputation score" dir="ltr">16 </span><span title="1 silver badge"><span class="badge2"></span><span class="bad gecount">1</span></span><span title="3 bronze badges"><span class="badge3"></spa n><span class="badgecount">3</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr>

<tr> <td class="votecell"></td> <td> <div id="comments-9664296" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="9714420"></a> <div id="answer-9714420" class="answer" data-answerid="9714420"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="9714420"> <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>Some notes about the code. I guess <code>break</co de> in <code>array_closest_ascenders</code> method should be replaced by <code>c ontinue</code> so that all elements are analyzed for their ascenders.<br>

And, surely, <code>maximal(A)</code> have to be moved out of a loop; instead ass ign maximal value to some variable before entering the loop and use it within th e loop, thus avoiding redundant calculation of max value.</p> </div> <table class="fw"> <tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/a/9714420" title="short permalink to this answer" class="short-link" id="link-post-9714420">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.com/posts/9714420/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"> answered <span title="2012-03-15 05:23:5 7Z" class="relativetime">Mar 15 '12 at 5:23</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/486016/bazi"><div class="">< img src="./codility - how to get ascender element in a array - Stack Overflow_f iles/b30eedd72e794008b19f842773529aac" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/486016/bazi">Bazi</a><br> <span class="reputation-score" title="reputation score" dir="ltr">48 </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-9714420" class="comments dno">

<table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="9718749"></a> <div id="answer-9718749" class="answer" data-answerid="9718749"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="9718749"> <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>After Above implementation i got WRONG ANSWER. wil l update code after going in deep. // WRONG ANSWER [ got [1, 0] expected [1, 0, 1, 1, 2, 1, 5.. ]</p> <p>I'm using Direct method for getting maximal and minimal for getting the valu e.</p> <p>Any though ?</p> </div> <table class="fw"> <tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/a/9718749" title="short

permalink to this answer" class="short-link" id="link-post-9718749">share</a><s pan class="lsep">|</span><a href="http://stackoverflow.com/posts/9718749/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"> answered <span title="2012-03-15 11:27:5 7Z" class="relativetime">Mar 15 '12 at 11:27</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/1271395/satya"><div class="" ><img src="./codility - how to get ascender element in a array - Stack Overflow _files/36c1c27bef532969bd756766f59972f1" alt="" width="32" height="32"></div></a > </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1271395/satya">Satya</a><br> <span class="reputation-score" title="reputation score" dir="ltr">1< /span> </div> </div> </td> </tr> </tbody></table> </td> </tr>

<tr> <td class="votecell"></td> <td> <div id="comments-9718749" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="17331291"></a> <div id="answer-17331291" class="answer" data-answerid="17331291">

<table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="17331291"> <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>Here is C# Solution</p> <pre><code> class Program { static void Main(string[] args) { int[] A = new int[] { 4, 3, 1, 4, -1, 2, 1, 5, 7 }; int[] B = new int[A.Length]; int[] R = new int[A.Length]; Program obj = new Program(); obj.ABC(A,B, R); } public void ABC(int[] A,int[]B, int[] R) { int i, j, m,k; // int temp = 0; int n = A.Length - 1; for (i = 0; i &lt; n; i++) { for (j = 0; j &lt;= n; j++) { if (A[i] &lt; A[j]) { m = Math.Abs(j - i); R[i] = m; break; } } for (j = i-1; j &gt; 0; j--) { if (A[i] &lt; A[j]) { k = Math.Abs(j - i); B[i] = k; break; }

} } for (i = 0; i &lt; n; i++) { if (R[i] &gt; B[i] &amp;&amp; (B[i] == 0)) { R[i] = R[i]; //Console.WriteLine(R[i]); //Console.ReadLine(); } else { R[i] = B[i]; } } } } </code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt">

<div class="post-menu"><a href="http://stackoverflow.com/a/17331291" title="shor t permalink to this answer" class="short-link" id="link-post-17331291">share</a> <span class="lsep">|</span><a href="http://stackoverflow.com/posts/17331291/edit " class="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"> answered <span title="2013-06-26 22:05:4 0Z" class="relativetime">Jun 26 at 22:05</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/2521798/user2521798"><div cl ass=""><img src="./codility - how to get ascender element in a array - Stack Ov erflow_files/3ee467a43002dc846b8db4c43d5a5058" alt="" width="32" height="32"></d iv></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/2521798/user2521798">user252

1798</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>

<tr> <td class="votecell"></td> <td> <div id="comments-17331291" 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.com/questions/9596148/answ er/submit" method="post" class="post-form"> <input type="hidden" id="post-id" value="9596148"> <h2 class="space">Your Answer</h2>

<script type="text/javascript"> StackExchange.ready(function() { initTagRenderer("".split(" "), "".split(" ")); prepareEditor({ heartbeatType: 'answer', bindNavPrevention: true, postfix: "", onDemand: true, discardSelector: ".discard-answer" ,immediatelyShowMarkdownHelp:true }); }); </script>

<div id="post-editor" class="post-editor"> <div style="position: relative;"> <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 style="background-position: 0px -20px;"></span></li><li id="wmditalic-button" class="wmd-button" style="left: 25px;"><span style="background-po sition: -20px -20px;"></span></li><li id="wmd-spacer1" class="wmd-spacer" style= "left: 50px;"><span style="background-position: -40px -20px;"></span></li><li id ="wmd-link-button" class="wmd-button" style="left: 75px;"><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: -60px -20px;"></span>< /li><li id="wmd-code-button" class="wmd-button" style="left: 125px;"><span style ="background-position: -80px -20px;"></span></li><li id="wmd-image-button" class ="wmd-button" style="left: 150px;"><span style="background-position: -100px -20p x;"></span></li><li id="wmd-spacer2" class="wmd-spacer" style="left: 175px;"><sp an style="background-position: -120px -20px;"></span></li><li id="wmd-olist-butt on" class="wmd-button" style="left: 200px;"><span style="background-position: -1 20px -20px;"></span></li><li id="wmd-ulist-button" class="wmd-button" style="lef t: 225px;"><span style="background-position: -140px -20px;"></span></li><li id=" wmd-heading-button" class="wmd-button" style="left: 250px;"><span style="backgro und-position: -160px -20px;"></span></li><li id="wmd-hr-button" class="wmd-butto n" style="left: 275px;"><span style="background-position: -180px -20px;"></span> </li><li id="wmd-spacer3" class="wmd-spacer" style="left: 300px;"><span style="b ackground-position: -200px -20px;"></span></li><li id="wmd-undo-button" class="w md-button" style="left: 325px;"><span style="background-position: -200px -20px;" ></span></li><li id="wmd-redo-button" class="wmd-button" style="left: 350px;"><s pan style="background-position: -220px -20px;"></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; height:24px;">&nbsp;</div> <div id="draft-saved" class="draft-saved community-option fl" style="margintop: 8px; height:24px; display:none;">draft saved</div> <div id="draft-discarded" class="draft-discarded community-option fl" style= "margin-top: 8px; height:24px; display:none;">draft discarded</div>

<div id="wmd-preview" class="wmd-preview"></div> <div></div> <div class="edit-block"> <input id="fkey" name="fkey" type="hidden" value="9336b12e86af343415687d 9e813eec5f"> <input id="author" name="author" type="text"> </div> </div> <div style="position: relative;"> <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.com/users/login?returnurl=%2fquestions%2f9596148%2fhow-to-get-ascender-elem ent-in-a-array%23new-answer">log in</a></h3> <script type="text/javascript">

StackExchange.ready(function () { StackExchange.helpers.onClickDraftSave('#login-l ink'); }); </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.bindHelpOverlayEvents($('.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, but not shown</sp an> </div> </td> </tr> </tbody></table> </div> </div> </div> </div> <script type="text/javascript"> StackExchange.ready( function () { StackExchange.openid.initPostLogin('.new-post-login', '% 2fquestions%2f9596148%2fhow-to-get-ascender-element-in-a-array%23new-answer');

} ); </script> <noscript> &lt;h3&gt;Post as a guest&lt;/h3&gt; &lt;div class="form-item"&gt; &lt;table&gt; &lt;tr&gt; &lt;script type="text/javascript"&gt; StackExchange.ready(function () { StackExchange.helpers.bindHelpOverlayEvents($('.vm input')); }); &lt;/script&gt; &lt;td class="vm"&gt; &lt;div&gt; &lt;label for="display-name"&gt;Name&lt;/label&gt; &lt;input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105"&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="m-address"&gt;Email&lt;/label&gt; &lt;input id="m-address" name="m-address" type="text" size=" 30" maxlength="100" value="" tabindex="106"&gt; &lt;span class="edit-field-overlay"&gt;required, but not sho wn&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </noscript> </div> <div class="form-submit cbt"> <input id="submit-button" type="submit" value="Post Your Answer" tab index="110"> <a href="http://stackoverflow.com/questions/9596148/how-to-get-ascen der-element-in-a-array/12660739#" class="discard-answer dno">discard</a> <p class="privacy-policy-agreement"> By posting your answer, you agree to the <a href="http://stackexchange.com/legal/privacy-policy" target="_blank"> privacy policy</a> and <a href="http://stackexchange.com/legal/terms-of-service" target="_blank ">terms of service</a>. </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.com/ques tions/tagged/arrays" class="post-tag" title="show questions tagged &#39;arrays&# 39;" rel="tag">arrays</a> <a href="http://stackoverflow.com/questions/tagged/cod ility" class="post-tag" title="show questions tagged &#39;codility&#39;" rel="ta g">codility</a> or <a href="http://stackoverflow.com/questions/ask">ask your own

question</a>. </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.com/questions/tagged/a rrays" class="post-tag" title="show questions tagged &#39;arrays&#39;" rel="tag" >arrays</a>&nbsp;<span class="item-multiplier"><span class="item-multiplier-x"> </s pan>&nbsp;<span class="item-multiplier-count">55477</span></span><br> <a href="http://stackoverflow.com/questions/tagged/codility" class="post-tag" ti tle="show questions tagged &#39;codility&#39;" rel="tag">codility</a>&nbsp;<span class="item-multiplier"><span class="item-multiplier-x"> </span>&nbsp;<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="2012-0 3-07 05:06:57Z"><b>1 year ago</b></p></td> </tr> <tr> <td><p class="label-key">viewed</p></td> <td style="padding-left:10px"> <p class="label-key"> <b>2688 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 ttp://stackoverflow.com/questions/9596148/how-to-get-ascender-element-in-a-array /12660739?lastactivity" class="lastactivity-link" title="2013-06-26 22:05:40Z">5 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.stackoverflow.c om/?cb=1" class="event-date" target="_blank">blog</a></div> <div class="bulletin-item-content"> <a href="http://blog.stackoverflow.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.adzerk.net/z/8277/adzerk1_2_4 _43,adzerk2_2_17_45,adzerk3_2_4_44?keywords=arrays,codility"; if (document.referrer) {

if (/\?/.test(scriptSrc)) scriptSrc += "&"; else scriptSrc += "?"; scriptSrc += "xReferrer=" + document.referrer; } StackExchange.ready(function() { var z = document.createElement("script"); z.type = "text/javascript"; z.async = "true"; z.src = scriptSrc; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s); }); </script> <div id="hireme"> <a href="http://careers.stackoverflow.com/jobs?a=24" class ="top" target="_blank"></a> <ul class="jobs"> <li> <a href="http://careers.stack overflow.com/jobs/32969/ruby-developer-idyllic-software?a=CX4Dz3i" target="_blan k" title="Ruby Developer at Idyllic Software. Click to learn more."> Ruby Develo per<br> <span class="company">Idyllic Software</span> <span class="location">Mum bai, India</span> </a> </li> <li> <a href="http://careers.stackoverflow.com/jobs /35816/senior-software-developer-building-scalable-e-lenskart-com?a=GjCFFzG" tar get="_blank" title="Senior Software Developer - building scalable e-solutions at lenskart.com. Click to learn more."> Senior Software Developer - building scala ble e-solutions<br> <span class="company">lenskart.com</span> <span class="locat ion">New Delhi, India / relocation</span> </a> </li> <li> <a href="http://career s.stackoverflow.com/jobs/36379/expert-php-developer-idyllic-software?a=GYRE1Pi" target="_blank" title="Expert PHP Developer at Idyllic Software. Click to learn more."> Expert PHP Developer<br> <span class="company">Idyllic Software</span> < span class="location">Mumbai, India</span> </a> </li> <li> <a href="http://caree rs.stackoverflow.com/jobs/34545/worship-worthy-frontend-developer-wanted-idyllic -software?a=EOwfwnC" target="_blank" title="Worship-worthy Frontend Developer Wa nted! Javascript // Html // CSS at Idyllic Software. Click to learn more."> Wors hip-worthy Frontend Developer Wanted! Javascript // <br> <span class="company">Idyll ic Software</span> <span class="location">Pune, India</span> </a> </li> <li> <a href="http://careers.stackoverflow.com/jobs/35537/software-development-engineeramazon?a=FZapUpq" target="_blank" title="Software Development Engineer at Amazon . Click to learn more."> Software Development Engineer<br> <span class="company" >Amazon</span> <span class="location">Irvine, CA / relocation</span> </a> </li> <li> <a href="http://careers.stackoverflow.com/jobs/35456/mobile-web-developer-c afepress?a=FTexLPO" target="_blank" title="Mobile Web Developer at CafePress. Cl ick to learn more."> Mobile Web Developer<br> <span class="company">CafePress</s pan> <span class="location">San Mateo, CA</span> </a> </li> </ul> <img alt="" cl ass="impression" src="./codility - how to get ascender element in a array - Sta ck Overflow_files/CX4Dz3i-GjCFFzG-GYRE1Pi-EOwfwnC-FZapUpq-FTexLPO-24" style="dis play:none"></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/q/337664?rq=1" title="Vote score (upvotes - do wnvotes)"> <div class="answer-votes answered-accepted default">21</div> </a>

<a href="http://stackoverflow.com/questions/337664/counting-inversions-in-an-arr ay?rq=1" class="question-hyperlink">Counting inversions in an array</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/369602?rq=1" title="Vote score (upvotes - do wnvotes)"> <div class="answer-votes answered-accepted large">301</div> </a> <a href="http://stackoverflow.com/questions/369602/how-to-delete-an-element-from -an-array-in-php?rq=1" class="question-hyperlink">How to delete an element from an array in php?</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/500606?rq=1" title="Vote score (upvotes - do wnvotes)"> <div class="answer-votes answered-accepted large">410</div> </a> <a href="http://stackoverflow.com/questions/500606/javascript-array-delete-eleme nts?rq=1" class="question-hyperlink">JavaScript Array Delete Elements</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/1921421?rq=1" title="Vote score (upvotes - d ownvotes)"> <div class="answer-votes answered-accepted large">140</div> </a> <a href="http://stackoverflow.com/questions/1921421/get-first-element-of-an-arra y?rq=1" class="question-hyperlink">Get first element of an array</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/8623924?rq=1" title="Vote score (upvotes - d ownvotes)"> <div class="answer-votes default">0</div> </a> <a href="http://stackoverflow.com/questions/8623924/dictionary-runtime-codilitytest?rq=1" class="question-hyperlink">Dictionary runtime (Codility Test)</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/8624083?rq=1" title="Vote score (upvotes - 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.com/q/9647935?rq=1" title="Vote score (upvotes - d ownvotes)"> <div class="answer-votes answered-accepted default">3</div> </a> <a href="http://stackoverflow.com/questions/9647935/how-to-make-the-execution-ti me-on-from-on2?rq=1" class="question-hyperlink">How to make the execution time O (N) from O(N^2)</a> </div> <div class="spacer"> <a href="http://stackoverflow.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/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.com/q/14307760?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes default">0</div> </a> <a href="http://stackoverflow.com/questions/14307760/ascending-integers-in-txt-t o-array?rq=1" class="question-hyperlink">Ascending Integers in TXT to Array</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/16953803?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes default">0</div> </a> <a href="http://stackoverflow.com/questions/16953803/codility-certification-june -2013?rq=1" class="question-hyperlink">codility certification june 2013</a> </div> </div> </div> </div> <div id="feed-link"> <div id="feed-link-text"><a href="http://stackoverflow.com/feeds/question/95 96148" title="feed of this question and its answers"><span class="feed-icon"></s pan>question feed</a></div> </div> <script type="text/javascript"> StackExchange.ready(function(){$.get('/posts/9596148/ivc/7ea7');}); </script> <noscript> &lt;div&gt;&lt;img src="/posts/9596148/ivc/7ea7" class="dno" alt="" width="0 " height="0"&gt;&lt;/div&gt; </noscript><div style="display:none" id="prettify-lang"></div></div> </div> </div> <div id="footer" class="categories"> <div class="footerwrap"> <div id="footer-menu"> <div class="top-footer-links"> <a href="http://stackoverflow.com/about">about</a> <a href="http://stackoverflow.com/help">help</a> <a href="http://stackoverflow.com/help/badges">badges</a > <a href="http://blog.stackexchange.com/?blb=1">blog</a> <a href="http://chat.stackoverflow.com/">chat</a> <a href="http://data.stackexchange.com/">data</a> <a href="http://stackexchange.com/legal">legal</a> <a href="http://stackexchange.com/legal/privacy-policy">priv acy policy</a> <a href="http://stackexchange.com/about/hiring">jobs</a> <a href="http://engine.adzerk.net/redirect/0/2776/2751/0/4de 3c60f719c4dfcb1a57531c7050090/0">advertising info</a> <a onclick="StackExchange.switchMobile(&quot;on&quot;, &quot ;/questions/9596148/how-to-get-ascender-element-in-a-array/12660739&quot;)">mobi

le</a> <b><a href="http://stackoverflow.com/contact">contact us</a> </b> <b><a href="http://meta.stackoverflow.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="professio nal and enthusiast programmers">Stack Overflow</a></li> <li><a href="http://serverfault.com/" title="professiona l system and network administrators">Server Fault</a></li> <li><a href="http://superuser.com/" title="computer enth usiasts and power users">Super User</a></li> <li><a href="http://webapps.stackexchange.com/" title="p ower users of web applications">Web Applications</a></li> <li><a href="http://askubuntu.com/" title="Ubuntu users and developers">Ask Ubuntu</a></li> <li><a href="http://webmasters.stackexchange.com/" title ="pro webmasters">Webmasters</a></li> <li><a href="http://gamedev.stackexchange.com/" title="p rofessional and independent game developers">Game Development</a></li> <li><a href="http://tex.stackexchange.com/" title="users of TeX, LaTeX, ConTeXt, and related typesetting systems">TeX - LaTeX</a></li> </ol></td><td><ol> <li><a href="http://programmers.stackexchange.com/" titl e="professional programmers interested in conceptual questions about software de velopment">Programmers</a></li> <li><a href="http://unix.stackexchange.com/" title="user s of Linux, FreeBSD and other Un*x-like operating systems.">Unix &amp; Linux</a> </li> <li><a href="http://apple.stackexchange.com/" title="pow er users of Apple hardware and software">Ask Different (Apple)</a></li> <li><a href="http://wordpress.stackexchange.com/" title= "WordPress developers and administrators">WordPress Answers</a></li> <li><a href="http://gis.stackexchange.com/" title="carto graphers, geographers and GIS professionals">Geographic Information Systems</a>< /li> <li><a href="http://electronics.stackexchange.com/" titl e="electronics and electrical engineering professionals, students, and enthusias

ts">Electrical Engineering</a></li> <li><a href="http://android.stackexchange.com/" title="e nthusiasts and power users of the Android operating system">Android Enthusiasts< /a></li> <li><a href="http://security.stackexchange.com/" title=" IT security professionals">IT Security</a></li> </ol></td><td><ol> <li><a href="http://dba.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.stackexchange.com/" title="Dr upal developers and administrators">Drupal Answers</a></li> <li><a href="http://sharepoint.stackexchange.com/" title ="SharePoint enthusiasts">SharePoint</a></li> <li><a href="http://ux.stackexchange.com/" title="user e xperience researchers and experts">User Experience</a></li> <li><a href="http://mathematica.stackexchange.com/" titl e="users of Mathematica">Mathematica</a></li> <li> <a href="http://stackexchange.com/sites#technology" class="more"> more (13) </a> </li> </ol> </td> <td> <ol> <li><a href="http://photo.stackexchange.com/" title="pro fessional, enthusiast and amateur photographers">Photography</a></li> <li><a href="http://scifi.stackexchange.com/" title="sci ence fiction and fantasy enthusiasts">Science Fiction &amp; Fantasy</a></li> <li><a href="http://cooking.stackexchange.com/" title="p rofessional and amateur chefs">Seasoned Advice (cooking)</a></li> <li><a href="http://diy.stackexchange.com/" title="contr actors and serious DIYers">Home Improvement</a></li> <li> <a href="http://stackexchange.com/sites#lifearts" cl ass="more"> more (13) </a> </li> </ol> </td> <td> <ol> <li><a href="http://english.stackexchange.com/" title="l inguists, etymologists, and serious English language enthusiasts">English Langua ge &amp; Usage</a></li> <li><a href="http://skeptics.stackexchange.com/" title=" scientific skepticism">Skeptics</a></li> <li><a href="http://judaism.stackexchange.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="ro ad warriors and seasoned travelers">Travel</a></li> <li><a href="http://christianity.stackexchange.com/" tit le="committed Christians, experts in Christianity and those interested in learni

ng more">Christianity</a></li> <li><a href="http://gaming.stackexchange.com/" title="pa ssionate videogamers on all platforms">Arqade (gaming)</a></li> <li><a href="http://bicycles.stackexchange.com/" title=" people who build and repair bicycles, people who train cycling, or commute on bi cycles">Bicycles</a></li> <li><a href="http://rpg.stackexchange.com/" title="gamem asters and players of tabletop, paper-and-pencil role-playing games">Role-playin g Games</a></li> <li> <a href="http://stackexchange.com/sites#culturerecre ation" class="more"> more (21) </a> </li> </ol> </td> <td> <ol> <li><a href="http://math.stackexchange.com/" title="peop le studying math at any level and professionals in related fields">Mathematics</ a></li> <li><a href="http://stats.stackexchange.com/" title="sta tisticians, data analysts, data miners and data visualization experts">Cross Val idated (stats)</a></li> <li><a href="http://cstheory.stackexchange.com/" title=" theoretical computer scientists and researchers in related fields">Theoretical C omputer Science</a></li> <li><a href="http://physics.stackexchange.com/" title="a ctive researchers, academics and students of physics">Physics</a></li> <li><a href="http://mathoverflow.net/" title="mathematic ians">MathOverflow</a></li> <li> <a href="http://stackexchange.com/sites#science" cla ss="more"> more (7) </a> </li> </ol> </td> <td> <ol> <li><a href="http://stackapps.com/" title="apps, scripts , and development with the Stack Exchange API">Stack Apps</a></li> <li><a href="http://meta.stackoverflow.com/" title="meta -discussion of the Stack Exchange family of Q&amp;A websites">Meta Stack Overflo w</a></li> <li><a href="http://area51.stackexchange.com/" title="pr oposing new sites in the Stack Exchange network">Area 51</a></li> <li><a href="http://careers.stackoverflow.com/">Stack Ov erflow Careers</a></li> </ol> </td> </tr> </tbody></table> </div> </div>

<div id="copyright"> site design / logo 2013 stack exchange inc; user contributions licensed under <a href="http://creativecommon s.org/licenses/by-sa/3.0/" rel="license">cc-wiki</a> with <a href="http://blog.stackoverflow.com/2009/06/attributionrequired/" rel="license">attribution required</a> </div> <div id="footer-flair"> <a href="http://creativecommons.org/licenses/by-sa/3.0/" class=" cc-wiki-link"></a> </div> <div id="svnrev"> rev 2013.7.1.798 </div> </div> </div> <noscript> &lt;div id="noscript-warning"&gt;Stack Overflow works best with JavaScri pt enabled&lt;img src="http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" al t="" class="dno"&gt;&lt;/div&gt; </noscript> <script type="text/javascript">var _gaq=_gaq||[];_gaq.push(['_setAccount','U A-5620270-1']); _gaq.push(['_setCustomVar', 1, 'tags', '|arrays|codility|']); _gaq.push(['_trackPageview']); var _qevents = _qevents || []; (function(){ var s=document.getElementsByTagName('script')[0]; var ga=document.createElement('script'); ga.type='text/javascript'; ga.async=true; ga.src='http://www.google-analytics.com/ga.js'; s.parentNode.insertBefore(ga,s); var sc=document.createElement('script'); sc.type='text/javascript'; sc.async=true; sc.src='http://edge.quantserve.com/quant.js'; s.parentNode.insertBefore(sc,s); })(); </script> <script type="text/javascript"> _qevents.push({ qacct: "p-c1rF4kxgLUzNc" }); </script> </body></html>

You might also like