<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    emu in blogjava

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      171 隨筆 :: 103 文章 :: 1052 評論 :: 2 Trackbacks
    ReverseSubstring
    You are given a String input. You are to find the longest substring of 
    input such that the reversal of the substring is also a substring of 
    input. In case of a tie, return the string that occurs earliest in 
    input. 
    Definition 
    給你一個字符串,你再生成一個顛倒的字符串,從原串中找出任意子串能同時存在顛倒的字符串中, 
    求出最長子串 
    Class: 
    ReverseSubstring 
    Method: 
    findReversed 
    Parameters: 
    String 
    Returns: 
    String 
    Method signature: 
    String findReversed(String input) 
    (be sure your method is public) 
    類ReverseSubstring方法  public String findReversed(String input) 


    Notes 

    The substring and its reversal may overlap partially or completely. 

    The entire original string is itself a valid substring (see example 4). 
    Constraints 

    input will contain between 1 and 50 characters, inclusive. 

    Each character of input will be an uppercase letter ('A'-'Z'). 
    Examples 
    0) 


    "XBCDEFYWFEDCBZ" 
    Returns: "BCDEF" 
    We see that the reverse of BCDEF is FEDCB, which appears later in the 
    string. 
    顛倒的字符串為"ZBCDEFWYFEDCBX",原串中BCDEF也是顛倒的字符串的子串,并且為最長的 
    1) 


    "XYZ" 
    Returns: "X" 
    The best we can do is find a one character substring, so we implement 
    the tie-breaker rule of taking the earliest one first. 
    2) 


    "ABCABA" 
    Returns: "ABA" 
    The string ABA is a palindrome (it's its own reversal), so it meets the 
    criteria. 
    3) 


    "FDASJKUREKJFDFASIREYUFDHSAJYIREWQ" 
    Returns: "FDF" 


    4) 


    "ABCDCBA" 
    Returns: "ABCDCBA" 
    Here, the entire string is its own reversal. 
    This problem statement is the exclusive and proprietary property of 
    TopCoder, Inc. Any unauthorized use or reproduction of this information 
    without the prior written consent of TopCoder, Inc. is strictly 
    prohibited. (c)2003, TopCoder, Inc. All rights reserved.
    posted on 2005-12-13 13:35 emu 閱讀(1585) 評論(5)  編輯  收藏 所屬分類: google編程大賽模擬題及入圍賽真題

    評論

    # re: google中國編程挑戰賽資格賽真題 -- ReverseSubstring 2006-08-28 00:59 bitstream
    我想詢問一下google編程競賽的情況,以前沒參加過,還望不吝賜教。Qualification Round是不是舉行一整天?一共有幾道題目?比賽用的程序現在能否down下來練練手?
    望回復!感謝!  回復  更多評論
      

    # re: google中國編程挑戰賽資格賽真題 -- ReverseSubstring 2006-08-29 01:21 emu
    下個星期的資格賽說明是:
    The Qualification Round will be open from Tuesday, September 5, at 12:00 PM (noon) EDT (GMT/UTC -4) through Wednesday, September 6, at 12:00 PM (noon) EDT (GMT/UTC -4). During this 24-hour period, each competitor must complete one randomly generated problem set. All competitors will receive a score for their performance on that one problem set.

    如果你已經注冊參賽,在確認郵件的 PRACTICING FOR THE EVENT 一段中有關于賽前練手的信息,我收集的題目也可以用來練手。如果你還沒有注冊就抓緊注冊吧,不注冊是不能啟用competition arena來練手的。  回復  更多評論
      

    # re: google中國編程挑戰賽資格賽真題 -- ReverseSubstring 2006-08-29 17:12 bitstream
    謝謝!
    也就是說每人隨機抽一套題做。我剛注冊了,抽空下點題目看看。你這里的題目我基本都有收集,大多數題不難,只是用的時間太長。(有時間我會把我的解答貼到這里,還望多多指教)
    另外,可否就比賽給小弟一些建議?或者談談您參賽的經驗?
    感激不盡!Have a nice day!  回復  更多評論
      

    # re: google中國編程挑戰賽資格賽真題 -- ReverseSubstring 2006-09-04 20:27 小貓魚
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.*;


    public class ReverseSubstring {
    private static String original="";
    public static void main(String[] args) throws IOException {
    String s=input();
    String s1=reversed(s);
    System.out.println(findReversed(Reversedsub(s),Reversedsub( s1))+"結果");
    }
    static String findReversed(Hashtable orig,Hashtable reversed){

    Enumeration enum=orig.elements();
    String result=original.substring(0,1);
    while(enum.hasMoreElements()){
    String s=(String)enum.nextElement();

    if( s.equals(reversed.get(s))){
    if(s.length()>=result.length()){
    result=s;
    }

    }
    }

    return result;

    }
    static Hashtable Reversedsub(String s){
    String originals=s;
    Hashtable hash=new Hashtable();
    for(int m=0;m<originals.length();m++){
    for(int i=0;i<originals.length()-m;i++){
    String sub= originals.substring(i,i+m+1);

    hash.put(sub,sub);
    }
    }
    return hash;
    }

    static String reversed(String s){
    int len=0;
    char[] original=s.toCharArray();
    len= original.length;
    char[] rever=new char[len];
    int m=len-1;
    for( int i=0;i<=len-1;i++){
    rever[i]=original[m];
    m--;
    }
    return new String(rever);
    }
    static String input() throws IOException{
    int first=0;
    boolean stop=true;
    while(stop){
    if(first!=0){
    original="輸入出錯請重新輸入";
    }
    else{
    original="請輸入數據";
    }
    System.out.println(original);
    BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
    original=input.readLine();
    if(original.length()==0||original.length()>50){
    original="輸入出錯請重新輸入";
    }
    else{
    stop=false;
    }
    first+=1;
    }
    return original;
    }

    }  回復  更多評論
      

    # re: google中國編程挑戰賽資格賽真題 -- ReverseSubstring 2009-07-11 21:02 Mandy
    @小貓魚
    bool Strstr(const char cStr1[], const char cStr2[], int Start, int Count)
    {
    char *SubString = (char*)malloc(Count + 1);
    memcpy(SubString, cStr2+Start, Count);
    SubString[Count] = '\0';
    char *find = strstr(cStr1, SubString);
    free(SubString);
    return find == NULL?false:true;
    }

    int GetSubString(char cStr[], int iSeatCount)
    {
    int left=0;
    int right=iSeatCount-1;
    int startindex = 0;
    int last = 0;
    int templast = 0;
    char ch='\0';
    char *ReverseSubstring = (char*)malloc(iSeatCount + 1);
    memcpy(ReverseSubstring, cStr, iSeatCount + 1);
    while(left <= right)
    {
    ch = ReverseSubstring[left];
    ReverseSubstring[left] = ReverseSubstring[right];
    ReverseSubstring[right] = ch;
    left++;
    right = iSeatCount-1-left;
    }
    ReverseSubstring[iSeatCount] = '\0';
    for (int i=0; i<iSeatCount; i++)
    {
    templast = 1;
    while (Strstr(ReverseSubstring, cStr, i, templast) && templast <= iSeatCount - i)
    {
    templast++;
    }
    if ((templast - 1) > last)
    {
    startindex = i;
    last = templast - 1;
    }
    }
    printf("The StartPostion is %d and the last number is %d.\n", startindex, last);
    printf("The Max Common String is ");
    for (i=0; i<last; i++)
    {
    printf("%c", *(cStr+startindex+i));
    }
    printf("\n");
    return last;
    }  回復  更多評論
      

    主站蜘蛛池模板: 最新亚洲精品国偷自产在线 | 久久久精品国产亚洲成人满18免费网站 | 最近中文字幕无吗高清免费视频| 亚洲av无码成人黄网站在线观看| aaa毛片免费观看| 亚洲午夜无码久久久久| 国产精品九九久久免费视频| 亚洲中文字幕伊人久久无码| 老司机福利在线免费观看| 国产成人免费手机在线观看视频 | 亚洲日本久久久午夜精品| 日本三级2019在线观看免费| 亚洲女人初试黑人巨高清| 黄色网址免费大全| 在线亚洲午夜片AV大片| 精品久久免费视频| 高潮毛片无遮挡高清免费| 亚洲欧洲精品成人久久奇米网 | 久久亚洲精品成人无码网站| 无码国产精品一区二区免费 | 国产美女被遭强高潮免费网站| 国产亚洲美女精品久久| 亚洲精品色婷婷在线影院| 成人自慰女黄网站免费大全| 亚洲AV人无码激艳猛片| 妻子5免费完整高清电视| 亚洲AV性色在线观看| 精品国产日韩亚洲一区| 一区二区三区在线免费看| 色婷五月综激情亚洲综合| 亚洲M码 欧洲S码SSS222| 中文字幕无码一区二区免费| 亚洲成在人线中文字幕| 国产女高清在线看免费观看| 免费无码又爽又刺激一高潮| 亚洲无人区视频大全| 免费在线观看理论片| 欧洲精品99毛片免费高清观看 | 波多野结衣免费视频观看| 精品免费tv久久久久久久| 精品久久久久久亚洲精品|