tag:blogger.com,1999:blog-3418265334198879901.post4992832032855273132..comments2015-07-08T20:12:23.530+05:30Comments on Coders Stop: Count the number of subsequence divisible by 6Aviral Guptahttps://plus.google.com/106672188404614095306noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-3418265334198879901.post-24931399023679418262015-07-08T20:12:23.520+05:302015-07-08T20:12:23.520+05:30Can you provide the test case?Can you provide the test case?codersstopblognoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-15268462678044829842015-07-08T20:11:58.858+05:302015-07-08T20:11:58.858+05:30Thanks for your inputs! Would update the code with...Thanks for your inputs! Would update the code with the comments.codersstopblognoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-50428999425873195442015-07-08T16:08:02.648+05:302015-07-08T16:08:02.648+05:30not getting the desired output please helpnot getting the desired output please helpsayan dasnoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-35678212219429284422015-07-08T06:04:40.223+05:302015-07-08T06:04:40.223+05:30The solution is elegant, but please consider expla...The solution is elegant, but please consider explaining how is your solution designed and more importantly, what variables are tracking/updating what part of your designed solution by commenting your code well (hat-tip to geeksforgeeks), for e.g. 't_ones' is not very obvious to many users.Ravi Karannoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-43204519183677806492015-06-30T16:48:17.145+05:302015-06-30T16:48:17.145+05:30thanks for the clarity..thanks for the clarity..Gurpreet Makkarnoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-68890478900949395912015-06-29T11:27:21.487+05:302015-06-29T11:27:21.487+05:30So the case 1 represents a (n + 1) % 3 = 1
So if ...So the case 1 represents a (n + 1) % 3 = 1<br /><br />So if we have a look at the 2nd row of the table the new number of subsequences with the remainder 1 will be <br /><br />number of subsequences with remainder 1 encountered till now + number of subsequences with remainder 0 encountered till now (this is because now adding the current digit with each of the previous subsequences would generate the subsequence of remainder 1)<br /><br />Hence the statement <br />t_ones = ones + threes<br /><br />Finally sum = threes + 1;<br /><br />this is due to counting the subsequences of the single digit (if you notice the equivalent addition to threes is threes++ in line 15)<br /><br /><br />Hope this makes a little clear, feel free to reach me out in case of any other issuecodersstopblognoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-15519364042488849622015-06-29T00:39:48.517+05:302015-06-29T00:39:48.517+05:30can you please explain these statements ?
t_ones ...can you please explain these statements ?<br /><br />t_ones = (ones + ones) in Case 0Gurpreet Makkarnoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-91487507413327352682015-06-29T00:07:50.479+05:302015-06-29T00:07:50.479+05:30ok..thanks for acknowledging that...:)ok..thanks for acknowledging that...:)Gurpreet Makkarnoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-6050889223848098712015-06-28T22:53:16.170+05:302015-06-28T22:53:16.170+05:30ones, twos and threes keep track of the number of ...ones, twos and threes keep track of the number of subsequences which give 1, 2, 3 respectively as remainder when divided by 3, which can be formed till the ith character of the string.codersstopblognoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-22564838137398006182015-06-28T22:51:06.683+05:302015-06-28T22:51:06.683+05:30Updated the question with an example, let me know ...Updated the question with an example, let me know if you need any further leads.codersstopblognoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-42174190849560234242015-06-28T22:47:58.440+05:302015-06-28T22:47:58.440+05:30The values in the table were a little messed up, t...The values in the table were a little messed up, thanks for pointing it out!codersstopblognoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-35973437739042361872015-06-28T20:06:16.156+05:302015-06-28T20:06:16.156+05:30if you can explain this question that would be gre...if you can explain this question that would be greatAnkur singhnoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-81556555214615000782015-06-28T19:35:32.419+05:302015-06-28T19:35:32.419+05:30if no =217
say a1=2, a2=1
x= (a1 a2)%3=(21)%3=0
re...if no =217<br />say a1=2, a2=1<br />x= (a1 a2)%3=(21)%3=0<br />remainder a3%3=7%3=1<br />y should be 1<br />but in table it is 2.. <br />Can u please make it more clear?Gurpreet Makkarnoreply@blogger.comtag:blogger.com,1999:blog-3418265334198879901.post-55798529427728158872015-06-28T15:22:55.412+05:302015-06-28T15:22:55.412+05:30Can you explain in more detail what are ones twos ...Can you explain in more detail what are ones twos and threes?Anonymusnoreply@blogger.com