Coding | EXAMS | IBM ACCENTURE | VIRTUSA | IBM | AMAZON | TCS | EPAM | WILEY EDGE | TECH MAHINDRA | JPMORGAN | HCL | WIPRO
3.37K subscribers
1.13K photos
3 videos
17 files
373 links
Main channel https://t.me/Coding_000
Contact Admin 👉 @ILOVEU_143 for booking your exam slots
Web- https://coding000.github.io/Projects/
💯% clearance in any placement exams
OffCampus -https://t.me/Offcampus_000
Discussion- https://t.me/exams_discussion
Download Telegram
My request to our group family don't trust anyone simply and don't lose money 🙏🥹
👍2👏1
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++
👍2
include <iostream>
 
struct Node {
    int data;
    struct Node* next;
};
 
struct Node* AddAlternateNodes(struct Node* head) {
    if (head == nullptr) {
        return nullptr;
    }
 
    struct Node* curr = head;
    while (curr != nullptr && curr->next != nullptr && curr->next->next != nullptr) {
        int sum = curr->data + curr->next->next->data;
        curr->next->next->data = sum;
        curr = curr->next->next;
    }
 
    return head;
}
 
// Function to print the linked list
void PrintList(struct Node* head) {
    struct Node* temp = head;
    while (temp != nullptr) {
        std::cout << temp->data << " ";
        temp = temp->next;
    }
    std::cout << std::endl;
}
 
// Test case
int main() {
    struct Node* head = new Node;
    struct Node* second = new Node;
    struct Node* third = new Node;
    struct Node* fourth = new Node;
    struct Node* fifth = new Node;
 
    // Assign data values and connect nodes
    head->data = 1;
    head->next = second;
    second->data = 2;
    second->next = third;
    third->data = 3;
    third->next = fourth;
    fourth->data = 4;
    fourth->next = fifth;
    fifth->data = 5;
    fifth->next = nullptr;
 
    std::cout << "Original Linked List: ";
    PrintList(head);
 
    head = AddAlternateNodes(head);
 
    std::cout << "Modified Linked List: ";
    PrintList(head);
 
    // Clean up memory
    delete fifth;
    delete fourth;
    delete third;
    delete second;
    delete head;
 
    return 0;
}

Alternate nodes in python
👍2
public class Main {
    public static int DesiredArray(int[] Arr, int N, int K) {
        int sum = 0;
        int count = 0;
        int i = 1;
       
        while (count < K) {
            boolean divisible = false;
           
            for (int j = 0; j < N; j++) {
                if (i % Arr[j] == 0) {
                    divisible = true;
                    break;
                }
            }
           
            if (!divisible) {
                sum += i;
                count++;
            }
           
            i++;
        }
       
        return sum;
    }
   
    
Java

Special Number
👍2