Answer:
You can simplify the problem down by recognizing that you just need to keep track of the integers you've seen in array that your given. You also need to account for edge cases for when the array is empty or the value you get would be greater than your max allowed value. Finally, you need to ensure O(n) complexity, you can't keep looping for every value you come across. This is where the boolean array comes in handy. See below -
public static int solution(int[] A)
{
int min = 1;
int max = 100000;
boolean[] vals = new boolean[max+1];
if(A.length == 0)
return min;
//mark the vals array with the integers we have seen in the A[]
for(int i = 0; i < A.length; i++)
{
if(A[i] < max + 1)
vals[A[i]] = true;
}
//start at our min val and loop until we come across a value we have not seen in A[]
for (int i = 1; i < max; i++)
{
if(vals[i] && min == i)
min++;
else if(!vals[i])
break;
}
if(min > max)
return max;
return min;
}
I agree with the programmers who think object-oriented programming is a superior approach to procedural programming.
<h3>Why is OOP better than procedural programming?</h3>
In terms of Security, Object-oriented programming is said to have more of a secure based than procedural programming, due to the level of abstraction or that is due to data hiding property.
Note that It hinders the access of data to any member functions of the same class and one cannot see a thing like that such as data hiding in the procedural programming framework.
Learn more about object-oriented programming from
brainly.com/question/12342989
#SPJ1
Answer: The tool that could be used to display only the rows containing the presidents who served two terms is the<u> Filter.</u>
Explanation:
If you are using Excel the filter tool is a great way to find the relevant information you are searching for. This will remove all other data from the search results, in this case presidents that only served one term.
The filtering of rows can be used three ways;
- By the value
- By the criteria
- By the format
By using the filter, you can find any phrase, number, dates, etc. Multiple columns can be filtered at the same time. Also, blank cells can be filtered out.
Answer:
// here is code in C++.
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int x=5,y=2,z=9;
int min;
// find the smallest value and assign to min
// if x is smallest
if(x < y && x < z)
// assign x to min
min=x;
// if y is smallest
else if(y < z)
// assign y to min
min=y;
// if z is smallest
else
// assign z to min
min=z;
// print the smallest
cout<<"smallest value is:"<<min<<endl;
return 0;
}
Explanation:
Declare and initialize variables x=5,y=2 and z=9.Then check if x is less than y and x is less than z, assign value of x to variable "min" .Else if value of y is less than value of z then smallest value is y, assign value of y to "min".Else z will be the smallest value, assign its value to "min".
Output:
smallest value is:2
<span>A wiki is this type of site. The users can, anonymously or with a profile, add to or delete content already posted. This gives the community the ability to add to the overall knowledge base on a specific subject. The site tracks changes through IP addresses to make sure that changes are not done maliciously.</span>