def loop_main(temp):
    flds = temp.replace("[", "").replace("]", "").rstrip()

    ope_l = OperateListNode()
    node = ope_l.createListNode(flds)
    print("node = {0}".format(ope_l.ListNodeToString(node)))

    sl = Solution()
    time0 = time.time()

    result_node = sl.reverseList(node)

    time1 = time.time()

    print("result = {0}".format(ope_l.ListNodeToString(result_node)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
Exemple #2
0
def loop_main(temp):
    flds = temp.replace("\"","").replace("[","").replace("]","").rstrip()

    ope_l = OperateListNode()
    head = ope_l.createListNode(flds)
    print("head = {0}".format(ope_l.ListNodeToString(head)))

    sl = Solution()
    time0 = time.time()

    result = sl.sortList(head)

    time1 = time.time()

    print("result = {0}".format(ope_l.ListNodeToString(result)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
Exemple #3
0
def loop_main(temp):
    str_args = temp.replace("\"", "").replace("[[", "").replace("]]",
                                                                "").rstrip()
    flds = str_args.split("],[")

    ope_l = OperateListNode()
    node = ope_l.createListNode(flds[0])
    print("node = {0}".format(ope_l.ListNodeToString(node)))

    sl = Solution()
    time0 = time.time()

    sl.deleteNode(node)

    time1 = time.time()
    print("node = {0}".format(ope_l.ListNodeToString(node)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
def loop_main(temp):
    str_args = temp.replace("\"","").replace("[[","").replace("]]","").rstrip()
    flds = str_args.split("],[")

    ope_l = OperateListNode()
    head = ope_l.createListNode(flds[0])
    k = int(flds[1])
    print("head = {0}, k = {1:d}".format(ope_l.ListNodeToString(head), k))

    sl = Solution()
    time0 = time.time()

    result = sl.reverseKGroup(head, k)

    time1 = time.time()

    print("result = {0}".format(ope_l.ListNodeToString(result)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
Exemple #5
0
def loop_main(temp):
    str_args = temp.replace("\"","").replace("[[","").replace("]]","").rstrip()
    flds = str_args.split("],[")

    ope_l = OperateListNode()
    l1 = ope_l.createListNode(flds[0])
    l2 = ope_l.createListNode(flds[1])
    print("l1 = {0}".format(ope_l.ListNodeToString(l1)))
    print("l2 = {0}".format(ope_l.ListNodeToString(l2)))

    sl = Solution()
    time0 = time.time()

    result = sl.addTwoNumbers(l1, l2)

    time1 = time.time()

    print("result = {0}".format(ope_l.ListNodeToString(result)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
Exemple #6
0
def loop_main(temp):
    flds = temp.replace("\"", "").replace("[[",
                                          "").replace("]]",
                                                      "").rstrip().split("],[")

    ope_l = OperateListNode()
    head = ope_l.createListNode(flds[0])
    x = int(flds[1])
    print("head = {0}, x = {1:d}".format(ope_l.ListNodeToString(head), x))

    sl = Solution()
    time0 = time.time()

    result = sl.partition(head, x)

    time1 = time.time()

    print("result = {0}".format(ope_l.ListNodeToString(result)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
Exemple #7
0
def loop_main(temp):
    str_args = temp.replace("\"","").replace("[[","").replace("]]","").rstrip()
    flds = str_args.split("],[")

    ope_l = OperateListNode()
    node1 = ope_l.createListNode(flds[0])
    node2 = ope_l.createListNode(flds[1])

    print("node1 = {0}".format(ope_l.ListNodeToString(node1)))
    print("node2 = {0}".format(ope_l.ListNodeToString(node2)))

    sl = Solution()
    time0 = time.time()

    common_node = sl.getIntersectionNode(node1, node2)

    time1 = time.time()

    print("common_node = {0}".format(ope_l.ListNodeToString(common_node)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
Exemple #8
0
def loop_main(temp):
    flds = temp.replace("\"", "").replace("[[",
                                          "").replace("]]",
                                                      "").rstrip().split("],[")

    ope_l = OperateListNode()
    head = ope_l.createListNode(flds[0])
    pos = int(flds[1])
    print("head = {0}, x = {1:d}".format(ope_l.ListNodeToString(head), pos))

    sl = Solution()
    time0 = time.time()
    result = sl.detectCycle(head)

    time1 = time.time()

    if result is not None:
        print("result = {0}".format(ope_l.ListNodeToString(result)))
    else:
        print("result = None")
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
def loop_main(temp):
    flds = temp.replace("\"", "").replace("[[",
                                          "").replace("]]",
                                                      "").rstrip().split("],[")

    ope_l = OperateListNode()
    node = ope_l.createListNode(flds[0])
    print("node = {0}".format(ope_l.ListNodeToString(node)))

    n = int(flds[1])
    print("n = {0:d}".format(n))

    sl = Solution()
    time0 = time.time()

    result = sl.removeNthFromEnd(node, n)

    time1 = time.time()

    print("node = {0}".format(ope_l.ListNodeToString(result)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
def loop_main(temp):
    str_args = temp.replace("\"", "").replace("[[", "").replace("]]",
                                                                "").rstrip()
    flds = str_args.split("],[")

    lists = []
    ope_l = OperateListNode()
    if len(flds) >= 1 and flds[0] != "":
        for i in range(len(flds)):
            lists.append(ope_l.createListNode(flds[i]))
            print("lists[{0:d}] = {1} ".format(
                i, ope_l.ListNodeToString(lists[i])))
    else:
        lists = [None]

    sl = Solution()
    time0 = time.time()

    result = sl.mergeKLists(lists)

    time1 = time.time()

    print("result = {0}".format(ope_l.ListNodeToString(result)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))
Exemple #11
0
def loop_main(temp):
    str_args = temp.replace("\"",
                            "").replace(" ",
                                        "").replace("[[",
                                                    "").replace("]]",
                                                                "").rstrip()
    flds = str_args.split("],[")

    ope_l = OperateListNode()
    head = ope_l.createListNode(flds[0])
    print("nodes = {0}".format(ope_l.ListNodeToString(head)))

    val = int(flds[1])
    print("val = {0:d}".format(val))

    sl = Solution()
    time0 = time.time()

    result = sl.removeElements(head, val)

    time1 = time.time()

    print("result = {0}".format(ope_l.ListNodeToString(result)))
    print("Execute time ... : {0:f}[s]\n".format(time1 - time0))