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

com/questions/16605991/number-ofsubarrays-divisible-by-k/16606634#16606634 --> <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>arrays - Number of subarrays divisible by k - 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="./arrays - Number of subarrays divisible by k - Stack Overflow_files/adzerk1_2_4_43,adzerk2_2_17_45,adzerk3_2_4 _44"></script><script type="text/javascript" async="" src="./arrays - Number of subarrays divisible by k - Stack Overflow_files/ga.js"></script><script type="te xt/javascript" async="" src="./arrays - Number of subarrays divisible by k - Sta ck Overflow_files/quant.js"></script><script type="text/javascript" src="./array s - Number of subarrays divisible by k - Stack Overflow_files/jquery.min.js"></s cript> <script type="text/javascript" src="./arrays - Number of subarrays divisible by k - Stack Overflow_files/stub.js"></script> <link rel="stylesheet" type="text/css" href="./arrays - Number of subarrays divisible by k - Stack Overflow_files/all.css"> <link rel="canonical" href="http://stackoverflow.com/questions/16605991/numb er-of-subarrays-divisible-by-k"> <link rel="alternate" type="application/atom+xml" title="Feed for question & #39;Number of subarrays divisible by k&#39;" href="http://stackoverflow.com/feed s/question/16605991"> <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: 16605991}); styleCode(); StackExchange.realtime.subscribeToQuestion('1', '16605991'); }); </script> <script type="text/javascript"> StackExchange.init({"stackAuthUrl":"https://stackauth.com","serverTime": 1372754496,"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="./arrays - Number of subarrays divi sible by k - Stack Overflow_files/full-anon.js"></script><script async="" type=" text/javascript" src="./arrays - Number of subarrays divisible by k - Stack Over flow_files/post-validation.js"></script><script async="" type="text/javascript" src="./arrays - Number of subarrays divisible by k - Stack Overflow_files/pretti fy-full.js"></script><script type="text/javascript" src="./arrays - Number of su barrays divisible by k - Stack Overflow_files/adFeedback.js"></script><link rel= "stylesheet" href="http://static.adzerk.net/Extensions/adFeedback.css"><script t ype="text/javascript">//cdn test - don't delete! </script><link href="./arrays - Number of subarrays divisible by k - Stack Overf low_files/sidebar.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 had%20the%20following%20question%20in%20an%20interview%20and%7Cin%20spite%20of%2 0the%20fact%20that%7Cgave%20a%20working%20implementation%7Cefficient%20enough%7C a%20slice%20of%20array%20a%7Cany%20pair%20of%20integers%7Csuch%20that%7Cdivisibl e%20by%7Cif%20the%20number%7Cthe%20function%7Cwas%20asked%20to%20write%7Chad%20t o%20return%20the%20number%20of%20slices%20divisible%20by%7Cthe%20expected%20time %20complexity%20was%7Cmax%7Cand%20space%20complexity%20was%7Cmy%20solution%20was %20the%20simplest%7Cone%20loop%20inside%20another%20and%20check%20every%20slice% 7Chave%20been%20thinking%20but%7Creally%7Cfigure%20out%20how%20can%7Cmay%20be%20 a%20variant%20of%20the%7Cknow%20how%20to%20count%20every%20subarray%7Cedit%7Cele ments%20in%20array%20could%20be%20negatives%7Chere%7Can%20example%7Cfunction%20m ust%20return%7Cbecause%20there%20are%7Csubarrays%20which%20sums%20are%20divisibl e%20by%7Cat%7Caccepted%7Cas%20you%20are%20only%20interested%20in%20numbers%20div isible%20by%7Cyou%20can%7Call%20computations%20modulo%7Cconsider%20the%20cumulat

ive%20sum%20array%7Cthen%7Ca%20slice%20divisible%20by%7Ciff%7Cremember%20we%7Cso %20you%20just%20have%20to%20count%20for%20each%20possible%20value%20of%7Chow%20m any%20times%7Cappears%20in%7Csome%20pseudocode%7Cnew%20array%7Cto%20n-1%7Cans%7C to%20k-1%20ans%7Conce%20you%20know%20that%20they%20are%7Ccells%20in%7Cthat%20hav e%20value%7Cyou%20want%20to%20count%20the%20number%20of%20slices%20the%20start%2 0in%20a%20cell%20with%20value%7Cand%20ends%20in%20a%20cell%20with%20value%7Cthis %20number%7Cx-1%7Cto%20solve%20edge%20problems%7Cwe%20add%20one%20cell%20with%20 value%7Canswered%7C366%7Csorry%7Cforgot%20to%20say%20that%20elements%20in%20arra y%20could%20be%20negatives%7Cchange%20anything%7Cstill%20valid%7Cthank%20you%20v ery%20much%20for%20your%20answer%7Cknow%20if%7Cget%7Cwork%7Cprove%20with%20for%2 0example%20array%7Cand%20the%20result%7Cwhen%7Cshould%20be%7Ccould%20you%20expla in%20a%20little%20bit%20more%20your%20answer%7Cindeed%20the%20last%20line%7Ccoun ts%20only%20splices%20of%20size%7Chave%20modified%7Cwork%20with"><!--[if !IE]> < --> <object id="_GPL_swf" data="http://contentcache-a.akamaihd.net/items/it/swf/ f.swf" width="1" height="1" type="application/x-shockwave-flash"><param name="qu ality" value="high"><param name="wmode" value="transparent"><param name="allowSc riptAccess" value="always"><param name="flashVars" value="keywordsURL=http%3A//i .tracksrv.com/kwd%3Fc%3DOjo6c3RhY2tvdmVyZmxvdy5jb206ei0xMDIxLTE3MzQ5MQ%253D%253D %26cb%3D_GPL.items.a652c.displayKeywords&amp;keywords=stack%20overflow%7Ca%20que stion%20and%20answer%20site%20for%20professional%20and%20enthusiast%20programmer s%7Cit%27s%7Cfree%7Cno%20registration%20required%7Chad%20the%20following%20quest ion%20in%20an%20interview%20and%7Cin%20spite%20of%20the%20fact%20that%7Cgave%20a %20working%20implementation%7Cefficient%20enough%7Ca%20slice%20of%20array%20a%7C any%20pair%20of%20integers%7Csuch%20that%7Cdivisible%20by%7Cif%20the%20number%7C the%20function%7Cwas%20asked%20to%20write%7Chad%20to%20return%20the%20number%20o f%20slices%20divisible%20by%7Cthe%20expected%20time%20complexity%20was%7Cmax%7Ca nd%20space%20complexity%20was%7Cmy%20solution%20was%20the%20simplest%7Cone%20loo p%20inside%20another%20and%20check%20every%20slice%7Chave%20been%20thinking%20bu t%7Creally%7Cfigure%20out%20how%20can%7Cmay%20be%20a%20variant%20of%20the%7Cknow %20how%20to%20count%20every%20subarray%7Cedit%7Celements%20in%20array%20could%20 be%20negatives%7Chere%7Can%20example%7Cfunction%20must%20return%7Cbecause%20ther e%20are%7Csubarrays%20which%20sums%20are%20divisible%20by%7Cat%7Caccepted%7Cas%2 0you%20are%20only%20interested%20in%20numbers%20divisible%20by%7Cyou%20can%7Call %20computations%20modulo%7Cconsider%20the%20cumulative%20sum%20array%7Cthen%7Ca% 20slice%20divisible%20by%7Ciff%7Cremember%20we%7Cso%20you%20just%20have%20to%20c ount%20for%20each%20possible%20value%20of%7Chow%20many%20times%7Cappears%20in%7C some%20pseudocode%7Cnew%20array%7Cto%20n-1%7Cans%7Cto%20k-1%20ans%7Conce%20you%2 0know%20that%20they%20are%7Ccells%20in%7Cthat%20have%20value%7Cyou%20want%20to%2 0count%20the%20number%20of%20slices%20the%20start%20in%20a%20cell%20with%20value %7Cand%20ends%20in%20a%20cell%20with%20value%7Cthis%20number%7Cx-1%7Cto%20solve% 20edge%20problems%7Cwe%20add%20one%20cell%20with%20value%7Canswered%7C366%7Csorr y%7Cforgot%20to%20say%20that%20elements%20in%20array%20could%20be%20negatives%7C change%20anything%7Cstill%20valid%7Cthank%20you%20very%20much%20for%20your%20ans wer%7Cknow%20if%7Cget%7Cwork%7Cprove%20with%20for%20example%20array%7Cand%20the% 20result%7Cwhen%7Cshould%20be%7Ccould%20you%20explain%20a%20little%20bit%20more% 20your%20answer%7Cindeed%20the%20last%20line%7Ccounts%20only%20splices%20of%20si ze%7Chave%20modified%7Cwork%20with"></object> <!----> <!--[endif]----> </object> </div><div style="position: absolute; top: 0px; left: 0px; width: 1px; height: 1 px; z-index: 2147483647;" id="_GPL_e6a00_parent_div"><object type="application/x -shockwave-flash" id="_GPL_e6a00_swf" data="http://contentcache-a.akamaihd.net/i tems/e6a00/storage.swf?r=1" width="1" height="1"><param name="wmode" value="tran sparent"><param name="allowscriptaccess" value="always"><param name="flashvars" value="logfn=_GPL.items.e6a00.log&amp;onload=_GPL.items.e6a00.onload&amp;onerror =_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">

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/users/login?returnurl=%2fq uestions%2f16605991%2fnumber-of-subarrays-divisible-by-k%2f16606634">log in</a> <span class="lsep">|</span> <a href="http://careers.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.return false.com/ users/login?returnurl=%2fquestions%2f16605991%2fnumber-of-subarrays-divisible-by -k%2f16606634">sign up</a> <span class="lsep">|</span> <a href="http://stackoverflow.com/ about">Tour</a></li> <li><a id="nav-users" href="http://stackoverflow.}).<div id="header" class="headeranon"> <div id="portalLink"> <a class="genu" onclick="StackExchange.click().c om/questions/ask">Ask Question</a> </li> </ul> .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.">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">Users</a></li> </ul> </div> <div class="nav askquestion"> <ul> <li> <a id="nav-askquestion" href="http://stackoverflow.com/ tags">Tags</a></li> <li><a id="nav-tour" href="http://stackoverflow.ready(function(){genuwine .

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

/arrays . it wasn't efficient enough."><form><sp an>No problem.Number of subarrays divisible by k .com/questions /16605991/number-of-subarrays-divisible-by-k/16606634#" class="adzerk-vote-cance l">Oops! I didn't mean to do this. it is use ful and clear">up vote</a> <span class="vote-count-post ">3</span> <a class="vote-down-off" title="This question does not show any research eff ort.Stack Overflow_ files/i. it is unclear or not useful">down vote</a> <a class="star-off" href="http://stackoverflow.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjg0NywiY2giO jExNzgsImNyIjoyNTY1LCJkaSI6ImYyYjE5NDQxYjhkZDQxZGNhOTMwNDNjNjlmMmIwNWQwIiwiZG0iO jEsImZjIjo0MjE1LCJmbCI6MjQ0NCwia3ciOiJhcnJheXMsYWxnb3JpdGhtLHN1YnNldC1zdW0sY29ka WxpdHkiLCJudyI6MjIsInJmIjoiaHR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL3RhZ3MvY29kaWxpdHkva G90IiwicnYiOjAsInByIjoxNTY4LCJzdCI6ODI3Nywiem4iOjQzLCJ1ciI6Imh0dHA6Ly9jYXJlZXJzL nN0YWNrb3ZlcmZsb3cuY29tLz9ibWlkPTFiIn0&s=23_6m7TBuZEfLLMub8dFG59vm40" rel="nofol low" target="_blank" title=""><img src=". in spite of the fac t that I gave a working implementation.</a></form></div><img height="0px" width="0px" border="0" src="."><div clas s="adzerk-vote-option 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. </p> . Why didn't you like it?</span><u l><li><label><input type="radio" value="12" name="downvoteReason">Uninteresting< /label></li><li><label><input type="radio" value="13" name="downvoteReason">Misl eading</label></li><li><label><input type="radio" value="14" name="downvoteReaso n">Offensive</label></li><li><label><input type="radio" value="15" name="downvot eReason">Repetitive</label></li></ul><a href="http://stackoverflow.Stack Overflow_files/2565.png" title="" alt="" border="0" width="728" he ight="90"></a><div class="adzerk-vote-controls" style="display: none.adzerk.Number of subarrays divisible by k . We won't show you that ad again.com/questions/16605991/number -of-subarrays-divisible-by-k/16606634#" title="This is a favorite question (clic k again to undo)">favorite</a> <div class="favoritecount"><b></b></div> </div> </td> <td class="postcell"> <div> <div class="post-text" itemprop="description"> <p>I had the following question in an interview and.gif"></div> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="16605991"> <a class="vote-up-off" title="This question shows research effort.</div> <div id="mainbar"> <div class="question" data-questionid="16605991" id="question"> <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk1" ><a href="http://engine./arrays .

0} {5. N.com/questions/tagged/algorithm" class="post-tag" title="sh ow questions tagged &#39. 1} {5} {5.org/wiki/Subset_sum_p roblem" rel="nofollow">subset sum problem</a>. 5. 5." rel="tag">arrays</a> <a href= "http://stackoverflow.<blockquote> <p>A slice of array A is any pair of integers (P. K)) and space complexity was O(K). K = 5 Function must return 7.. -3} {-2. 0. -3} </code></pre> </div> <div class="post-taglist"> <a href="http://stackoverflow. -2.. 0. -3.subset-sum&#39.com/questions/tagged/codility" class="post-tag" title="show questions tagged &#39. K)). The expected time complexity was O(max(N.com/questions/tagged/subset-sum" class="post-tag" title="show que stions tagged &#39. one loop inside another and check every slice: O(n^2)</p> <p>I have been thinking but I really can't figure out how can I do it in O(max(N . had to return the number of slices divisib le by K. Q) of array A is divisible by K if the number A[P] + A[P+1] + . -3} {0} {0.algorithm&#39. </p> <p>It may be a variant of the <a href="http://en." rel="tag">subset-sum</a> <a href="http://sta ckoverflow. because there are 7 subarrays which sums are divisible b y 5 {4. </p> <p>EDIT: Elements in array could be negatives. Q) such that 0 £ P £ Q &lt. Here is an example:</p> <pre><code>A = {4." rel="tag">algorithm</a> <a href="http:/ /stackoverflow. A slice (P.</p> <p>My solution was the simplest.wikipedia.arrays&#39. -2.com/questions/tagged/arrays" class="post-t ag" title="show questions tagged &#39. -2. 0.com/q/16605991" title="shor . -2.codility&#39. but I don't know how to count eve ry subarray. -3. + A[Q-1] + A[Q] is divisible by K. 1}." rel="tag">codility</a> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.</p> </blockquote> <p>The function I was asked to write.

Stack Overflow_ files/4fde1c091d0b554379c278e9557d614c" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/2391137/tonimaister">tonimai ster</a><br> <span class="reputation-score" title="reputation score" dir="ltr">18 </span><span title="4 bronze badges"><span class="badge3"></span><span class="ba dgecount">4</span></span> </div> </div> </td> </tr> </tbody></table> </div> </td> </tr> <tr> <td class="votecell"></td> .Number of subarrays divisible by k .t permalink to this question" class="short-link" id="link-post-16605991">share</ a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/16605991/ed it" 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/users/2391137/tonimaister"><div cl ass=""><img src=".com/users/774674/adi">adi</a><br> <span class="reputation-score" title="reputation score" dir="ltr">65 8</span><span title="3 silver badges"><span class="badge2"></span><span class="b adgecount">3</span></span><span title="22 bronze badges"><span class="badge3"></ span><span class="badgecount">22</span></span> </div> </div> </td> <td class="post-signature owner"> <div class="user-info "> <div class="user-action-time"> asked <span title="2013-05-17 09:43:09Z" cla ss="relativetime">May 17 at 9:43</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.Number of subarrays divisible by k ./arrays .com/posts/16605991/rev isions" title="show all edits to this post">edited <span title="2013-05-24 05:20 :45Z" class="relativetime">May 24 at 5:20</span></a> </div> <div class="user-gravatar32"> <a href="http://stackoverflow./arrays .com/users/774674/adi"><div class=""><i mg src=".Stack Overflow_files/29b 2bb2b9e784b7fe19215329de18b43" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.

<td> <div id="comments-16605991" class="comments dno"> <table> <tbody> <tr><td></td><td></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> 4 Answers </h2> <div id="tabs"> <a href="http://stackoverflow.com/questions/16605991/number-of-subarrays-divisib le-by-k?answertab=oldest#tab-top" title="Answers in the order they were provided ">oldest</a> <a class="youarehere" href="http://stackoverflow.com/questions/16605991/number-o f-subarrays-divisible-by-k?answertab=votes#tab-top" title="Answers with the high est score first">votes</a> </div> </div> </div> <a name="16606634"></a> <div id="answer-16606634" class="answer accepted-answer" data-answerid="16606634 " style=""> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="16606634"> <a class="vote-up-off" title="This answer is useful">up vote</a> <span class="vote-count-post ">3</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 .com/questions/16605991/number-of-s ubarrays-divisible-by-k?answertab=active#tab-top" title="Answers with the latest activity first">active</a> <a href="http://stackoverflow.

com/a/16606634" title="shor t permalink to this answer" class="short-link" id="link-post-16606634">share</a> <span class="lsep">|</span><a href="http://stackoverflow.com/posts/16606634/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"> <a href="http://stackoverflow.ing when this answer was accepted. this number is x(x-1)/2. you want to count the number of slices the start in a cell with value i and ends in a cell with v alue i. + S[i].">accepted</span> </div> </td> <td class="answercell"> <div class="post-text"><p>As you are only interested in numbers divisible by K. So you just have to count for each possible value of [0. To solve edge problems..</p> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow. we add one cell with va lue 0. you can do all computations modulo K. T hen (P... Consider the cumulative sum array S such that S[i] = S[0] + S[1] + ..com/posts/16606634/rev isions" title="show all edits to this post">edited <span title="2013-05-17 14:09 :39Z" class="relativetime">May 17 at 14:09</span></a> .K-1 ] how many times it appears in S.. Q) is a slice divisible by K iff S[P] = S[Q] (remember we do all computa tions modulo K).</p> <p>Here is some pseudocode:</p> <pre><code>B = new array(K) B[0]++ s = 0 for i = 0 to N-1 s = (s + A[i]) % K B[s]++ ans = 0 for i = 0 to K-1 ans += B[i]*(B[i]-1)/2 </code></pre> <p>Once you know that they are x cells in S that have value i....

Number of subarrays divisible by k .</div> <div class="user-gravatar32"> </div> <div class="user-details"> <br> </div> </div> </td> <td align="right" class="post-signature"> <div class="user-info user-hover"> <div class="user-action-time"> answered <span title="2013-05-17 10:17:5 6Z" class="relativetime">May 17 at 10:17</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.com/users/2391137/tonimaister" title="18 reputation" class="commentuser owner">tonimaister</a> <span class="comment-date" dir="ltr"><a class="comme .com/users/1372399/thomash"><div class= ""><img src=". 366</span><span title="1 gold badge"><span class="badge1"></span><span class="ba dgecount">1</span></span><span title="6 silver badges"><span class="badge2"></sp an><span class="badgecount">6</span></span><span title="26 bronze badges"><span class="badge3"></span><span class="badgecount">26</span></span> </div> </div> </td> </tr> </tbody></table> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-16606634" class="comments"> <table> <tbody> <tr id="comment-23872517" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">sorry. I forgot to say that elements in array could be negatives</span> ±&nbsp.<a href="http://st ackoverflow./arrays .Stack Overflow_file s/8282947398571ff83ee0b3fa325ef49f" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/users/1372399/thomash">Thomash</a> <br> <span class="reputation-score" title="reputation score" dir="ltr">2.

but I don't know if I don't get it of it just doesn't work . but I can't fix it because I still don 't understand your reasoning. and it sh ould be one. 2. my solution is still valid.com/ques tions/16605991/number-of-subarrays-divisible-by-k/16606634#comment23875080_16606 634"><span title="2013-05-17 11:56:45Z" class="relativetime-clean">May 17 at 11: 56</span></a></span></div></td> </tr> <tr id="comment-23879472" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">It doesn't work with <code>k = 6</code> and <code>A = {1.com/users/2391137/tonimaister" title= "18 reputation" class="comment-user owner">tonimaister</a> <span class="commentdate" dir="ltr"><a class="comment-link" href="http://stackoverflow.</span> ±&nbsp.com/users/1372399/th omash" title="2366 reputation" class="comment-user">Thomash</a> <span class="com ment-date" dir="ltr"><a class="comment-link" href="http://stackoverflow. Maybe it's a little mistake. 1. Why do you multiply <code>B[i] * (B[i]+1)</code> ? </span> ±&nbsp.nt-link" href="http://stackoverflow.<a href="http://stackoverflow.com/questions/16605991/numberof-subarrays-divisible-by-k/16606634#comment23874727_16606634"><span title="2013 -05-17 11:46:51Z" class="relativetime-clean">May 17 at 11:46</span></a></span><s pan class="edited-yes" title="this comment was edited"></span></div></td> </tr> <tr id="comment-23875080" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">Indeed the last line <code>ans += B[i]*(B[i]+1)/2</code> counts only splices of size &gt.com/questions /16605991/number-of-subarrays-divisible-by-k/16606634#comment23879472_16606634"> <span title="2013-05-17 13:58:45Z" class="relativetime-clean">May 17 at 13:58</s pan></a></span></div></td> </tr> </tbody> </table> </div> .com/users/2391137/tonimaister" title="18 reputation" c lass="comment-user owner">tonimaister</a> <span class="comment-date" dir="ltr">< a class="comment-link" href="http://stackoverflow. I have modified it. It returns 3. 2.<a href="http://stackoverflow. 3}</code>.</span> ±&nbsp. I prove with for example array {1.com/questions/16605991/number-of-subarrays-divisible-by-k/1660663 4#comment23872558_16606634"><span title="2013-05-17 10:34:04Z" class="relativeti me-clean">May 17 at 10:34</span></a></span></div></td> </tr> <tr id="comment-23874727" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">Thank you very much for your answer. 3} and k = 3 and the result is 1.<a href="http://stackoverfl ow. when i t should be 3.com/questions/16605991/number-of-subarrays-d ivisible-by-k/16606634#comment23872517_16606634"><span title="2013-05-17 10:32:3 7Z" class="relativetime-clean">May 17 at 10:32</span></a></span></div></td> </tr> <tr id="comment-23872558" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">It doesn't chan ge anything.com/users/1372399/thomash" title="2366 reputation" class="comment-user">Thoma sh</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="http:/ /stackoverflow. Could you explain a little bit more your answer?</span> ±&nbsp.<a h ref="http://stackoverflow.

-2. Why didn't you li ke it?</span><ul><li><label><input type="radio" value="12" name="downvoteReason" >Uninteresting</label></li><li><label><input type="radio" value="13" name="downv oteReason">Misleading</label></li><li><label><input type="radio" value="14" name ="downvoteReason">Offensive</label></li><li><label><input type="radio" value="15 " name="downvoteReason">Repetitive</label></li></ul><a href="http://stackoverflo w.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiY20iOjI5MTEsImNoIjoxM Tc4LCJjciI6NTkyMywiZGkiOiJlMzQ4NDFiMGRmYzA0MmE1OGU0NzNiYTY0ZGQ5MTIzZSIsImRtIjoxL CJmYyI6MTAxODgsImZsIjo3NDcyLCJrdyI6ImFycmF5cyxhbGdvcml0aG0sc3Vic2V0LXN1bSxjb2Rpb Gl0eSIsIm53IjoyMiwicmYiOiJodHRwOi8vc3RhY2tvdmVyZmxvdy5jb20vdGFncy9jb2RpbGl0eS9ob 3QiLCJydiI6MCwicHIiOjE2MDQsInN0Ijo4Mjc3LCJ6biI6NDQsInVyIjoiaHR0cDovL2NhcmVlcnMuc 3RhY2tvdmVyZmxvdy5jb20vIn0&s=3Ypc7UitO0BQ6XeuLzjlxQPKOiM" rel="nofollow" target= "_blank" title=""><img src="."><div class="adzerk-vote-option adzerk-vote-up"><div class="adzerk-vote-ico n"></div></div><div class="adzerk-vote-option adzerk-vote-down"><div class="adze rk-vote-icon"></div></div></div><div class="adzerk-vote-survey" style="display:n one. int i.<a id="comments-link-16606634" class="comments-link" data-comments-count="2" title="expand to show all comments on this post">show <b>2</b> more comments</a > </td> </tr> </tbody></table> </div> <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk3"><a href="http://engine.png" title="" alt="" border="0 " width="728" height="90"></a><div class="adzerk-vote-controls" style="display:n one.adzerk. .</a></form></div><img height="0 px" width="0px" border="0" src=".com/questions/16605991/number-of-subarrays-divisible-by-k/16606634#" class="ad zerk-vote-cancel">Oops! I didn't mean to do this. j. -3.Number of subarrays divisible by k . int sum = 0."><form><span>No problem. 0. 5. We won't show you that ad again./arrays ./arrays .Number of subarrays divisible by k Stack Overflow_files/i(1). 1 }.gif"></div> <a name="17307808"></a> <div id="answer-17307808" class="answer" data-answerid="17307808"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="17307808"> <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>static void Main(string[] args) { int[] A = new int[] { 4.Stac k Overflow_files/46a9844d6e504212a85bc72ddd7dd829.

A.Length.com/users/2521798/user2521798"><div cl ass=""><img src=". 6) sum += A[j + i]. A. i &lt.com/posts/17307808/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-25 21:24:5 7Z" class="relativetime">Jun 25 at 21:24</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.int count = 0. } Console. i++) { for (j = 0. Console.com/users/2521798/user2521798">user252 1798</a><br> <span class="reputation-score" title="reputation score" dir="ltr">11 .Length. j++) { if (j + i &lt.ReadLine(). } </code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow. if ((sum % 5) == 0) count++./arrays . for (i = 0.WriteLine(count).Stack Overflow_ files/3ee467a43002dc846b8db4c43d5a5058" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow. } sum = 0.Number of subarrays divisible by k .com/a/17307808" title="shor t permalink to this answer" class="short-link" id="link-post-17307808">share</a> <span class="lsep">|</span><a href="http://stackoverflow. j &lt.

when you really only ha ve to go through part of it--since <code>j + i</code> is going to reach 6 partwa y through.</span> ±&nbsp.<a href="http://stackoverflow.com/questions/16605991 /number-of-subarrays-divisible-by-k/16606634#comment25101334_17307808"><span tit le="2013-06-25 21:46:19Z" class="relativetime-clean">Jun 25 at 21:46</span></a>< /span></div></td> </tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="16881714"></a> <div id="answer-16881714" class="answer" data-answerid="16881714"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="16881714"> <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> . This solution needs some work s till. you're using <code>sum</code> in a comparison right after that even though it's not been set in that iteration. Also.</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-17307808" class="comments"> <table> <tbody> <tr id="comment-25101334" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">Suggestion: you 're iterating through the whole array in the inner loop.com/users/12802/catfood" title=" 2198 reputation" class="comment-user">catfood</a> <span class="comment-date" dir ="ltr"><a class="comment-link" href="http://stackoverflow.

while (s &lt. N. int[] B = new int[K]. } int ans = 0. for (int i = 0. i++) { s = (s + A[i]) % K. i &lt.com/posts/16881714/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"> . 0) { s += K. i++) { ans += B[i] * (B[i] .Length.com/a/16881714" title="shor t permalink to this answer" class="short-link" id="link-post-16881714">share</a> <span class="lsep">|</span><a href="http://stackoverflow. B. } B[0]++.1) / 2. int s = 0. } B[s]++. i++) { B[i] = 0. int K) { int N = A.= K . for (int i = 0. } return ans. i &lt.1.Length. for (int i = 0. } </code></pre> </div> <table class="fw"> <tbody><tr> <td class="vt"> <div class="post-menu"><a href="http://stackoverflow.</div> </td> <td class="answercell"> <div class="post-text"> <pre><code> private int GetSubArraysCount(int[] A. i &lt.

/arrays .Number of subarrays divisible by k .com/users/2444873/user2444873"><div cl ass=""><img src=".com/users/2444873/user2444873">user244 4873</a><br> <span class="reputation-score" title="reputation score" dir="ltr">1< /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-16881714" class="comments dno"> <table> <tbody> <tr><td></td><td></td></tr> </tbody> .Stack Overflow_ files/fed0953adf5d8308b5d705a4d31e0d67" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/posts/16881714/rev isions" title="show all edits to this post">edited <span title="2013-06-02 11:18 :06Z" class="relativetime">Jun 2 at 11:18</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="2013-06-02 10:01:3 0Z" class="relativetime">Jun 2 at 10:01</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.<a href="http://stackoverflow.

</span><span class="pln "> </span><span class="pun">-</span><span class="lit">2</span><span class="pun"> .</span><span class="pln"> </span><span class="pun">-</span><span class="lit">3< /span><span class="pun">.</span>< span class="lit">5</span><span class="pun">).</span><span class="p ln"> </span><span class="lit">0</span><span class="pun">.</span><span class="pln"> </span><span class="lit">1</s pan><span class="pun">}.</span><span class= "pln"> </span><span class="lit">5</span><span class="pun">.</span><span class="pln"> obj</span><span class="pun">.</table> </div> </td> </tr> </tbody></table> </div> <a name="16615228"></a> <div id="answer-16615228" class="answer" data-answerid="16615228"> <table> <tbody><tr> <td class="votecell"> <div class="vote"> <input type="hidden" value="16615228"> <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">class</span><span class="pln"> </span><span class="typ">SubArrayDivisible< /span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class= "kwd">static</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> main</span><span class="pun">(</span><span class="typ">String</span ><span class="pun">[]</span><span class="pln"> args</span><span class="pun">)</s pan><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="kwd">int</span><span class="pun">[]</span><span clas s="pln"> A </span><span class="pun">=</span><span class="pln"> </span><span clas s="pun">{</span><span class="lit">4</span><span class="pun">.</span><span class="pln">getSubArrays</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="pln"> </span><span class="typ">SubArrayDivisible</span><span class="pln"> obj </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new </span><span class="pln"> </span><span class="typ">SubArrayDivisible</span><span class="pun">().

</span><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span c lass="kwd">int</span><span class="pln"> j </span><span class="pun">=</span><span class="pln"> i</span><span class="pun">.</span><span cla ss="pln"> </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="kwd">int</span><span class="pln"> K</ 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"> count </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span c lass="pun">.</span><span class="pln">i</span><span class= "pun">&lt.</s pan><span class="pln">out</span><span class="pun">.</span><span cl ass="pln">out</span><span class="pun">.</span><span c lass="pln"> count</span><span class="pun">++.</span><span class="pln">A</span><span class="pun">.</span><span class="pln">println</span><s pan class="pun">(</span><span class="str">"Num of Sub-Array "</span><span class= "pun">+</span><span class="pln">count</span><span class="pun">).</span><span class="pln">A</span><span class="pun">.</span><span class="kwd">private</span><span class="pln"> </span><span class ="kwd">void</span><span class="pln"> getSubArrays</span><span class="pun">(</spa n><span class="kwd">int</span><span class="pun">[]</span><span class="pln"> A</s pan><span class="pun">.</span><span class ="pln">length</span><span class="pun">.</span><span class="pln">i</span><span cl ass="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> s </span><span class="pun">=</span><span class="pln"> </span><span c lass="lit">0</span><span class="pun">.</span><span class="pln">j</span><span class="pun">&lt.</span><span class="pln">prin tln</span><span class="pun">(</span><span class="str">"Value of S "</span><span class="pun">+</span><span class="pln">s</span><span class="pun">).</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">((</span><sp an class="pln">s</span><span class="pun">%</span><span class="pln">K</span><span class="pun">)</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">)</span><span cl ass="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="typ">System</span><span class="pun">.</span><span class="pln">length</span><span class="pun">.</span><span class="pln"> </span><span class="kwd">for</span><span class="pun">(</span><span class ="kwd">int</span><span class="pln"> i</span><span class="pun">=</span><span clas s="lit">0</span><span class="pun">.</span><span class="pln">j</span><s pan class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> s </span><span class="pun">=</span><span class="pln"> s</span><s pan class="pun">+</span><span class="pln">A</span><span class="pun">[</span><spa n class="pln">j</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><span class="pln"> </span><span class="typ">System</span><span class="pun">.</span><span class="pln">s</span><span class="pun">=</span><span cla ss="lit">0</span><span class="pun">.

Number of subarrays divisible by k ./arrays .com/a/16615228" title="shor t permalink to this answer" class="short-link" id="link-post-16615228">share</a> <span class="lsep">|</span><a href="http://stackoverflow.<div class="post-menu"><a href="http://stackoverflow.com/users/1410037/thomas"><div class=" "><img src=".com/users/2395001/subhasish"><div clas s=""><img src=".com/users/2395001/subhasish">Subhasish </a><br> <span class="reputation-score" title="reputation score" dir="ltr">1< /span> </div> .Stack Overflow_files /c4e910f23fa3f49cded79db125234a3e" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.com/posts/16615228/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"> <a href="http://stackoverflow.com/users/1410037/thomas">Thomas</a><b r> <span class="reputation-score" title="reputation score" dir="ltr">69 6</span><span title="5 silver badges"><span class="badge2"></span><span class="b adgecount">5</span></span><span title="22 bronze badges"><span class="badge3"></ span><span class="badgecount">22</span></span> </div> </div> </td> <td align="right" class="post-signature"> <div class="user-info "> <div class="user-action-time"> answered <span title="2013-05-17 17:59:2 6Z" class="relativetime">May 17 at 17:59</span> </div> <div class="user-gravatar32"> <a href="http://stackoverflow.Stack Overflow_fi les/5415b8e55a562b3cc508124dd9b777ee" alt="" width="32" height="32"></div></a> </div> <div class="user-details"> <a href="http://stackoverflow.Number of subarrays divisible by k .com/posts/16615228/rev isions" title="show all edits to this post">edited <span title="2013-06-02 10:25 :08Z" class="relativetime">Jun 2 at 10:25</span></a> </div> <div class="user-gravatar32"> <a href="http://stackoverflow./arrays .

prepareEditor({ heartbeatType: 'answer'.</div> </td> </tr> </tbody></table> </td> </tr> <tr> <td class="votecell"></td> <td> <div id="comments-16615228" class="comments"> <table> <tbody> <tr id="comment-23889249" class="comment"> <td></td> <td class="comment-text"><div><span class="comment-copy">That's the solu tion I gave in the interview.discard-answer" .immediatelyShowMarkdownHelp:true }). postfix: "". but its complexity is O(n!) and they asked for O(m ax(k.com/questions/16605991/number-of-subarrays-divis ible-by-k/16606634#comment23889249_16615228"><span title="2013-05-17 19:06:34Z" class="relativetime-clean">May 17 at 19:06</span></a></span></div></td> </tr> </tbody> </table> </div> </td> </tr> </tbody></table> </div> <a name="new-answer"></a> <form id="post-form" action="http://stackoverflow.<a href="http://stacko verflow. onDemand: true. bindNavPrevention: true.ready(function() { initTagRenderer("".n)).split(" ").split(" ")). . discardSelector: ".com/users/2391137/tonimaister" title="18 reputation" class="comment-user owner">tonimaister</a> <span class="comment-date" dir="ltr"><a class="comment-l ink" href="http://stackoverflow. "". Thomas' solution is the correct one</span> ±&nbsp.com/questions/16605991/ans wer/submit" method="post" class="post-form"> <input type="hidden" id="post-id" value="16605991"> <h2 class="space">Your Answer</h2> <script type="text/javascript"> StackExchange.

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

</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. but not shown</sp an> </div> </td> </tr> </tbody></table> </div> </div> </div> </div> . }).ready(function () { StackExchange.helpers.ready(function () { StackExchange.vm input')).helpers.com/users/login?returnurl=%2fquestions%2f16605991%2fnumber-of-subarrays-div isible-by-k%23new-answer">log in</a></h3> <script type="text/javascript"> StackExchange.onClickDraftSave('#login-l ink').bindHelpOverlayEvents($('. }). </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="new-login-left"> <h3>Sign up or <a id="login-link" href="http://stackover flow.

&lt. &lt. &lt.Post as a guest&lt.div&gt. &lt. &lt./div&gt. &lt.vm input')). &lt. &lt.script type="text/javascript"&gt. &lt.input id="m-address" name="m-address" type="text" size=" 30" maxlength="100" value="" tabindex="106"&gt. </script> <noscript> &lt.Name&lt. StackExchange.div class="form-item"&gt./label&gt. &lt.bindHelpOverlayEvents($('.com/ques ./script&gt.tr&gt./tr&gt.table&gt. &lt.openid. you agree to the <a href="http://stackexchange. &lt. but not sho wn&lt.Email&lt.span class="edit-field-overlay"&gt. </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.div&gt.label for="m-address"&gt.required.ready(function () { StackExchange.input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105"&gt.com/legal/privacy-policy" target="_blank"> privacy policy</a> and <a href="http://stackexchange. &lt./td&gt. &lt.<script type="text/javascript"> StackExchange./span&gt.initPostLogin('. '% 2fquestions%2f16605991%2fnumber-of-subarrays-divisible-by-k%23new-answer')./div&gt.com/questions/16605991/number-of-subar rays-divisible-by-k/16606634#" class="discard-answer dno">discard</a> <p class="privacy-policy-agreement"> By posting your answer./label&gt.h3&gt.com/legal/terms-of-service" target="_blank ">terms of service</a>./table&gt. &lt.label for="display-name"&gt. } ).new-post-login'. }). &lt.helpers. &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. &lt.ready( function () { StackExchange./div&gt./h3&gt. &lt.td class="vm"&gt.

com/questions/tagged/a rrays" class="post-tag" title="show questions tagged &#39.<span class="item-multiplier"><span class="item-multiplier-x">×</ span>&nbsp.tions/tagged/arrays" class="post-tag" title="show questions tagged &#39.<span class="item-multiplier-count">75</span></span><br> <a href="http://stackoverflow. </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." rel="tag">algorithm</a>&nbsp.codility&#39." rel="tag">codility</a>&nbsp." rel="tag">codility </a> or <a href="http://stackoverflow.com/questions/16605991/number-of-subarrays-divisible-by-k/16 606634?lastactivity" class="lastactivity-link" title="2013-06-25 21:24:57Z">6 da ys ago</a></b></p></td> </tr> </tbody></table> </div> <div class="module community-bulletin" data-tracker="cb=1"> <h4>Community Bulletin</h4> .<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="2013-0 5-17 09:43:09Z"><b>1 month ago</b></p></td> </tr> <tr> <td><p class="label-key">viewed</p></td> <td style="padding-left:10px"> <p class="label-key"> <b>694 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/ask">ask your own question</a>.<span class="item-multiplier"><span class="item-multiplier-x">×</span>&nbsp." rel="tag"> subset-sum</a> <a href="http://stackoverflow." rel="tag">subset-sum</a>&nbsp .<span class="item-multiplier"><span class="item-multiplier-x">×</span>&nbsp." rel="tag" >arrays</a>&nbsp.algorithm&#39.arrays&#39.com/questions/tagged/alg orithm" class="post-tag" title="show questions tagged &#39.<span cl ass="item-multiplier-count">30772</span></span><br> <a href="http://stackoverflow.algorithm&#39.<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.com/questions/tagged/subset-sum " class="post-tag" title="show questions tagged &#39." rel="tag">arrays</a> <a href="http://stackoverflow.<span class="item-multiplier-count">55477</span></span><br> <a href="http://stackoverflow.subset-sum&#39.codility&#39.subset-sum&#39." rel=" tag">algorithm</a> <a href="http://stackoverflow.arrays&# 39.com/questions/tagged/subset-sum" class="post-tag" title="show questions tagged &#39.com/questions/tagged/codility" clas s="post-tag" title="show questions tagged &#39.com/questions/tagged/algorithm" class="post-tag" t itle="show questions tagged &#39.

Click to learn more. Click to learn more.com/jobs?a=24" class ="top" target="_blank"></a> <ul class="jobs"> <li> <a href="http://careers.stack overflow.com/jobs/34545/worship-worthy-frontend-developer-wanted-idyllic-softwar e?a=EOwfwnC" target="_blank" title="Worship-worthy Frontend Developer Wanted! Ja vascript // Html // CSS at Idyllic Software.codility ".getElementsByTagName("script")[0].insertBefore(z.com/jobs/36379/expert-php-developer-idylli c-software?a=GYRE1Pi" target="_blank" title="Expert PHP Developer at Idyllic Sof .com/jobs/35816/senior-software-developer-building-sca lable-e-lenskart-com?a=GjCFFzG" target="_blank" title="Senior Software Developer ."> Ruby Developer<br> <span class="company">Idyllic Software</span> <span class="location">Mumbai. else scriptSrc += "?".createElement("script"). s).type = "text/javascript". } StackExchange.src = scriptSrc.algorithm. })."> Web Developer at PointRoll<br> <span class="company">G annett Co</span> <span class="location">Conshohocken.com/jobs/36059/web-developer-at-pointroll-gann ett-co?a=GBp9GMg" target="_blank" title="Web Developer at PointRoll at Gannett C o.adzerk.<div class="related"> <div class="spacer"> <div class="bulletin-item-type"><a href="http://blog.stackoverflow."> Senior Backend Developer<br> <span class="company">Badgeville</ span> <span class="location">Redwood City.test(scriptSrc)) scriptSrc += "&".referrer. z.com/jobs/33649/senior-backend-developer-badgeville? a=DKRNbaw" target="_blank" title="Senior Backend Developer at Badgeville. </script> <div id="hireme"> <a href="http://careers.subset-sum.adzerk2_2_17_45.stackoverflow."> Worship-wort hy Frontend Developer Wanted! Javascript //¼<br> <span class="company">Idyllic Sof tware</span> <span class="location">Pune.stackoverflow. Click to learn more.stackoverflow.com/jobs/32969/ruby-developer -idyllic-software?a=CX4Dz3i" target="_blank" title="Ruby Developer at Idyllic So ftware.parentNode.building scalable e-solutions<br> <span class="company">len skart.async = "true". India</span> </a> </li> <li> <a href=" http://careers. CA</span> </a> </li> <li> <a href="ht tp://careers.com. Click to learn more. var s = document.com</span> <span class="location">New Delhi. z. scriptSrc += "xReferrer=" + document.referrer) { if (/\?/.stackoverflow.stackoverflow.c om/?cb=1" class="event-date" target="_blank">blog</a></div> <div class="bulletin-item-content"> <a href="http://blog. s. India</span> </a> </li> <li> <a h ref="http://careers. India / relocation</span> </a > </li> <li> <a href="http://careers. Click to learn more. z.ready(function() { var z = document.stackoverflow.net/z/8277/adzerk1_2_4 _43.adzerk3_2_4_44?keywords=arrays. PA</span> </a> </li> <li> <a href="http://careers.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."> Senior Software Developer . if (document.stackoverflow.building scalable e-solutions at lenskart.

d ownvotes)"> <div class="answer-votes answered-accepted large">296</div> </a> <a href="http://stackoverflow. find the missing nu mber(s)</a> </div> <div class="spacer"> <a href="http://stackoverflow.tware. India</span> </a> </li> </ul > <img alt="" class="impression" src=".100..com/questions/9152095/zero-sum-minimal-subarray?rq =1" class="question-hyperlink">Zero sum minimal subarray</a> </div> <div class="spacer"> .com/questions/3492302/easy-interview-question-gotharder-given-numbers-1-100-find-the-missing-numbe?rq=1" class="question-hyperlin k">Easy interview question got harder: given numbers 1.com/q/2680548?rq=1" title="Vote score (upvotes .com/questions/8099334/maximum-subset-sum-with-twoarrays?rq=1" class="question-hyperlink">Maximum subset sum with two arrays</a> </div> <div class="spacer"> <a href="http://stackoverflow.d ownvotes)"> <div class="answer-votes answered-accepted default">4</div> </a> <a href="http://stackoverflow. return array of products of all other numbers (no division)</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/questions/2680548/given-an-array-of-numbers-re turn-array-of-products-of-all-other-numbers-no-div?rq=1" class="question-hyperli nk">Given an array of numbers.Number of subarrays divisible b y k ./arrays .com/q/5963983?rq=1" title="Vote score (upvotes .com/q/3492302?rq=1" title="Vote score (upvotes .com/q/8099334?rq=1" title="Vote score (upvotes ."> Expert PHP Developer<br> <span class="company">Idy llic Software</span> <span class="location">Mumbai.d ownvotes)"> <div class="answer-votes answered-accepted default">65</div> </a> <a href="http://stackoverflow.d ownvotes)"> <div class="answer-votes answered-accepted default">15</div> </a> <a href="http://stackoverflow.com/questions/5963983/find-the-minimum-number-of-e lements-required-so-that-their-sum-equals-or-exceeds?rq=1" class="question-hyper link">Find the minimum number of elements required so that their sum equals or e xceeds S</a> </div> <div class="spacer"> <a href="http://stackoverflow. Click to learn more.d ownvotes)"> <div class="answer-votes default">2</div> </a> <a href="http://stackoverflow.Stack Overflow_files/EOwfwnC-DKRNbaw-GjCFFzG-CX4Dz3i-GBp9GMg-GYRE1Pi-24" s tyle="display: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/9152095?rq=1" title="Vote score (upvotes .

com/feeds/question/16 605991" title="feed of this question and its answers"><span class="feed-icon"></ span>question feed</a></div> </div> <script type="text/javascript"> StackExchange.com/questions/14120729/algorithm-to-split-an-array -into-p-subarrays-of-balanced-sum?rq=1" class="question-hyperlink">Algorithm to split an array into P subarrays of balanced sum</a> </div> </div> </div> </div> <div id="feed-link"> <div id="feed-link-text"><a href="http://stackoverflow./div&gt.com/questions/13093602/finding-subarray-with-maxim um-sum-number-of-elements?rq=1" class="question-hyperlink">Finding subarray with maximum sum/number of elements</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/13093602?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes answered-accepted default">0</div> </a> <a href="http://stackoverflow.&lt.com/q/11772145?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes default">0</div> </a> <a href="http://stackoverflow. </script> <noscript> &lt.com/questions/13950442/subset-sum-recursively-to-g et-as-near-as-possible-to-a-given-number?rq=1" class="question-hyperlink">Subset sum recursively to get as near as possible to a given number</a> </div> <div class="spacer"> <a href="http://stackoverflow. .com/q/13950442?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes answered-accepted default">0</div> </a> <a href="http://stackoverflow.img src="/posts/16605991/ivc/7ea7" class="dno" alt="" width=" 0" height="0"&gt.div&gt.com/questions/11772145/number-of-subarrays-where-s um-of-numbers-is-divisible-by-k?rq=1" class="question-hyperlink">number of subar rays where sum of numbers is divisible by K</a> </div> <div class="spacer"> <a href="http://stackoverflow.com/q/14120729?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes default">13</div> </a> <a href="http://stackoverflow.<a href="http://stackoverflow.get('/posts/16605991/ivc/7ea7').com/q/13089010?rq=1" title="Vote score (upvotes downvotes)"> <div class="answer-votes answered-accepted default">1</div> </a> <a href="http://stackoverflow.com/questions/13089010/find-longest-subarray-whose -sum-divisible-by-k?rq=1" class="question-hyperlink">Find longest subarray whose sum divisible by K</a> </div> <div class="spacer"> <a href="http://stackoverflow.&lt.}).ready(function(){$.

com/about">about</a> <a href="http://stackoverflow.stackexchange.com/contact">contact us</a> </b> <b><a href="http://meta.com/" title="p .com/help/badges">badges</a > <a href="http://blog.stackexchange.com/help">help</a> <a href="http://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.on&quot.stackoverflow.com/legal">legal</a> <a href="http://stackexchange.)">mobile< /a> <b><a href="http://stackoverflow.net/redirect/0/2776/2751/0/4de 3c60f719c4dfcb1a57531c7050090/0">advertising info</a> <a onclick="StackExchange.stackoverflow. &quot .com/about/hiring">jobs</a> <a href="http://engine./questions/16605991/number-of-subarrays-divisible-by-k/16606634&quot.com/" title="computer enth usiasts and power users">Super User</a></li> <li><a href="http://webapps.com/?blb=1">blog</a> <a href="http://chat.stackexchange.switchMobile(&quot.</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/" title="professiona l system and network administrators">Server Fault</a></li> <li><a href="http://superuser.com/">data</a> <a href="http://stackexchange.com/legal/privacy-policy">priv acy policy</a> <a href="http://stackexchange..adzerk.com/">chat</a> <a href="http://data.

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

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

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

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