a***e 发帖数: 413 | 1 又改写了,还是通不过,有大侠能看出明显错误吗?好奇那些面试官对这类题怎么知道
到底写对没?
8 / 24 test cases passed.
多谢。
Input:
["Listen","to","many,","speak","to","a","few."], 6
Output:
["Listen","to ","many, ","speak ","to a","few. "]
Expected:
["Listen","to ","many, ","speak ","to a","few. "]
class Solution {
public:
vector fullJustify(vector &words, int L) {
int n ... 阅读全帖 |
|
a***e 发帖数: 413 | 2 我不知道这种情况怎么继续努力啦,只能看看别人的答案?我觉得自己的思路是对的啊,
。。。有人碰到类似情况吗?
Last executed input:
["My","momma","always","said,",""Life","was","like","a","box
","of","chocolates.","You","never","know","what","you're","gonna","get."],
12
Given an array of words and a length L, format the text such that each line
has exactly L characters and is fully (left and right) justified.
You should pack your words in a greedy approach; that is, pack as many words
as you can in each line. Pad extra spaces ' ' when ... 阅读全帖 |
|
z***y 发帖数: 73 | 3 for (int j = start; j
{
pos += words[j].length();
if (c
{
tmp.insert(pos, perspace+1, ' ');
pos+=perspace+1;
c++;
}
else
{
tmp.insert(pos, perspace, ' ');
} ... 阅读全帖 |
|
J***2 发帖数: 444 | 4 Dude,extraspace has the same serive,but 1/6 your charge. |
|
z***y 发帖数: 73 | 5 大概有三个问题:
1.
while (tmp.length() + words[i].length() + 1
应该i
2.
int pos = words[start].length() + perspace + extraspace+1;
我理解空格应该是均摊,比如4个词有5个空格,应该是2 2 1, 而不是 3 1 1
3.
最后一行要特殊处理,尾部加空格即可。 |
|
q*****e 发帖数: 433 | 6 在美国本来大家基本上都是以租房子为主谁都不免要搬家, 你说你把mail地址放朋友家
不是太大问题, 放你家当确实不是小事情, 甚至说是比住个活人还麻烦得问题呢. 没人
帮挺正常得还是租extraspace把, 一个月能几十块解决得事情求朋友没意思, |
|
|