알고리즘/codefights

Challenge>formatString

Diademata 2019. 3. 6. 01:01
반응형

Remove extra white-spaces from the given string.


Example


For input = " abc   a aa  a a ", the output should be

formatString(input) = "abc a aa a a".


code>>


string formatString(string i) {

    return i.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Aggregate((l,r)=> l+" "+r);

}



문자열 처리에 C++은 최악...


반응형

'알고리즘 > codefights' 카테고리의 다른 글

18>arrayPacking  (0) 2021.04.17
17>Kill K-th Bit  (0) 2021.04.17
Challenge>fibonacciIndex  (0) 2019.03.06
16>metroCard  (0) 2019.02.24
15>willYou  (0) 2019.02.24