hackrank Sorting Array of Strings
Posted zjhangia
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hackrank Sorting Array of Strings相关的知识,希望对你有一定的参考价值。
https://www.hackerrank.com/challenges/sorting-array-of-strings/problem
1 int flag = 1; 2 int distinct_characters(const char* a); 3 4 int lexicographic_sort(const char* a, const char* b) { 5 6 if(strcmp(a, b) > 0){ 7 flag = 0; 8 }else flag = 1; 9 10 return flag; 11 } 12 13 int lexicographic_sort_reverse(const char* a, const char* b) { 14 if(strcmp(a, b) < 0){ 15 flag = 0; 16 }else flag = 1; 17 return flag; 18 } 19 20 int distinct_characters(const char* a){ 21 int dis_char = strlen(a); 22 int len = strlen(a); 23 for(int i = 0; i < len; i ++){ 24 if(a[i] != ‘