×

# [closed] Why isn't the second implementation working?

 0 Here, I have two implementations of the problem Art, code- MAKEART in JAVA. The first one is giving me AC, while the seond one is giving wrong answer. Please help. It is a problem from SNACKDOWN 2016, pre-elimination round A. Thanks. 1st implementation- import java.io.*; class MAKEART { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); int i,T,N,j; System.out.println(); T=Integer.parseInt(br.readLine()); String s[]=new String[100011]; int a[]=new int[100011]; for(i=0;i

### The question has been closed for the following reason "The question is answered, right answer was accepted" by vijju123 27 May '17, 14:10

 2 In the second implementation, you are using char data type for accessing colours which have been given in int data type. In this way, you are matching the first digit of the integer with the first digit of another integer, not the complete integer value. For the below Input: 1 3 50 52 56 The output of your solution is: Yes Whereas the expected output should be: No answered 27 May '17, 13:51 329●2●9 accept rate: 21% 2 Lol i messed up with the order. :/ I misread that "first is not working" while second got AC. Better go get some sleep XD (27 May '17, 14:05) 2 OMG! Such a stupid mistake!!!! Sometimes, the obvious is just in front of you, and you still don't get it for hours!! I feel soooo stupid. (27 May '17, 14:07) 2 Thanks a lot (27 May '17, 14:08) 1 HAHAHAHA XDDDDDDDDDD Same here, i am also doing silly errors today. Better get some rest :) (27 May '17, 14:08) 2 You should @vijju123 (27 May '17, 14:12)
 0 For this test case 4 2 15 15 16 also the output is yes. You are using charAt(0) but Ci need not be a single digit number, you are checking only the first digit. answered 27 May '17, 14:08 1.1k●2●11 accept rate: 10%

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,302

question asked: 27 May '17, 13:23

question was seen: 272 times

last updated: 27 May '17, 14:12