본문 바로가기

Print the Elements of a Linked List If you're new to linked lists, this is a great exercise for learning about them. Given a pointer to the head node of a linked list, print its elements in order, one element per line. If the head pointer is null (indicating the list is empty), don’t print anything.Input FormatThe void Print(Node* head) method takes the head node of a linked list as a parameter. Each struct Node has a data field (.. 더보기
Left Rotation A left rotation operation on an array of size shifts each of the array's elements unit to the left. For example, if left rotations are performed on array , then the array would become .Given an array of integers and a number, , perform left rotations on the array. Then print the updated array as a single line of space-separated integers.Input FormatThe first line contains two space-separated int.. 더보기
Dynamic Array Create a list, , of empty sequences, where each sequence is indexed from to . The elements within each of the sequences also use -indexing.Create an integer, , and initialize it to .The types of queries that can be performed on your list of sequences () are described below:Query: 1 x yFind the sequence, , at index in .Append integer to sequence .Query: 2 x yFind the sequence, , at index in .Find.. 더보기
2D Array - DS 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.. 더보기
Arrays - DS An array is a type of data structure that stores elements of the same type in a contiguous block of memory. In an array, , of size , each memory location has some unique index, (where ), that can be referenced as (you may also see it written as ).Given an array, , of integers, print each element in reverse order as a single line of space-separated integers.Note: If you've already solved our C++ .. 더보기
Sorting: Bubble Sort Consider the following version of Bubble Sort:for (int i = 0; i a[j+1]){ int tmp = a[j+1]; a[j+1] = a[j]; a[j] = tmp; count++; } } } System.out.println("Array is sorted in " + count + " swaps."); System.out.println("First Element: " + a[0]); System.out.println("Last Element: " + a[a.length-1]); } } 더보기
Heaps: Find the Running Median The median of a dataset of integers is the midpoint value of the dataset for which an equal number of integers are less than and greater than the value. To find the median, you must first sort your dataset of integers in non-decreasing order, then:If your dataset contains an odd number of elements, the median is the middle element of the sorted sample. In the sorted dataset , is the median.If yo.. 더보기
Day 29: Bitwise AND Task Given set . Find two integers, and (where ), from set such that the value of is the maximum possible and also less than a given integer, . In this case, represents the bitwise ANDoperator.Input FormatThe first line contains an integer, , the number of test cases. Each of the subsequent lines defines a test case as space-separated integers, and , respectively.ConstraintsOutput FormatFor each.. 더보기
Day 28: RegEx, Patterns, and Intro to Databases Task Consider a database table, Emails, which has the attributes First Name and Email ID. Given rows of data simulating the Emails table, print an alphabetically-ordered list of people whose email address ends in .Input FormatThe first line contains an integer, , total number of rows in the table. Each of the subsequent lines contains space-separated strings denoting a person's first name and em.. 더보기
Day 27: Testing Objective This challenge is very different from the others we've completed because it requires you to generate a valid test case for a problem instead of solving the problem. There is no input to read, you simply have to generate and print test values for the problem that satisfy both the problem's Input Format and the criteria laid out in the Tasksection. Check out the Tutorial tab for an instr.. 더보기