Giter Club home page Giter Club logo

leetcode-notes-python's Introduction

Hi there ๐Ÿ‘‹

  • M.S. in Applied Data Science @USC
  • B.E. in Software Engineering @BJUT
  • Ex Intern @Meta(Facebook) @SenseTime @Meituan

leetcode-notes-python's People

Contributors

xuyangwang0825 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kinsozheng

leetcode-notes-python's Issues

1.Two Sum

# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
        i1 = 0
        start = ListNode(0)
        l1_literal = 0
        l2_literal = 0
        flag = 0
        while not l1 == None:
            l1_literal += l1.val * 10 ** i1
            l1 = l1.next
            i1 += 1
        i2 = 0
        while not l2 == None:
            l2_literal += l2.val * 10 ** i2 
            l2 = l2.next
            i2 += 1
        result = str(l1_literal + l2_literal)
        for i in range(len(result)-1,-1,-1):
            if flag == 0:
                tmp = ListNode(int(result[i]))
                start = tmp
                tmp1 = tmp
                flag = 1
            else:
                tmp2 = ListNode(int(result[i]))
                tmp1.next = tmp2
                tmp1 = tmp1.next
        return start

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.