Simple yet powerful Python 28 ms solution.


  • 0
    P
    class Solution(object):
        def wordsTyping(self, sentence, rows, cols):
            """
            :type sentence: List[str]
            :type rows: int
            :type cols: int
            :rtype: int
            """
            string = ' '.join(sentence) + ' '
            strlen = len(string)
            counter = length = 0
            screenarea = rows*cols
            while True:
                length += strlen
                if length > screenarea:
                    break
                counter += 1
            return counter
    

  • 0
    I

    How much % does it beat?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.