标签:arrays png rds turn split lambda info res color
题目描述:
提交:
class Solution: def arrangeWords(self, text: str) -> str: text = text.lower().split(" ") text.sort(key = lambda x:len(x)) text[0] = text[0][0].upper()+text[0][1:] return " ".join(text)
java:
class Solution { public String arrangeWords(String text) { String[] s = text.toLowerCase().split(" "); Arrays.sort(s, (o1, o2) -> { return o1.length()-o2.length(); }); char first=s[0].charAt(0); first=(char)(first-32); String temp= first +s[0].substring(1); s[0]=temp; String res=""; res= String.join(" ", s); return res; } }
leetcode-189周赛-1451-重新排列句子中的单词
标签:arrays png rds turn split lambda info res color
原文地址:https://www.cnblogs.com/oldby/p/12919015.html