"HR30 Day 15: Linked List"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 4개는 보이지 않습니다)
9번째 줄: 9번째 줄:
==Java==
==Java==
{{참고|HR30 Day 15: Linked List/Java}}
{{참고|HR30 Day 15: Linked List/Java}}
<source lang='Java'>
<syntaxhighlight lang='Java'>
     public static Node insert(Node head, int data) {
     public static Node insert(Node head, int data) {
         Node newNode = new Node(data);
         Node newNode = new Node(data);
15번째 줄: 15번째 줄:
             return newNode;
             return newNode;
         }
         }
         Node temp = head;
         Node node = head;
         while(temp.next != null) {
         while(node.next != null) {
             temp = temp.next;
             node = node.next;
         }
         }
         temp.next = newNode;
         node.next = newNode;
         return head;
         return head;
     }
     }
</source>
</syntaxhighlight>


==PHP==
==PHP==
{{참고|HR30 Day 15: Linked List/PHP}}
{{참고|HR30 Day 15: Linked List/PHP}}
<source lang='php'>
<syntaxhighlight lang='php'>
</source>
    function insert($head, $data) {
        $newNode = new Node($data);
        if(is_null($head)) {
            return $newNode;
        }
        $node = $head;
        while(!is_null($node->next)) {
            $node = $node->next;
        }
        $node->next = $newNode;
        return $head;
    }
</syntaxhighlight>
 
==Python==
{{참고|HR30 Day 15: Linked List/Python}}
<syntaxhighlight lang='Python'>
    def insert(self,head,data):
        #Complete this method
        newNode = Node(data)
        if head is None:
            return newNode
        node = head
        while node.next is not None:
            node = node.next
        node.next = newNode
        return head
</syntaxhighlight>

2021년 7월 31일 (토) 10:34 기준 최신판

1 개요[ | ]

HR30 Day 15: Linked List
해커랭크 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[ | ]

    public static Node insert(Node head, int data) {
        Node newNode = new Node(data);
        if(head == null) {
            return newNode;
        }
        Node node = head;
        while(node.next != null) {
            node = node.next;
        }
        node.next = newNode;
        return head;
    }

3 PHP[ | ]

    function insert($head, $data) {
        $newNode = new Node($data);
        if(is_null($head)) {
            return $newNode;
        }
        $node = $head;
        while(!is_null($node->next)) {
            $node = $node->next;
        }
        $node->next = $newNode;
        return $head;
    }

4 Python[ | ]

    def insert(self,head,data): 
        #Complete this method
        newNode = Node(data)
        if head is None:
            return newNode
        node = head
        while node.next is not None:
            node = node.next
        node.next = newNode
        return head
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}