Mall-Tarat Sakshi Contracto0 HackerRank Question - Binary x C Learning Path ← → Chackerrank.com/test/eifsidn6q35/questio
Posted: Thu May 05, 2022 12:51 pm
solve in java 8 in 30 minutes
solve in java 8
Mall-Tarat Sakshi Contracto0 HackerRank Question - Binary x C Learning Path ← → Chackerrank.com/test/eifsidn6q35/questions/1ecgba45c Info C# 43m left BETA Can't read the text? Switch theme (7) 5. Binary Number in a Linked List ALL A binary number is represented as a series of Os and 7's. In this challenge, the series will be in the form of a singly-linked list. Each node instance, a LinkedListNode, has a value, data, and a pointer to the next node, next. Given a reference to the head of a singly-linked list, convert the binary number represented to a decimal number. Example Libertin Linked list corresponding to the binary. number (010011)[2] or (19)[10]. Function Description Complete the function getNumber in the editor below. getNumber has the following parameter(s): binary: reference to the head of a singly-linked list of binary digits Ⓒ 1 2 3 4 5 Autocomplete Ready Ⓒ ^/ public static long getNumber (SinglyLinkedListNode binary) { long res= 0; SinglyLinkedListNode a binary; while (a != null) { res (res<<1) + (a.data); a = a.next; } return res; Test Results Custom Input Compiled successfully. All available test cases passed Test case 9 Input (stdin) Test case 10 1 7 Test case 11 A 3 e 4 1 Test case 12 8 5 1 6 e Test case 13 8 7 92 93 94 95 96 97 98 99 100 101 102 103 (2) >> I 3 Ⓡ Line: 74 Col: Run Tests Submit Run as Custom Input | Download Run Code
solve in java 8
Mall-Tarat Sakshi Contracto0 HackerRank Question - Binary x C Learning Path ← → Chackerrank.com/test/eifsidn6q35/questions/1ecgba45c Info C# 43m left BETA Can't read the text? Switch theme (7) 5. Binary Number in a Linked List ALL A binary number is represented as a series of Os and 7's. In this challenge, the series will be in the form of a singly-linked list. Each node instance, a LinkedListNode, has a value, data, and a pointer to the next node, next. Given a reference to the head of a singly-linked list, convert the binary number represented to a decimal number. Example Libertin Linked list corresponding to the binary. number (010011)[2] or (19)[10]. Function Description Complete the function getNumber in the editor below. getNumber has the following parameter(s): binary: reference to the head of a singly-linked list of binary digits Ⓒ 1 2 3 4 5 Autocomplete Ready Ⓒ ^/ public static long getNumber (SinglyLinkedListNode binary) { long res= 0; SinglyLinkedListNode a binary; while (a != null) { res (res<<1) + (a.data); a = a.next; } return res; Test Results Custom Input Compiled successfully. All available test cases passed Test case 9 Input (stdin) Test case 10 1 7 Test case 11 A 3 e 4 1 Test case 12 8 5 1 6 e Test case 13 8 7 92 93 94 95 96 97 98 99 100 101 102 103 (2) >> I 3 Ⓡ Line: 74 Col: Run Tests Submit Run as Custom Input | Download Run Code