# Help me in solving https://www.codechef.com/problems/CHEFCH?tab=statement

Here is my code. It is giving partially correct answer
Solution: 1017387964 - CodeChef

@srishti34
the logic is quite simple either your string at the end will be ±±±… or -±±+…
So just calculate the move to convert the string into them one by one and print the minimum moves among them.

I have done it but getting partially correct answer. I am not able to identify the error in my code.

@srishti34
Have corrected your code with the logic i was saying . Hope u will get it .

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int ans=0;
String str=sc.next();
StringBuilder s=new StringBuilder(str);
if(str.length()==1){
System.out.println(ans);
}
else{

for(int i=0;i<s.length();i++){
if(i%2==0)
{
if(s.charAt(i)=='-')
ans++;
}
else
{
if(s.charAt(i)=='+')
ans++;
}
}
int ans2=0;
for(int i=0;i<s.length();i++){
if(i%2==0)
{
if(s.charAt(i)=='+')
ans2++;
}
else
{
if(s.charAt(i)=='-')
ans2++;
}
}

System.out.println(Math.min(ans,ans2));
}
}
}
}
``````

Thanks