ch
Feedback

不要被骗子欺骗!Telemetrio 会找到并标记这些频道 👉 如果想查看标记,请订阅

IBM HACKERRANK CODING SOLUTIONS

IBM HACKERRANK CODING SOLUTIONS

前往频道在 Telegram

We provide help for all Exams... Anyone can contact me @AK_Coder for Exam clearance and interviews Trusted ✅

显示更多
未指定国家未指定类别
4 420
订阅者
无数据24 小时
无数据7 天
无数据30 天
帖子存档
Njan ayachu

2code code click save and next

/noforwards

i got interview mail today and shedule is tomorrow

import java.util.*; import java.math.*; class GFG { // Function to maximise the sum of selected numbers //by deleting occurrences of Ai-1 and Ai+1 public static int getMaximumSum (int arr[]) { // Number of elements in the array int n = arr.length; // Largest element in the array int max = -1; for(int i = 0; i < n; i++) { max = Math.max(max, arr[i]); } // An array to count the occurrence of each element int []freq = new int[max + 1]; for(int i = 0; i < n; i++) { freq[arr[i]]++; } // ans to store the result int ans = 0, i=max; // Using the above mentioned approach while(i>0){ // if occurence is greater than 0 if(freq[i] > 0){ // add it to ans ans += i; // decrease i-1th element by 1 freq[i-1]--; // decrease ith element by 1 freq[i]--; }else{ // decrease i i--; } } return ans; } public static void main(String[] args) { int []a = {1, 2, 3}; System.out.println(getMaximumSum(a)); } }

Both test case pass

Updated check 💯

Shiva, your message contains words listed on blacklist.

This is how we help in premium group🤩 💯✨ 🔴This was previous IRA that was on 2nd may 🔴Without single error in code..given💯💯 Just 100% results given for 2nd May 🚨if anyone need help for tomorrow IRA ping me @bulliea to join 9nd May premium group