D-509 | Max sum in the configuration | gfg potd 06 June
Vložit
- čas přidán 4. 06. 2024
- Our 509 Days of Code- 6th June GeeksForGeeks Problem Of The Day - JAVA
ALL CP/DSA RESOURCES : linktr.ee/aksh_yay
Asked in Google - • D-381 Find the String ...
Interview Experience Playlist - • Brillio Software Devel...
Leetcode Interview preparation - • LeetCode 136. Single N...
GFG POTD - • D-334 Number Of Enclav...
Topics Wise
----------------------------------------------
Bitwise - • D-468 Gray to Binary e...
Recursion and BackTracking - • Lec-1 What is Recursio...
Binary Trees - • What is a Binary Tree ?
Binary Search Tree - • Floor in BST | DSA S...
Graphs - • Day 312/365 - Print ad...
Dynamic Programming - • What is Dynamic Progra...
Disjoint Set - • D-452 Possible Paths i...
Trie - • D-415 Insert and Searc...
Heaps - • DAY 25 Longest Perfect...
Arrays - • Day-401Maximum Meeting...
Number Theory - • 204. Count Primes - (A...
Use code for 10% off on GFG : "AKSHAYS10"
practice.geeksforgeeks.org/co...
----------------------------------------------
Reference Videos
1. Time complexity Logic of 10^8 -constraint analysis
• Trick the TLE | How t...
GitHub: github.com/AkshayAnil1080
Follow 👉DSA repository - github.com/AkshayAnil1080/DSA
Practice Link - www.geeksforgeeks.org/problem...
Source code - github.com/AkshayAnil1080/DSA...
You can follow me on below platforms for all the latest updates
----------------------------------------------
LinkedIn - / akshay-a-26672a172
Twitter - / akshay_anil_
Instagram
/ code_with_akshay
/ itzz_aksh_yay
Show Support
----------------------------------------------
CZcams: / @akshayanil0-1
Telegram : t.me/+cEa2twkSqbBjYThl
Happy Coding 🤝.
.
.
"Join me daily as we tackle the #ProblemOfTheDay from #GeeksforGeeks! Enhance your skills in #DataStructures and #Algorithms with our comprehensive #DSA tutorials. Perfect for those preparing for #CodingInterviews and looking to ace their #TechJobs. Dive into #CodingProblems, #CompetitiveProgramming, and #CodeChallenges with solutions in #C++/#Java/#Python. Stay ahead in your #InterviewPrep and #SoftwareEngineering journey. Don't miss out on our #CodingPractice sessions designed to help you master #DataStructuresAndAlgorithms. Follow for daily insights and tips on #Leetcode, #Hackerrank, and #Codeforces problems. #Programming #Coding #AlgorithmSolutions #CodeDaily."
#GFG #POTD #geeksforgeeks #problemoftheday #java
#AkshayAnil #dsa #code_with_akshay #dsa_with_akshay #dsasheet #programming #leetcodesolutions #gfg #gfgpotd #problemsolving #coding #softwareengineer #faang #amazon #microsoft #competitiveprogramming #dsasheet #interviewpreparation
Nice Explanation Understood 😃
Great 👍
Thanks a lot bhaiya 😊
🙌🙌💯
good one
🙌👍
Nice Explanation
🎉🙌
Good explanation 👏 ❤
🙌
👍
🙌
Here is the equivalent C++ code :
class Solution {
public:
long long max_sum(int arr[], int n) {
long long sum = 0;
long long prev_sum = 0;
// Calculating the initial value of prev_sum and sum
for(int i = 0; i < n; i++) {
prev_sum += 1LL * i * arr[i];
sum += arr[i];
}
long long ans = prev_sum;
// Iterating through the array to find the maximum sum
for(int i = 1; i < n; i++) {
long long curr_sum = prev_sum - (sum - arr[i-1]) + 1LL * arr[i-1] * (n - 1);
prev_sum = curr_sum;
if(curr_sum > ans) {
ans = curr_sum;
}
}
return ans;
}
};
👍
👍
🙌