From 07d7d4aeb801d39f5bf2d2461d87ad0e28f5ebf6 Mon Sep 17 00:00:00 2001 From: nandinisahu407 <109886925+nandinisahu407@users.noreply.github.com> Date: Sun, 30 Oct 2022 21:33:10 +0530 Subject: [PATCH] chore(CPlusPlus): add special index in an array (#1048) Co-authored-by: Arsenic <54987647+Arsenic-ATG@users.noreply.github.com> --- algorithms/CPlusPlus/Arrays/specialindex2.cpp | 65 +++++++++++++++++++ algorithms/CPlusPlus/README.md | 1 + 2 files changed, 66 insertions(+) create mode 100644 algorithms/CPlusPlus/Arrays/specialindex2.cpp diff --git a/algorithms/CPlusPlus/Arrays/specialindex2.cpp b/algorithms/CPlusPlus/Arrays/specialindex2.cpp new file mode 100644 index 00000000..f542d92d --- /dev/null +++ b/algorithms/CPlusPlus/Arrays/specialindex2.cpp @@ -0,0 +1,65 @@ +/* +@author: nandinisahu407 +special index-> if after deleting element from index i , sum of even index=sum of odd index +approach-> +after deleting ,previous element at odd index will be now at even index and vice versa +s_odd= odd[0 to i]+ even[i+1 to len] +s_even=even[0 to i]+odd[i+1 to len] + +*/ +#include +using namespace std; + +int main(){ + int num; + cout<<"enter length"<>num; + vector arr (num); + + for(int i=0;i>arr[i]; + } + + int count=0; + int s_even,s_odd; + for(int i=0;i