diff --git a/5.leetcode/src/com/fanxb/common/Q68.java b/5.leetcode/src/com/fanxb/common/Q68.java new file mode 100644 index 0000000..fdd4d34 --- /dev/null +++ b/5.leetcode/src/com/fanxb/common/Q68.java @@ -0,0 +1,32 @@ +package com.fanxb.common; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created with IntelliJ IDEA + * + * @author fanxb + * Date: 2020/6/11 9:56 + */ +public class Q68 { + public List fullJustify(String[] words, int maxWidth) { + int length = words.length, int leftWidth = maxWidth; + List lineWord = new ArrayList<>(); + for (int i = 0; i < length; i++) { + if (lineWord.isEmpty()) { + lineWord.add(words[i]); + leftWidth -= words[i].length(); + } else { + if (leftWidth >= words[i].length() + 1){ + //可以放下 + }else{ + //hao + } + } + } + } + + public static void main(String[] args) { + } +}