Commit 606ab984d82e39d0f01762c1a415e4bafb5faf59

Authored by Ronaldo
1 parent 15c20b0679
Exists in main

Update.

Showing 3 changed files with 42 additions and 0 deletions Side-by-side Diff

BasicsOfArrayStringGreedyandBitManipulation/FindMaximumAndMinimumElementInArray/MaxMinArray.cpp View file @ 606ab98
  1 +//
  2 +// Created by ronal on 2/11/2023.
  3 +// Problem description link.
  4 +// https://practice.geeksforgeeks.org/problems/find-minimum-and-maximum-element-in-an-array4428/1?category%5B%5D=Arrays&category%5B%5D=Arrays&page=1&query=category%5B%5DArrayspage1category%5B%5DArrays
  5 +
  6 +
  7 +
  8 +pair<long long, long long> getMinMax(long long a[], int n) {
  9 + pair<long long int, long long int> two;
  10 + long long int maximum;
  11 + long long int minimum;
  12 +
  13 + for(int i = 0; i < n; i++){
  14 + if(i == 0){
  15 + maximum = a[i];
  16 + minimum = a[i];
  17 + }else if(a[i] > maximum){
  18 + maximum = a[i];
  19 +
  20 + }else if(a[i] < minimum){
  21 + minimum = a[i];
  22 + }
  23 + }
  24 + two.first = minimum;
  25 + two.second = maximum;
  26 + return two;
  27 +
  28 +}
BasicsOfArrayStringGreedyandBitManipulation/ReverseAnArray/Problem2/ReverseAnArray.cpp View file @ 606ab98
1 1 //
2 2 // Created by ronal on 2/11/2023.
3 3 // Problem description link.
  4 +// https://practice.geeksforgeeks.org/problems/reverse-squared-sum/0
4 5 //
5 6  
6 7 #include <iostream>
BasicsOfArrayStringGreedyandBitManipulation/SumOfArrayElements/Problem/SumEleArray.cpp View file @ 606ab98
  1 +//
  2 +// Created by ronal on 2/11/2023.
  3 +// Problem description link.
  4 +// https://practice.geeksforgeeks.org/problems/sum-of-array-elements2502/1?category%5B%5D=Arrays&category%5B%5D=Arrays&page=1&query=category%5B%5DArrayspage1category%5B%5DArrays
  5 +
  6 +int sumElement(int arr[],int n)
  7 +{
  8 + int sum = 0;
  9 + for(int i = 0; i < n; i++){
  10 + sum += arr[i];
  11 + }
  12 + return sum;
  13 +}