2016 360 written programming questions 1

Source: Internet
Author: User
Tags gz file

Last character

Is challenging a crackme you, the need to fill in the first few passwords are correctly guessed, but this last password, as if hidden a bit deep. The author of the Crackme also provocative in hiding a. tar.gz file, extracted, and wrote the last character you want is in the string below. This character is the first occurrence of a character in the entire string below. (For example, the string is Abaccdeff, then the correct character is B) However, the strings given below appear to be too long and too long to be found by manpower alone. So, you need to write a program to do it. The input file volume is large, please use some fast input and output means, do not recommend the use of Cin/cout, Java is not recommended to use scanner direct read and write.

Input Description:
The first line, a positive integer T (t≤20)  , represents the number of input data groups.
After the T line, each line is a string s. (The length of the 1≤s is ≤10 6 , guaranteeing that the ASCII code of the characters appearing in the string is within the range of [0x21,0x7f), that is, non-whitespace characters that can be displayed, and that there must be a solution)
Output Description:
A total of T-lines, one character c per line, representing the first character in the given string that appears only once.

Input Example:

2abaccdefftestonline
Output Example:
Bs


Code implementation:
Import Java.util.scanner;import Java.util.linkedhashset;import Java.util.iterator;public class Main{public static Voi        D Main (String args[]) {Scanner sc=new Scanner (system.in);        int N=sc.nextint ();            for (int i=0;i<n;i++) {String s=sc.next ();            int Len=s.length ();            Linkedhashset<character> set=new linkedhashset<character> ();            Linkedhashset<character> tmp=new linkedhashset<character> ();            int m=0; for (int j=0;j<len;j++) {if (Tmp==null | |!tmp.contains (S.charat (j))) {Set.add (S.charat                    (j));                        if (j+1! = set.size () +m) {Set.remove (S.charat (j));                        Tmp.add (S.charat (j));                    m+=2;                     }}else{m++;            }} iterator<character> It=set.iterator ();          Char C=it.next ();  System.out.println (c); }    }}

  

2016 360 written programming questions 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.