重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
class Solution {public String largestMerge(String word1, String word2) {StringBuilder sb = new StringBuilder();
int i = 0, j = 0;
while (i< word1.length() || j< word2.length()) {if (i< word1.length() && word1.substring(i).compareTo(word2.substring(j)) >0) {sb.append(word1.charAt(i));
++i;
} else {sb.append(word2.charAt(j));
++j;
}
}
return sb.toString();
}
}
pythonclass Solution:
def largestMerge(self, word1: str, word2: str) ->str:
# 貪心!
merge = ''
i, j, m, n = 0, 0, len(word1), len(word2)
while i< m or j< n:
# 表明沿著這個方向效益大!
if word1[i:] >word2[j:]:
merge += word1[i]
i += 1
else:
merge += word2[j]
j += 1
return merge
總結你是否還在尋找穩定的海外服務器提供商?創新互聯www.cdcxhl.cn海外機房具備T級流量清洗系統配攻擊溯源,準確流量調度確保服務器高可用性,企業級服務器適合批量采購,新人活動首月15元起,快前往官網查看詳情吧