Day 25: Running Time and Complexity Task A prime is a natural number greater than that has no positive divisors other than and itself. Given a number, , determine and print whether it's or .Note: If possible, try to come up with a primality algorithm, or see what sort of optimizations you come up with for an algorithm. Be sure to check out the Editorial after submitting your code!Input FormatThe first line contains an integer, , t.. 더보기 Day 24: More Linked Lists Task A Node class is provided for you in the editor. A Node object has an integer data field, , and a Node instance pointer, , pointing to another node (i.e.: the next node in a list).A removeDuplicates function is declared in your editor, which takes a pointer to the node of a linked list as a parameter. Complete removeDuplicates so that it deletes any duplicate nodes from the list and returns .. 더보기 Day 23: BST Level-Order Traversal Task A level-order traversal, also known as a breadth-first search, visits each level of a tree's nodes from left to right, top to bottom. You are given a pointer, , pointing to the root of a binary search tree. Complete the levelOrderfunction provided in your editor so that it prints the level-order traversal of the binary search tree.Hint: You'll find a queue helpful in completing this challen.. 더보기 Day 21: Generics Task Write a single generic function named printArray; this function must take an array of generic elements as a parameter (the exception to this is C++, which takes a vector). The locked Solution class in your editor tests your function.Note: You must use generics to solve this challenge. Do not write overloaded functions.Input FormatThe locked Solution class in your editor will pass different .. 더보기 Day 20: Sorting Consider the following version of Bubble Sort:for (int i = 0; i array[j + 1]) { int temp = array[j]; array[j] = array[j+1]; array[j+1] = temp; numberOfSwaps++; } } // If no elements were swapped during a traversal, array is sorted if (numberOfSwaps == 0) { break; } } return numberOfSwaps; } Integer getFirstElement() { return array[0]; } Integer getLastElement() { return array[array.length - 1]; .. 더보기 Day 19: Interfaces Task The AdvancedArithmetic interface and the method declaration for the abstract int divisorSum(int n) method are provided for you in the editor below. Write the Calculator class, which implements the AdvancedArithmeticinterface. The implementation for the divisorSum method must be public and take an integer parameter, , and return the sum of all its divisors.Note: Because we are writing multip.. 더보기 Day 18: Queues and Stacks Welcome to Day 18! Today we're learning about Stacks and Queues. Check out the Tutorial tab for learning materials and an instructional video!A palindrome is a word, phrase, number, or other sequence of characters which reads the same backwards and forwards. Can you determine if a given string, , is a palindrome?To solve this challenge, we must first take each character in , enqueue it in a queu.. 더보기 Day 17: More Exceptions Task Write a Calculator class with a single method: int power(int,int). The power method takes two integers, and , as parameters and returns the integer result of . If either or is negative, then the method must throw an exception with the message: n and p should be non-negative.Note: Do not use an access modifier (e.g.: public) in the declaration for your Calculator class.Input FormatInput from.. 더보기 Day 16: Exceptions - String to Integer Task Read a string, , and print its integer value; if cannot be converted to an integer, print Bad String.Note: You must use the String-to-Integer and exception handling constructs built into your submission language. If you attempt to use loops/conditional statements, you will get a score.Input FormatA single string, .Constraints, where is the length of string . is composed of either lowercase .. 더보기 Day 15: Linked List A Node class is provided for you in the editor. A Node object has an integer data field, , and a Node instance pointer, , pointing to another node (i.e.: the next node in a list).A Node insert function is also declared in your editor. It has two parameters: a pointer, , pointing to the first node of a linked list, and an integer value that must be added to the end of the list as a new Node objec.. 더보기 이전 1 2 3 4 다음