1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GenaCL600 [577]
3 years ago
12

The input nums is supposed to be an array of unique integers ranging from 1 to nums.length (inclusive). However, there is a mist

ake: one of the numbers in the array is duplicated, which means another number is missing. Find and return the sum of the duplicated number and the missing number. Example: in the array [4, 3, 3, 1], 3 is present twice and 2 is missing, so 3 2
Computers and Technology
1 answer:
Elden [556K]3 years ago
6 0

The program is an illustration of loops.

Loops are used to perform repetitive and iterative operations.

The program in Python where comments are used to explain each line is as follows:

#This intializes the list

nums = [5,4,4,2,1]

#This gets the length of the list

size = len(nums)

#This iterates through the list

for i in range(size):

   #The following if condition determines the repeating number

   if nums[abs(nums[i])-1] > 0:

       nums[abs(nums[i])-1] = -nums[abs(nums[i])-1]

   else:

       repeating = abs(nums[i])

   #The following if condition determines the missing number

   if nums[i]>0:

       missing = i + 1

   

#This calculates and prints the sum of the missing and the repeating numbers

print(repeating+missing)

Read more about similar programs at:

brainly.com/question/13549861

You might be interested in
A port is the point at which a peripheral device attaches to or communicates with a computer or mobile device. True False
soldier1979 [14.2K]

Answer:

True

Explanation:

Computer is a device that is electronically designed to receive input, execute task on the input and give an output or resultant value. It's electronic hardware components are driven by a central software called the operating system. Input, output, memory and storage, and processor units are categories of the hardware components of the computer.

Peripheral hardware devices are externally attached to a computer system to maximise it's functionality. They are connected through extensions like ports, PCIe extensions etc.

5 0
3 years ago
What are your thoughts on copyright?<br><br> (Write 2 or more sentences)
victus00 [196]

Answer:

I look down on copyright. To take someone else's work and disguising it as your own seems like a form of theft.

5 0
3 years ago
Read 2 more answers
What is a 96.1791 weighted gpa in a 4.0 scale?
Oksanka [162]

Answer:

3.85 out of 4

Explanation:

As 96.1791 out of 100 gives 96.1791% calculated below:

Percentage formula: (Obtained value/total value)*100.......eq(1)

Putting values:

= (96.1791/100)*100

= 96.1791%

Now finding 96.1791% of 4:

Putting values in eq (1):

96.1791% = (Obtained value/4)*100

96.1791/100= (Obtained value/4)    (dividing by 100 on both sides)

0.961791 = (Obtained value/4)

4* 0.961791 = Obtained value          (multiplying 4 on both sides)

3.847164 = Obtained value

Then 96.1791% of 4 will be equal to: 0.961791 * 4  = 3.847164

Rounding off the answer to 2 decimal places:

=3.85    (As the digit on 3rd decimal place is greater than 5)

4 0
3 years ago
doubleIt is a function that takes one argument and returns no value . The argument is a pointer to int . The function doubles th
Mama L [17]

Answer:

void doublelt(int *number)

{

*number=*number*2;

}

Explanation:

This exercise is for you to learn and understand the PASS BY POINTER syntax. The importance of this is that if you didnt use a pointer you would have to RETURN an int from the function. in that case the code would be:

int doublelt(int number)

{

number=number*2;

       return number;

}

Passing by pointer manipulates the value by going inside the memory and where it resides. Without the pointer, the function would create COPIES of the argument you pass and delete them once the function ends. And you would have to use the RETURNED value only.

8 0
3 years ago
How does the computer help me with school work
Alex73 [517]
You are able to mark your answers on tests and save your work, while on paper, you get it taken away from you.
7 0
2 years ago
Read 2 more answers
Other questions:
  • Devices such as monitors and printers that are connected to a computer are called ________.
    12·1 answer
  • 50 POINTS!!!!
    8·1 answer
  • 13.
    8·1 answer
  • The number of square units required to cover a surface.
    13·1 answer
  • 2.13) A simple rule to estimate your ideal body weight is to allow 110 pounds for the first 5 feet of height and 5 pounds for ea
    15·1 answer
  • Brainliest for whoever adds me on snap<br> gianavaughn007
    15·2 answers
  • What is the primary purpose of source code editor features such as keyword hi lighting and auto-completion A.to speed up the cod
    7·1 answer
  • Question # 5
    6·1 answer
  • with the advent of technology one can experience special features such as 3D theater experiences true or false
    8·1 answer
  • computer have taken over a lot of boring, repetitive and time consuming as well as dangerous jobs.true or false
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!