본문 바로가기

Day 14: Scope The absolute difference between two integers, and , is written as . The maximum absolute differencebetween two integers in a set of positive integers, , is the largest absolute difference between any two integers in .The Difference class is started for you in the editor. It has a private integer array () for storing non-negative integers, and a public integer () for storing the maximum absolute .. 더보기
Day 13: Abstract Classes Task Given a Book class and a Solution class, write a MyBook class that does the following:Inherits from BookHas a parameterized constructor taking these parameters:string string int Implements the Book class' abstract display() method so it prints these lines:, a space, and then the current instance's ., a space, and then the current instance's ., a space, and then the current instance's .Note:.. 더보기
Queues: A Tale of Two Stacks A queue is an abstract data type that maintains the order in which elements were added to it, allowing the oldest elements to be removed from the front and new elements to be added to the rear. This is called a First-In-First-Out(FIFO) data structure because the first element added to the queue (i.e., the one that has been waiting the longest) is always the first one to be removed.A basic queue .. 더보기
Day 11: 2D Arrays Context Given a 2D Array, :1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 We define an hourglass in to be a subset of values with indices falling in this pattern in 's graphical representation:a b c d e f g There are hourglasses in , and an hourglass sum is the sum of an hourglass' values.Task Calculate the hourglass sum for every hourglass in , then print the maximum ho.. 더보기
Stacks: Balanced Brackets A bracket is considered to be any one of the following characters: (, ), {, }, [, or ].Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matched pairs of brackets: [], {}, and ().A matching pair of brackets is not balanced if the set of brackets .. 더보기
Linked Lists: Detect a Cycle A linked list is said to contain a cycle if any node is visited more than once while traversing the list.Complete the function provided in the editor below. It has one parameter: a pointer to a Node object named that points to the head of a linked list. Your function must return a boolean denoting whether or not there is a cycle in the list. If there is a cycle, return true; otherwise, return fa.. 더보기
Day 10: Binary Numbers Task Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation.Input FormatA single integer, .ConstraintsOutput FormatPrint a single base- integer denoting the maximum number of consecutive 's in the binary representation of .Sample Input 15 Sample Output 11 Sample Input 213 Sample Output.. 더보기
Day 9: Recursion Recursive Method for Calculating Factorial Task Write a factorial function that takes a positive integer, as a parameter and prints the result of ( factorial).Note: If you fail to use recursion or fail to name your recursive function factorial or Factorial, you will get a score of .Input FormatA single integer, (the argument to pass to factorial).ConstraintsYour submission must contain a recursi.. 더보기
Day 8: Dictionaries and Maps Task Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for. For each queried, print the associated entry from your phone book on a new line in the form name=phoneNumber; if an entry for is not found, print Not found instead.Note: Your phone book should be a Di.. 더보기
Day 7: Arrays Task Given an array, , of integers, print 's elements in reverse order as a single line of space-separated numbers.Input FormatThe first line contains an integer, (the size of our array). The second line contains space-separated integers describing array 's elements.Constraints, where is the integer in the array.Output FormatPrint the elements of array in reverse order as a single line of space-.. 더보기