Leecode刷题之旅-C语言/python-14.最长公共前缀

/*
 * @lc app=leetcode.cn id=14 lang=c
 *
 * [14] 最长公共前缀
 *
 * https://leetcode-cn.com/problems/longest-common-prefix/description/
 *
 * algorithms
 * Easy (32.10%)
 * Total Accepted:    54.4K
 * Total Submissions: 169.3K
 * Testcase Example:  '["flower","flow","flight"]'
 *
 * 编写一个函数来查找字符串数组中的最长公共前缀。
 * 
 * 如果不存在公共前缀,返回空字符串 ""。
 * 
 * 示例 1:
 * 
 * 输入: ["flower","flow","flight"]
 * 输出: "fl"
 * 
 * 
 * 示例 2:
 * 
 * 输入: ["dog","racecar","car"]
 * 输出: ""
 * 解释: 输入不存在公共前缀。
 * 
 * 
 * 说明:
 * 
 * 所有输入只包含小写字母 a-z 。
 * 
 */

char* longestCommonPrefix(char** strs, int strsSize) {
    if(strsSize == 0) {
        return "";
    }
    int index = 0, i = 0;
    char flag = strs[0][index];
    while(flag) {
        for(i = 1; i < strsSize; i++) {
            if(strs[i][index] != flag)
                break;
        }
        if(i < strsSize)
            break;
        flag = strs[0][++index];
    }
    strs[0][index] = '