WhiteHat Coding
Ir al canal en Telegram
650
Suscriptores
Sin datos24 horas
-27 días
-330 días
Archivo de publicaciones
public static int DifferenceSumOfDigits(int[] arr, int n) {
int sumOfDigits = 0;
int sumOfArray = 0;
for (int i = 0; i < n; i++) {
int num = arr[i];
while (num > 0) {
sumOfDigits += num % 10;
num /= 10;
}
}
for (int i = 0; i < n; i++) {
sumOfArray += arr[i];
}
int F1 = sumOfDigits * 10;
int F2 = sumOfArray % 10;
int F = F1 - F2;
return F;
}
Node* AddAlternateNodes(Node* head) {
if (head == nullptr) {
return nullptr;
}
Node* current = head;
while (current != nullptr && current->next != nullptr && current->next->next != nullptr) {
current->next->data += current->data;
current = current->next->next;
}
return head;
}
int sumOfDigits(int num) {
int sum = 0;
while (num > 0) {
sum += num % 10;
num /= 10;
}
return sum;
}
int DifferenceSumOfDigits(int arr[], int n) {
int f1 = 0;
int f2 = 0;
for (int i = 0; i < n; i++) {
f1 += sumOfDigits(arr[i]);
f2 += arr[i];
}
f1 *= 10;
f1 -= f2;
f1 %= 10;
return f1;
}
C++
int ans = INT_MIN;
int index = 0;
for (int i = 0; i < lenght; i++)
{
if (arr[i] > ans)
{
ans = arr[i];
index = i;
}
}
cout << ans << endl;
cout << index;
Accenture Hiring
Role: System and Application Services Associate
YOP: 2022, 2023
Salary: 3.3 LPA
Apply link:
https://indiacampus.accenture.com/myzone/accenture/1/jobs/3627/job-details
Bee careful protect yourself💯✅
Many groups are posting wrong answers 😂😂
Pls check it once if u mark solutions
Trust us Expect us 😊
Repost from Off Campus Updates | AMAZON | IBM | TCS | WIPRO | WILEY EDGE | VIRTUSA | MINDTREE | COGNIZANT
No need to hustle for job opportunities anymore, Be with us, I will try to post every job opportunities.
Devote your time for preparation, just check channel twice a day.
Share @Offcampus_000❤️✅
// Online Javascript Editor for free
// Write, Edit and Run your Javascript code using JS Online Compiler
function insertDashes(integer) {
// Convert the integer to a string
let str = integer.toString();
// Initialize the modified string
let modifiedStr = "";
// Iterate through each digit in the string
for (let i = 0; i < str.length; i++) {
// Check if the current digit and the next digit are both odd
if (parseInt(str[i]) % 2 !== 0 && parseInt(str[i + 1]) % 2 !== 0) {
modifiedStr += str[i] + "-";
} else {
modifiedStr += str[i];
}
}
return modifiedStr;
}
// Prompt the user for input
const input = prompt();
// Call the function to insert dashes
const output = insertDashes(input);
// Log the modified integer in the console
console.log(output);
share @whitehatcoding❤️
Visa Mock Interview available✅
Anyone need DM @Iloveu_143👨💻
Full visa preparation materials and mock to be taken....Daily..😊
https://drive.google.com/drive/folders/1-xmLdiHEtepyVeam-z2j3KdhZWPfCmL4
Complete Frontend + Server side Resources, Ebooks, Notes, Interview Questions Everything 🤩
React with any random emoji, if you can access the resources 😄🔥
Hope this helps you!!❤️
Share @whitehatcoding👨💻
#include <vector>
using namespace std;
typedef long long ll;
bool fn(vector<int>& a, vector<int>& b, ll x, ll mid) {
int n = a.size();
vector<int> vis(n, 0);
ll sum = 0;
for (int i = 0; i < n; i++) {
if (b[i] <= mid) {
sum += a[i];
vis[i] = 1;
}
}
ll mx = 0;
for (int i = 0; i < n; i++) {
if (!vis[i]) {
mx = max(mx, static_cast<ll>(a[i]));
}
}
return sum + mx >= x;
}
int scoreAndCost(int n, vector<int>& a, vector<int>& b, int x) {
ll ans = -1;
ll s = 0, e = 1e9;
while (s <= e) {
ll mid = (s + e) / 2;
if (fn(a, b, x, mid)) {
ans = mid;
e = mid - 1;
}
else {
s = mid + 1;
}
}
return static_cast<int>(ans);
}
100% working
import java.util.*;
public class Solution {
static int[] buildingBlocks(int n, int m, int[][] links, int[] a, int k, int[] d) {
// Write your code here.
int[] ans = new int[k];
List> adj = new ArrayList<>();
for(int i = 0; i < n; i++) adj.add(new HashSet<>());
for(int i = 0; i < m; i++){
adj.get(links[i][0]).add(links[i][1]);
adj.get(links[i][1]).add(links[i][0]);
}
Set decay = new HashSet<>();
for(int i = 0; i < k; i++){
if(i != 0){
removeNode(adj, d[i - 1]);
decay.add(d[i - 1]);
}
ans[i] = solve(adj, decay, a);
}
return ans;
}
static void removeNode(List> adj, int node){
for(int i = 0; i < adj.size(); i++){
Set curr = adj.get(i);
if(curr.contains(node)) curr.remove(node);
}
}
static int solve(List> adj, Set decay, int[] a){
int ans = 0;
int[] visited = new int[adj.size()];
for(int i = 0; i < adj.size(); i++){
if(decay.contains(i)) continue;
else if(visited[i] == 0){
ans = Math.max(ans, dfs(adj, i, visited, a));
}
}
return ans;
}
static int dfs(List> adj, int curr, int[] visited, int[] a){
visited[curr] = 1;
int ans = a[curr];
Set set = adj.get(curr);
for(int i : set){
if(visited[i] == 0){
ans ^= dfs(adj, i, visited, a);
}
}
return ans;
}
}
long long superMovement(int n, vector &a, int k) {
// Write your code here.
vector v(k - 1, LLONG_MAX); // Use LLONG_MAX for long long
long long ans = 0;
int j = 0;
for (int i = 0; i < n - 1; i++) {
if (j == k - 1) {
j = 0;
continue;
}
long long x = abs(a[i] - a[i + 1]);
v[j] = min(v[j], x);
j++;
}
for (auto i : v) {
ans += i;
}
return ans;
}
int terminalDefence(int n, int m, const vector& a, const vector& h, const vector& b, int k) {
vector> monsters;
for (int i = 0; i < m; i++) {
monsters.push_back({a[i], h[i]});
}
sort(monsters.begin(), monsters.end());
for (int i = 0; i < n; i++) {
int sentinelPos = b[i];
auto it = lower_bound(monsters.begin(), monsters.end(), make_pair(sentinelPos, 0));
if (it == monsters.end())
return 0;
int monsterPos = it->first;
int monsterHealth = it->second;
if (monsterPos == sentinelPos) {
if (monsterHealth <= k)
monsters.erase(it);
else
it->second -= k;
} else {
if (it == monsters.begin())
return 0;
it--;
monsterPos = it->first;
monsterHealth = it->second;
if (monsterHealth <= k)
monsters.erase(it);
else
it->second -= k;
}
}
return monsters.empty() ? 1 : 0;
}
vector binaryQueries(int n, vector &a,
int q,std::vector>& queries){
std::vector res;
for(const auto & query:queries){
int left = query[0];
int right=query[1];
int x =query[2];
for(int i=left;i<=right;i++){
a[i]^=x;
}
int orResult = a[left];
for(int i = left+1; i<=right; i++){
orResult |= a[i];
}
res.push_back(orResult);
}
return res;
}
