Answer:
See explaination
Explanation:
Keep two iterators, i (for nuts array) and j (for bolts array).
while(i < n and j < n) {
if nuts[i] == bolts[j] {
We have a case where sizes match, output/return
}
else if nuts[i] < bolts[j] {
this means that size of nut is smaller than that of bolt and we should go to the next bigger nut, i.e., i+=1
}
else {
this means that size of bolt is smaller than that of nut and we should go to the next bigger bolt, i.e., j+=1
}
}
Since we go to each index in both the array only once, the algorithm take O(n) time.
Answer:
The solution code is written in Python 3:
- def modifyList(listNumber):
- posCount = 0
- negCount = 0
-
- for x in listNumber:
- if x > 0:
- posCount += 1
- else:
- negCount += 1
-
- if(posCount == len(listNumber)):
- listNumber.append(max(listNumber))
-
- if(negCount == len(listNumber)):
- listNumber.append(min(listNumber))
-
- print(listNumber)
-
- modifyList([-1,-99,-81])
- modifyList([1,99,8])
- modifyList([-1,99,-81])
Explanation:
The key step to solve this problem is to define two variables, posCount and negCount, to track the number of positive value and negative value from the input list (Line 2 - 3).
To track the posCount and negCount, we can traverse through the for-loop and create if else statement to check if the current number x is bigger than 0 then increment posCount by 1 otherwise increment negCount (Line 5- 9).
If all number in the list are positive, the posCount should be equal to the length of the input list and the same rule is applied to negCount. If one of them happens, the listNumber will append either the maximum number (Line 11 -12) or append the minimum number (Line 14-15).
If both posCount and negCount are not equal to the list length, the block of code Line 11 -15 will be skipped.
At last we can print the listNumber (Line 17).
If we test our function using the three sets of input list, we shall get the following results:
[-1, -99, -81, -99]
[1, 99, 8, 99]
[-1, 99, -81]
It helps you determine the amount of watts a turbine produces because math is the only way to go
Photoshop is a software program developed by Adobe that allows users to edit graphics. It's used by graphic artists, designers and photographers, among others, and can enhance and manipulate images to improve their appearance. It's an excellent tool that makes photo editing easy and efficient.
Explanation:
- In the past, it produced creative printing or home publishing programs used for desktop publishing too, but the primary page layout software from Corel is CorelDraw
- Adobe InDesign is a desktop publishing and typesetting software application produced by Adobe Systems. It can be used to create works such as posters, flyers, brochures, magazines, newspapers, presentations, books and ebooks
- Adobe InDesign is a standard piece of publishing software, and is commonly used by professional typesetters to design the inside pages of books.
- Select an image, and then choose File > File Info
- Use the File Info dialog box to view or edit an image's metadata. This dialog box displays quite a bit of information. Many of the settings in it are important in the metadata.
- Metadata is a set of standardized information about a file, such as author name, resolution, color space, copyright, and keywords applied to it.