allcoding1
27.6K subscribers
2.2K photos
2 videos
77 files
853 links
Download Telegram
Goat Grazing
Astrome
Java

Telegram:-  @allcoding1
👎3
Send Questions
Astrome & IBM.....
Goat Grazing
Astrome


Telegram:-  @allcoding1
👍2
Send Questions
Astrome & IBM & juspay.....
allcoding1
Photo
Here's a Python program to simulate the given problem:

`python
def print_terrain(terrain):
for row in terrain:
print(''.join(row))

def flow_water(terrain, n):
water_level = int(terrain[n // 2][n // 2])
terrain[n // 2][n // 2] = 'W'

def can_flow(x, y, direction):
if direction == 'N':
return x > 0 and terrain[x-1][y] != 'W' and int(terrain[x-1][y]) <= water_level
elif direction == 'S':
return x < n - 1 and terrain[x+1][y] != 'W' and int(terrain[x+1][y]) <= water_level
elif direction == 'E':
return y < n - 1 and terrain[x][y+1] != 'W' and int(terrain[x][y+1]) <= water_level
elif direction == 'W':
return y > 0 and terrain[x][y-1] != 'W' and int(terrain[x][y-1]) <= water_level

def flow(x, y):
if can_flow(x, y, 'N'):
terrain[x-1][y] = 'W'
return True
if can_flow(x, y, 'S'):
terrain[x+1][y] = 'W'
return True
if can_flow(x, y, 'E'):
terrain[x][y+1] = 'W'
return True
if can_flow(x, y, 'W'):
terrain[x][y-1] = 'W'
return True
return False

while True:
print_terrain(terrain)
has_flown = False
for i in range(n):
for j in range(n):
if terrain[i][j] == 'W':
if flow(i, j):
has_flown = True
if not has_flown:
water_level += 1
print(f"Cannot flow, increasing water level to {water_level}")
break
if any(cell == 'W' and (i == 0 or j == 0 or i == n - 1 or j == n - 1) for i, row in enumerate(terrain) for j, cell in enumerate(row)):
print("Reached edge, exiting.")
break


n = 7
terrain = [
[494, 88, 89, 778, 984, 726, 587],
[340, 959, 220, 301, 639, 280, 290],
[666, 906, 632, 824, 127, 505, 787],
[673, 499, 843, 172, 193, 613, 154],
[544, 211, 124, 60, 575, 572, 389],
[635, 170, 174, 946, 593, 314, 300],
[620, 167, 931, 780, 416, 954, 275]
]

flow_water(terrain, n)



Python
Telegram:- @allcoding1_official
👍10
bool isPal(int n) {
    int r, s = 0, t;
    t = n;
    while (n > 0) {
        r = n % 10;
        s = (s * 10) + r;
        n = n / 10;
    }
    return (t == s);
}

int firstPal(int n) {
    int i = 1;
    while (true) {
        if (isPal(i)) {
            int d = 1 + log10(i);
            if (d == n)
                return i;
        }
        i++;
    }
}

void login(int d, string u, string p) {
    map<string, string> users = {
        {"user1", "pass1"},
        {"user2", "pass2"},
        {"user3", "pass3"},
        {"user4", "pass4"},
        {"user5", "pass5"}
    };

    if (users.find(u) != users.end() && users[u] == p) {
        int t = firstPal(d);
        cout << "Welcome " << u << " and the generated token is: token-" << t << endl;
    } else {
        cout << "UserId or password is not valid, please try again." << endl;
    }
}

IBM

Telegram:- @allcoding1
👍9
Odd Even Code
Python 3
IBM

Telegram:- @allcoding1

Code 1👆
Code 2👇

vector<int>solve(vector<int> arr, int transform) {
    for(int t = 0; t < transform; t++) {
        for(int i = 0; i < arr.size(); i++) {
            if(arr[i] % 2 == 0) {
                arr[i] -= 3;
            } else {
                arr[i] += 3;
            }
        }
    }
    return arr;
}

Odd Even
👍5
Code 1👆
Code 2👇

string solve(string bs) {
    map<string, string> nb = {
        {"001", "C"},
        {"010", "G"},
        {"011", "A"},
        {"101", "T"},
        {"110", "U"},
        {"000", "DNA"},
        {"111", "RNA"}
    };

    string ds = "";
    string t = nb[bs.substr(0, 3)];
    for(int i = 3; i < bs.length(); i += 3) {
        string b = bs.substr(i, 3);
        if(nb.find(b) != nb.end()) {
            string x = nb[b];
            if(t == "DNA" && x == "U") {
                x = "T";
            }
            ds += x;
        } else {
            ds += "Error";
        }
    }

    return ds;
}

DNA
IBM

Telegram:- @allcoding1
Valid user

Telegram:- @allcoding1
👍43
This media is not supported in your browser
VIEW IN TELEGRAM
🎯Amazon off Campus Drive 2024 Hiring Freshers As Associate Quality Services | 2.52-4 LPA

Job Role : Associate Quality Services
Qualification : BE/BTech/MCA/BSc/BCA/MSc
Experience : Freshers
Salary CTC : Rs 2.52-4 LPA

Apply Now:- www.allcoding1.com

Telegram:- @allcoding1
2👍2
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll solve(ll k, ll s) {
    auto comb = [](ll n) {
        return n * (n - 1) / 2;
    };

    if (k > 3 * s) return 0;

    ll ans = comb(k + 2);

    if (k > s) ans -= 3 * comb(k - s + 1);
    if (k - 2 >= 2 * s) ans += 3 * comb(k - 2 * s);

    return ans;
}

int main() {
    ll n, s;
    cin >> n >> s;
    cout << solve(s,n) << endl;
    return 0;
}

Distribute Car Toy
Service Now

Telegram:- @allcoding1
👍7
int solve(vector<int>& nums) {
    vector<int> s(nums);
    sort(s.begin(), s.end());
    int i = 0, j = nums.size() - 1;
    while (i < nums.size() && nums[i] == s[i]) {
        i++;
    }
    while (j > i && nums[j] == s[j]) {
        j--;
    }
    return j - i + 1;
}

Arrange the heights
Apple

Telegram:- @allcoding1
👍42
#include<bits/stdc++.h>
using namespace std;

void dfs(int node, vector<int>& vis, vector<vector<int>>& adj) {
    vis[node] = 1;
    for(auto it : adj[node]) {
        if(!vis[it]) {
            dfs(it, vis, adj);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            int x;
            cin >> x;
            if(x == 1) {
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }
    vector<int> vis(n, 0);
    int cc = 0;
    for(int i = 0; i < n; i++) {
        if(!vis[i]) {
            dfs(i, vis, adj);
            cc++;
        }
    }
    cout << cc << endl;
    return 0;
}

Telegram:- @allcoding1
👍7
def count(a, X):
    a.sort()
    ans = 0
    n = len(a)

    for i in range(n):
        if (i < n // 2):
            ans += max(0, a[i] - X)
        elif (i == n // 2):
            ans += abs(X - a[i])
        else:
            ans += max(0, X - a[i]);

    return ans

IBM
Telegram:- @allcoding1
👍3👏1
Cognizant Off Campus Hiring | Data Analyst – Fresher | Upto 7.5 LPA


Job RoleData Analyst
QualificationB.E/B.Tech
BatchAny Batch
CTC/SalaryUpto 7.5 LPA

Apply Now:- www.allcoding1.com

Telegram:- @allcoding1
👍2
🎯Deloitte National Level Hiring 2024 As Analyst Trainee | 4-8 LPA

Job Role Analyst Trainee
Qualification BE, B Tech, ME, M Tech, MCA
Location PAN India
Salary 4-8 LPA

Apply Now:- www.allcoding1.com

Telegram:- @allcoding1
👍6
🎯Wipro Recruitment 2024 For Banking Operations

Location: Chennai

Qualification: Any Graduate

Work Experience: Freshers / Experience

Apply Now:- www.allcoding1.com

Telegram:- @allcoding1
👍3🔥1