Sort by

recency

|

356 Discussions

|

  • + 1 comment

    The problem description is unclear and misleading.

    The test cases do not use regex, and the algorithm does not require the use of regex, so why is it even mentioned in the problem description?

    start/end is not a good verb pairing for an API. It should be start/stop, or begin/end.

    Furthermore, the test cases require printing values to stdout, not implementing start/end APIs, so again, why are those even mentioned?

  • + 0 comments

    import re S = input() k = input()

    find_match = list(re.finditer(rf"(?=({k}))", S))

    if find_match: for i in find_match: print ((i.start(1), i.end(1)-1))

    else: print((-1, -1))

  • + 0 comments

    result

  • + 0 comments

    My solution:

    import re
    
    string = input()
    sample = input()
    matches = list(re.finditer(rf"(?={sample})", string))
    
    if (matches == []):
        print((-1, -1))
    for word in matches:
        print(tuple((word.start(), word.start() + len(sample) - 1 )))
    
  • + 0 comments
    import re
    S,k = input().strip(),input().strip()
    print(*([(m.start(1), m.end(1)-1) for m in re.finditer(r'(?=(' + re.escape(k) + r'))',S)] or [(-1, -1)]),sep='\n')