https://www.hackerrank.com/contests/hourrank18/challenges/supersixsubstrings can anyone explain the apporach used asked 06 Mar '17, 09:07

yeah sure.Lets see this part in detail. answered 06 Mar '17, 20:35
Good explanation, but regarding remainder I got 1 query. We know that if we are getting remainder of, lets say 2 when we divide 5 by 3. Then its a sure fact that (52)%3=0. Meaning, number  remainder would be surely divisible. So why are we doing addition in form of (x+m) instead of using subtraction property I wrote about above. I would appreciate if you can help me here :)
(06 Mar '17, 20:39)
1
We are traversing every number and starting for index i of string and checking if its divisible by 3 and 2.
(06 Mar '17, 20:55)
1
I think I need a bit more practice of dynamic programming to truly appreciate what you say. I am getting it, but there are multiple 'whys' and 'ifs' which can be best resolved by a future attempt with a much more refined skill in dp. Thanks for your effort and explanation dear ^_^
(06 Mar '17, 21:01)

It's all about dynamic programming. If you are not aware of dynamic programming then please try your hand on these problem unless you could not able to crack that logic. On other hand, editorial has already been provided so i suggest you to check out and tell me which line you are having a problem. Author solution is also to the point so overall the editorial and question are clear. Please check out and comment here after that answered 06 Mar '17, 11:08
1
@bansal1232 i know dynamic programming but still i m not able understand. https://www.hackerrank.com/rest/contests/hourrank18/challenges/supersixsubstrings/hackers/gvaibhav21/download_solution. if((s[i]'0')%2 ==0) ans += cnt[presum%3]; if(i+1 == n  s[i+1] != '0') cnt[presum%3]++; if(s[i]=='0') ans++; if 1,2 is the remainder by taking modulous by 3 then how it is divisble by 6.
(06 Mar '17, 13:52)

@akshay29 read the observation part of the editorial,you will get to know what they are trying to say. They are saying the number is divisible by 6 only if it's divisible by both 3 and 2.They are checking both for 2 and 3 not just for 3. Hope You get this. answered 06 Mar '17, 19:03
You're right here, but can you explain the " "(x+m)%3" thing in the function." ??
(06 Mar '17, 19:52)

m is running sum of digits of substring starting at i . Now if we extend this interval and x is the next digit, then if (x+m)%3==0 and x%2==0 then we can extend the interval and hence we memoize this answer. m here is just used to remember the sum of last seen substring to check if next substring is super substring or not. So if previous m was 1 and now x is 2 then we have a super substring((1+2)%3==0 &&2 is even). Had we not memoized m then we would have to find the running sum of subset again which will blow up the time constraints. Hope this helps answered 07 Mar '17, 08:15

Compute all the subarrays. Refer Link answered 10 Mar '17, 09:43

Even I cant get that "(x+m)%3" thing in the function. Waiting for an answer now lol XD
@naksh9619 Asking for mark is not a good way. It seems that you are helping the people only because of earning karma points.