confusing! wrong in this editor, but right in pycharm about case('AB' 2)


  • 0
    A

    when i submit it ,says" output :null expected:AB ", why is null?
    i run it in pycharm the output is "AB". why are they different?

    class Solution(object):
    def convert(self, s, numRows):
    """
    :type s: str
    :type numRows: int
    :rtype: str
    """
    if s=="" or numRows==1 or len(s)==1:
    return s
    else:
    n=2*numRows-2
    result=""
    for i in range(numRows):
    term=""
    if(i==0 or i==(numRows-1)):
    term=s[i::n]
    else:
    a=s[i::n]
    b=s[(n-i)::n]
    for j,ele in enumerate(a):
    if j<len(b):
    term=term+ele+b[j]
    else:
    term=term+ele
    result=result+term;


Log in to reply
 

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