×

# [closed] SPOJ FREQUENT WA

 0 http://www.spoj.com/problems/FREQUENT/ https://ideone.com/KW4NGX Can anyone help?? asked 23 Dec '14, 13:03 1★abeyaar 334●2●21●40 accept rate: 30%

### The question has been closed for the following reason "The question is answered, right answer was accepted" by abeyaar 23 Dec '14, 15:35

 1 In line 58- parent.freq1=left_child.freq1+right_child.freq1*(FREQUENT.a[mid]==FREQUENT.a[parent.start]?1:0); parent.freq2=right_child.freq2+left_child.freq2*(FREQUENT.a[mid+1]==FREQUENT.a[parent.end]?1:0); Dont u think it should be mid+1 in the first line and mid in the second? Like- parent.freq1=left_child.freq1+right_child.freq1*(FREQUENT.a[mid+1]==FREQUENT.a[parent.start]?1:0); parent.freq2=right_child.freq2+left_child.freq2*(FREQUENT.a[mid]==FREQUENT.a[parent.end]?1:0); You add the right parts frequency only when the first value in right subtree is same as the first value in the parent. Likewise for the other part. Your given code fails here: https://ideone.com/d3zEqv The correct answer is 5 Do upvote if this helps :) Happy Coding! :) answered 23 Dec '14, 14:38 438●2●4●14 accept rate: 22% Thanks got AC. :) . Can you look into this?? http://discuss.codechef.com/questions/59332/spoj-gss2-wa (23 Dec '14, 15:35) abeyaar1★ Umm sure..do u mind accepting my answer? :D I would really appreciate that! (23 Dec '14, 20:52)

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×1,768
×1,138

question asked: 23 Dec '14, 13:03

question was seen: 1,157 times

last updated: 23 Dec '14, 20:53