Giter Club home page Giter Club logo

leetcode's Introduction

Leetcode: way 2 master

Python 3.7 Black

leetcode solutions:

I am currently working on putting all leetcode solutions in one place for people to use. I leveraged termcolor and pyfiglet to create clear separation for all the test examples and results. Please see input example and expected output below.

Input Example:

from helper import rprint
from typing import Any, Dict, Iterable, List, Optional, Union

nums1 = [1,2,3,1,1,3]
nums2 = [1,1,1,1]
nums3 = [1,2,3]
nums_lst = [nums1, nums2, nums3]


class Solution:
    def numIdenticalPairs(self, nums: List[int]) -> int:
        count = 0
        for index, num in enumerate(nums):
            if index == len(nums):
                pass
            else:
                for index2 in range(index+1, len(nums)):
                    if num == nums[index2]:
                        count += 1
        return count

rprint(Solution().numIdenticalPairs, nums_lst)

Result Example:

_____                           _        _
| ____|_  ____ _ _ __ ___  _ __ | | ___  / |_
|  _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \ | (_)
| |___ >  < (_| | | | | | | |_) | |  __/ | |_
|_____/_/\_\__,_|_| |_| |_| .__/|_|\___| |_(_)
                          |_|

********************************
The Input dataset is: [1, 2, 3, 1, 1, 3]
The Output dataset is: 4
********************************
 _____                           _        ____
| ____|_  ____ _ _ __ ___  _ __ | | ___  |___ \ _
|  _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \   __) (_)
| |___ >  < (_| | | | | | | |_) | |  __/  / __/ _
|_____/_/\_\__,_|_| |_| |_| .__/|_|\___| |_____(_)
                          |_|

********************************
The Input dataset is: [1, 1, 1, 1]
The Output dataset is: 6
********************************
 _____                           _        _____
| ____|_  ____ _ _ __ ___  _ __ | | ___  |___ /_
|  _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \   |_ (_)
| |___ >  < (_| | | | | | | |_) | |  __/  ___) |
|_____/_/\_\__,_|_| |_| |_| .__/|_|\___| |____(_)
                          |_|

********************************
The Input dataset is: [1, 2, 3]
The Output dataset is: 0

Pull Request:

Feel free to PR unsolved questions or better solutions

leetcode's People

Contributors

couyang24 avatar

Watchers

 avatar

Forkers

chuanqiliv

leetcode's Issues

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.