1 solutions
-
0
C++ :
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; int main() { char a[2000]; gets(a); int r=strlen(a);int s[24]={0}; for(int i=0;i<=r-1;i++) s[a[i]-97]++; for(int i=0;i<=r-1;i++) { if(s[a[i]-97]==1){ cout<<a[i]; return 0;} } }
Java :
import java.util.*; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int count=0; String b=""; String str=input.next(); String a[]=new String[str.length()]; for(int i=0;i<str.length();i++) { a[i]=str.substring(i,i+1); } for(int i=0;i<str.length();i++) { if(!a[i].equals("0")) { for(int j=i+1;j<str.length();j++) { if(a[i].equals(a[j])) { a[j]="0"; }else { count++; } } if(count==str.length()-(i+1)) { b=a[i]; break; }else { count=0; } } } System.out.println(b); } }
- 1
Information
- ID
- 541
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- (None)
- # Submissions
- 0
- Accepted
- 0
- Uploaded By