From 698ae450afc65c5a77464f45f45f887a2410a1ed Mon Sep 17 00:00:00 2001 From: anand-w <73929247+anand-w@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:23:33 +0530 Subject: [PATCH 1/3] Create solution1.cpp --- Problem Statement 1/solution1.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Problem Statement 1/solution1.cpp diff --git a/Problem Statement 1/solution1.cpp b/Problem Statement 1/solution1.cpp new file mode 100644 index 0000000..5190edf --- /dev/null +++ b/Problem Statement 1/solution1.cpp @@ -0,0 +1,19 @@ + int getMove(int n){ + for (int i = 1; i < n; i++){ + if (n % i == 0) + return i; + } + return -1; + } + + bool divisorGame(int n) { + vector dp; + dp.push_back(n); + int move = getMove(n), i = 0; + + while (move != -1){ + dp.push_back(dp[i] - move); + move = getMove(dp[++i]); + } + + return dp.size() % 2 == 0; From 809f71b4db91ea8b57a1eb43dce209a175fe927a Mon Sep 17 00:00:00 2001 From: anand-w <73929247+anand-w@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:29:34 +0530 Subject: [PATCH 2/3] Create Solution2.cpp --- Problem Statement 2/Solution2.cpp | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Problem Statement 2/Solution2.cpp diff --git a/Problem Statement 2/Solution2.cpp b/Problem Statement 2/Solution2.cpp new file mode 100644 index 0000000..51b136f --- /dev/null +++ b/Problem Statement 2/Solution2.cpp @@ -0,0 +1,5 @@ + int countVowelStrings(int n) { + n+=4; + long long sol = n*(n-1)*(n-2)*(n-3)/24; + return sol; + } From f24eba5dc15a204d48ce462586bf6a4236da11b8 Mon Sep 17 00:00:00 2001 From: anand-w <73929247+anand-w@users.noreply.github.com> Date: Sun, 24 Apr 2022 15:32:25 +0530 Subject: [PATCH 3/3] Create Solution3.cpp --- Problem Statement 3/Solution3.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Problem Statement 3/Solution3.cpp diff --git a/Problem Statement 3/Solution3.cpp b/Problem Statement 3/Solution3.cpp new file mode 100644 index 0000000..7c02d0a --- /dev/null +++ b/Problem Statement 3/Solution3.cpp @@ -0,0 +1,18 @@ +int solve(vector& arr, int k) { + int n=arr.size(); + vector t(n+1,0); + t[1]=arr[0]; + for(int i=2;i=0;j++) + { int maa=0; + for(int l=1;l<=j && i-l>=0;l++) + maa=max(maa,arr[i-l]); + temp=max(temp,t[i-j]+maa*j); + t[i]=temp; + } + } + return t[n]; + }