diff --git a/Questions/Find_second_largest_Element_in_array.md b/Questions/Find_second_largest_Element_in_array.md new file mode 100644 index 0000000..bfe19b5 --- /dev/null +++ b/Questions/Find_second_largest_Element_in_array.md @@ -0,0 +1,27 @@ +# Find Second largest element in an array + +Given an array of integers, our task is to write a program that efficiently finds the second largest element present in the array. + +## Input Format + +First line contains T that denotes the number of test cases. This is followed by T lines, each containing an integer, N. + + +## Output Format + +Print the required answer for each test case. + + +### Sample Input and Output + +``` +Input : arr[] = {12, 35, 1, 10, 34, 1} +Output : The second largest element is 34. + +Input : arr[] = {10, 5, 10} +Output : The second largest element is 5. + +Input : arr[] = {10, 10, 10} +Output : The second largest does not exist. + +``` diff --git a/Solutions/Multiple_of_3_and_5.py b/Solutions/Multiple_of_3_and_5.py new file mode 100644 index 0000000..5f1ee47 --- /dev/null +++ b/Solutions/Multiple_of_3_and_5.py @@ -0,0 +1,10 @@ +def sumOfMultiple(): + + multiplyList = []; + for i in range(1000): + if i%3 == 0 or i%5 == 0: + multiplyList.append(i) + + return sum(multiplyList) + +print(sumOfMultiple()) diff --git a/Solutions/Sum_square_difference.cpp b/Solutions/Sum_square_difference.cpp new file mode 100644 index 0000000..53328f9 --- /dev/null +++ b/Solutions/Sum_square_difference.cpp @@ -0,0 +1,22 @@ +#include + +using namespace std; + +int main() +{ + int number; + long sumOfSqure, squreOfSum, difference; + + cout<<"Enter Natural Number --> "; + std::cin >> number; + + squreOfSum = (number*(number + 1)) / 2; //formula to find sum of first n natural number. + squreOfSum = squreOfSum * squreOfSum; + + sumOfSqure = (number*(number + 1)*(2*number + 1)) / 6; //formula to find sum of squre of first n natural numbers. + + difference = squreOfSum - sumOfSqure; + + cout<<"Difference of the sum squre is --> "< ")) + +squreOfSum = math.pow((number*(number + 1)) // 2, 2) +sumOfSqure = (number*(number + 1)*(2*number + 1)) // 6 + +print("Difference of the sum squre is --> ", squreOfSum - sumOfSqure)