Algorithm: POJ1007 DNA sorting

Source: Internet
Author: User

This problem is relatively simple, the focus should be on how to reduce the number of cycles.

 Packagepractice;ImportJava.io.BufferedInputStream;ImportJava.util.Map;ImportJava.util.Scanner;ImportJava.util.TreeMap;/*** DNA Sorting * *@authorCaiyu * @date 2014-11-5*/ Public classPOJ1007 { Public Static voidMain (string[] args) {Scanner cin=NewScanner (NewBufferedinputstream (system.in)); intL =Cin.nextint (); intt =Cin.nextint ();        String s; Map<integer, string> m =NewTreemap<integer, string>();  for(inti = 0; I < T; i++) {s=Cin.next (); int[] Count =New int[L]; intInversion = 0;  for(intj = 0, len = l-1; J < Len; J + +) {Count[j]=S.charat (j);  for(inth = 0; H < J; h++) {                    if(Count[h] >Count[j]) inversion++;        }} m.put (inversion, s); }         for(String x:m.values ()) {System.out.println (x); }    }}

Algorithm: POJ1007 DNA sorting

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.