From 2b57309d9b0eabefd275cf10241c0c2a7f9adb88 Mon Sep 17 00:00:00 2001 From: Ajay Makwana Date: Thu, 10 Oct 2019 00:48:39 +0530 Subject: [PATCH 1/3] created pyhton code to find addition of multiply of 3 and 5 --- Solutions/Multiple_of_3_and_5.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Solutions/Multiple_of_3_and_5.py 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()) From 14a23d844413d9e99a5c1634bb16f1161f5c3163 Mon Sep 17 00:00:00 2001 From: Ajay Makwana Date: Fri, 11 Oct 2019 00:58:17 +0530 Subject: [PATCH 2/3] added solution for sum squre difference --- Solutions/Sum_square_difference.cpp | 22 ++++++++++++++++++++++ Solutions/Sum_squre_difference.py | 8 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 Solutions/Sum_square_difference.cpp create mode 100644 Solutions/Sum_squre_difference.py 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) From 460b1e8dffa356e6f5898b5b99f430e0ea2adfd6 Mon Sep 17 00:00:00 2001 From: Ajay Makwana Date: Fri, 11 Oct 2019 01:14:02 +0530 Subject: [PATCH 3/3] added one question to find second largest number in given array --- .../Find_second_largest_Element_in_array.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Questions/Find_second_largest_Element_in_array.md 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. + +```