HR30 Day 14: Scope

1 개요[ | ]

HR30 Day 14: Scope
해커랭크 30 Days of Code
문제 풀이
10-19 Day e
HR30 Day 10: Binary Numbers

HR30 Day 11: 2D Arrays

HR30 Day 12: Inheritance

HR30 Day 13: Abstract Classes

HR30 Day 14: Scope

HR30 Day 15: Linked List

HR30 Day 16: Exceptions - String to Integer

HR30 Day 17: More Exceptions

HR30 Day 18: Queues and Stacks

HR30 Day 19: Interfaces

2 Java[ | ]

    Difference(int[] a) {
        this.elements = a;
    }
    public void computeDifference() {
        int max = 1;
        int min = 100;
        for(int num:this.elements) {
            if( num > max ) max = num;
            if( num < min ) min = num;
        }
        this.maximumDifference = max - min;
    }

3 PHP[ | ]

    function __construct($arr) {
        $this->elements = $arr;
    }
    public function ComputeDifference() {
        $max = 1;
        $min = 100;
        foreach($this->elements as $num) {
            if( $num > $max ) $max = $num;
            if( $num < $min ) $min = $num;
        }
        $this->maximumDifference = $max - $min;
    }

4 Python[ | ]

	# Add your code here
    def computeDifference(self):
        mx = 1
        mn = 100
        for num in self.__elements:
            if( num > mx ): mx = num
            if( num < mn ): mn = num
        self.maximumDifference = mx - mn
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}