i think DP has answer to this question initialy compute the quality value of all the substrings of length 1,2,3 Ans[i][j] = max(ans[i,j-2]+ans[j-1][j],ans[i,j-3]+ans[j-2][j],ans[i,i+1]+ans[i+2][j],ans[i,i+2]+ans[i+3][j]) something like that.
On Fri, Jul 8, 2011 at 1:31 AM, rajeev bharshetty <[email protected]>wrote: > It scans 555 count=3(excellent group) it will put in one group than 54 > since the count is one puts that in usual group quality =2*1 =2 , > > > On Fri, Jul 8, 2011 at 1:28 AM, Piyush Sinha <[email protected]>wrote: > >> @Rajeev...check ur logic for 55554 >> >> On 7/8/11, rajeev bharshetty <[email protected]> wrote: >> > So, I think first check for excellent groups then good and then usual to >> > increase the quality. >> > So to get excellent groups scan the string and keep a count of the >> > contagious repeating elements ,if count==3 or count==2,then put in one >> > group >> > The same procedure for good and usual accord to constraints . >> > >> > >> > >> > On Thu, Jul 7, 2011 at 11:46 PM, Piyush Sinha >> > <[email protected]>wrote: >> > >> >> You are given a String number containing the digits of a phone number >> >> (the number of digits, n, can be any positive integer) . To help you >> >> memorize the number, you want to divide it into groups of contiguous >> >> digits. Each group must contain exactly 2 or 3 digits. There are three >> >> kinds of groups: >> >> • Excellent: A group that contains only the same digits. For example, >> 000 >> >> or 77. >> >> • Good: A group of 3 digits, 2 of which are the same. For example, >> >> 030, 229 or 166. >> >> • Usual: A group in which all the digits are distinct. For example, 123 >> or >> >> 90. >> >> The quality of a group assignment is defined as 2 × (number of >> >> excellent groups) + (number of good groups) >> >> Divide the number into groups such that the quality is maximized. >> >> Design an efficient >> >> algorithm to return the solution that maximizes the quality. >> >> >> >> -- >> >> *Piyush Sinha* >> >> *IIIT, Allahabad* >> >> *+91-8792136657* >> >> *+91-7483122727* >> >> *https://www.facebook.com/profile.php?id=100000655377926 * >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups >> >> "Algorithm Geeks" group. >> >> To post to this group, send email to [email protected]. >> >> To unsubscribe from this group, send email to >> >> [email protected]. >> >> For more options, visit this group at >> >> http://groups.google.com/group/algogeeks?hl=en. >> >> >> >> >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Algorithm Geeks" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group at >> > http://groups.google.com/group/algogeeks?hl=en. >> > >> > >> >> >> -- >> *Piyush Sinha* >> *IIIT, Allahabad* >> *+91-8792136657* >> *+91-7483122727* >> *https://www.facebook.com/profile.php?id=100000655377926 * >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
