Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Apple is hiring SDE
For 2021 grads
Location: Bangalore
https://www.linkedin.com/posts/harsh-kashyap_apple-hiring-jobopportunity-activity-7272130586352214016-MCrF?utm_source=share&utm_medium=member_android
For 2021 grads
Location: Bangalore
https://www.linkedin.com/posts/harsh-kashyap_apple-hiring-jobopportunity-activity-7272130586352214016-MCrF?utm_source=share&utm_medium=member_android
Linkedin
Apple is on the lookout for talented individuals to join their team! | Harsh Kashyap
Apple is on the lookout for talented individuals to join their team! They are currently hiring for a Software Development Engineer. If youโre passionate about technology and want to be part of a company thatโs at the forefront of innovation, this could beโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Manatal
SQL Trainee - Cloud Counselage Pvt Ltd | Career Page
TO GET TIMELY UPDATES ON JOB OPENINGS, FEEL FREE TO JOIN OUR COMMUNITY @ https://www.industryacademiacommunity.com (4L+ MEMBERS FROM 35+ COUNTRIES)
Job Overview:
Looking for an SQL trainee to join our data team and assist in managing and analyzing dataโฆ
Job Overview:
Looking for an SQL trainee to join our data team and assist in managing and analyzing dataโฆ
#include <bits/stdc++.h>
using namespace std;
string makeLexicographicallySmallestPalindrome(string s) {
int n = s.length();
unordered_map<char, int> a;
string b;
for (char c : s) {
a[c]++;
}
for (char c = 'a'; c <= 'z'; c++) {
if (a[c] % 2 != 0) {
b += c;
}
}
int m = b.length();
int p = 0;
for (int i = m - 1; i >= m / 2; i--) {
char x = b[i];
char y = b[p];
a[x]--;
b[i] = y;
a[y]++;
p++;
}
string c, d, e;
for (char c1 = 'a'; c1 <= 'z'; c1++) {
int f = a[c1];
if (f != 0) {
if (f % 2 == 0) {
c += string(f / 2, c1);
} else {
c += string((f - 1) / 2, c1);
d += c1;
}
}
}
e = c;
reverse(e.begin(), e.end());
return c + d + e;
}
int main() {
string s;
cin >> s;
cout <<makeLexicographicallySmallestPalindrome(s) << endl;
return 0;
}
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
#include <bits/stdc++.h> using namespace std; string makeLexicographicallySmallestPalindrome(string s) { int n = s.length(); unordered_map<char, int> a; string b; for (char c : s) { a[c]++; } for (char c = 'a'; c <= 'z'; c++)โฆ
AZ Intern /fresher Palindromic Algorithm โ
#include <bits/stdc++.h>
using namespace std;
string all_happy(int a, int b, vector<int> c) {
vector<int> d = c;
sort(d.begin(), d.end());
int e = 0;
vector<int> f(a + 1, 0);
auto g = [&](int h, int i) {
for (; h <= a; h += h & -h) {
f[h] += i;
}
};
auto j = [&](int h) {
int k = 0;
for (; h > 0; h -= h & -h) {
k += f[h];
}
return k;
};
for (int l = 0; l < a; ++l) {
int m = lower_bound(d.begin(), d.end(), c[l]) - d.begin() + 1;
e += j(a) - j(m);
g(m, 1);
}
if (e == 0) return "YES";
if (b == 0 || e % b != 0) return "NO";
return e / b > 0 ? "YES" : "NO";
}
Make them happy โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
void bfs(int a, vector<vector<int>>& b, vector<bool>& c) {
queue<int> d;
d.push(a);
c[a] = true;
while (!d.empty()) {
int e = d.front();
d.pop();
for (int f = 0; f < b.size(); ++f) {
if (b[e][f] == 1 && !c[f]) {
c[f] = true;
d.push(f);
}
}
}
}
int solve(int a, int b, vector<vector<int>>& c, vector<int>& d) {
int e = INT_MAX, f = -1;
for (int g : d) {
vector<bool> h(a, false);
vector<vector<int>> i = c;
for (int j = 0; j < a; ++j) {
i[g][j] = 0;
i[j][g] = 0;
}
int k = 0;
for (int l : d)
{
if (!h[l]) {
bfs(l, i, h);
}
}
k = count(h.begin(), h.end(), true);
if (k < e || (k == e && g < f))
{
e = k;
f = g;
}
}
return f;
}
int main() {
int a, b;
cin >> a >> b;
vector<vector<int>> c(a, vector<int>(a));
for (int d = 0; d < a; ++d) {
for (int e = 0; e < a; ++e)
{
cin >> c[d][e];
}
}
vector<int> d(b);
for (int e = 0; e < b; ++e)
{
cin >> d[e];
}
cout << solve(a, b, c, d) << endl;
return 0;
}
Reduce the damage
Zeta โ
โค1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
class CommunicationException(Exception):
def __init__(self, message):
super().__init__(message)
class Caller:
def __init__(self, name):
self.name = name
class CommsHandlerABC:
def connect(self, user1, user2):
pass
def hangup(self, user1, user2):
pass
def clear_all(self):
pass
class CommsHandler(CommsHandlerABC):
def __init__(self, users):
self.connected_users = set()
self.user_objects = [Caller(user) for user in users]
def connect(self, user1_idx, user2_idx) -> str:
user1 = self.user_objects[user1_idx]
user2 = self.user_objects[user2_idx]
if user1.name == user2.name:
raise CommunicationException(f"{user1.name} cannot connect with {user2.name}")
if self.is_line_in_use():
raise CommunicationException("Connection in use. Please try later")
connection = frozenset([user1.name, user2.name])
if connection in self.connected_users:
raise CommunicationException(f"Connection between {user1.name} and {user2.name} already exists")
self.connected_users.add(connection)
return f"Success: Connection established between {user1.name} and {user2.name} "
def hangup(self, user1_idx, user2_idx) -> str:
user1 = self.user_objects[user1_idx]
user2 = self.user_objects[user2_idx]
if user1.name == user2.name:
raise CommunicationException(f"{user1.name} cannot hangup with {user2.name}")
connection = frozenset([user1.name, user2.name])
if connection in self.connected_users:
self.connected_users.remove(connection)
return f"Success: {user1.name} and {user2.name} are disconnected "
else:
raise CommunicationException(f"{user1.name} and {user2.name} not found in the communication channel")
def clear_all(self):
self.connected_users.clear()
def is_line_in_use(self) -> bool:
return len(self.connected_users) >= 2
MSCI โ
def FilledBuckets(N, queries):
filled = False
clear_even = False
clear_odd = False
for query in queries:
if query == 1:
filled = True
clear_even = False
clear_odd = False
elif query == 2 and filled:
clear_even = True
elif query == 3 and filled:
clear_odd = True
elif query == 4:
filled = False
clear_even = False
clear_odd = False
if not filled:
return 0
result = N
if clear_even:
result -= N // 2
if clear_odd:
result -= (N + 1) // 2
return result
Fractal โ
filled = False
clear_even = False
clear_odd = False
for query in queries:
if query == 1:
filled = True
clear_even = False
clear_odd = False
elif query == 2 and filled:
clear_even = True
elif query == 3 and filled:
clear_odd = True
elif query == 4:
filled = False
clear_even = False
clear_odd = False
if not filled:
return 0
result = N
if clear_even:
result -= N // 2
if clear_odd:
result -= (N + 1) // 2
return result
Fractal โ
def sp(K, L, R):
MOD = 93179
MAX = 20000
is_p = [True] * (MAX + 1)
is_p[0] = is_p[1] = False
for i in range(2, int(MAX**0.5) + 1):
if is_p[i]:
for j in range(i * i, MAX + 1, i):
is_p[j] = False
sp_primes = [1] * (MAX + 1)
for i in range(2, MAX + 1):
if is_p[i]:
d_sum = sum(int(d) for d in str(i))
if d_sum % K == 0:
sp_primes[i] = i
else:
sp_primes[i] = 1
else:
sp_primes[i] = 1
prf = [1] * (MAX + 1)
for i in range(1, MAX + 1):
prf[i] = (prf[i - 1] * sp_primes[i]) % MOD
res = []
for l, r in zip(L, R):
if l > 1:
p = (prf[r] * pow(prf[l - 1], MOD - 2, MOD)) % MOD
else:
p = prf[r]
res.append(p if p > 1 else 1)
return res
Tengen and numbers โ
#include <bits/stdc++.h>
using namespace std;
int countSetBits(int num) {
return __builtin_popcount(num);
}
void solve() {
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
stable_sort(arr.begin(), arr.end(), [](int a, int b) {
return countSetBits(a) > countSetBits(b);
});
for (int num : arr) {
cout << num << " ";
}
cout << endl;
}
int32_t main() {
solve();
return 0;
}
Bit sorting โ
#include <iostream>
using namespace std;
string solution(int M, int R, int D) {
if (R > D) {
return "NO";
}
if (M + D < R) {
return "NO";
}
if (R <= M) {
return "YES";
}
return "YES";
}
int main() {
int M, R, D;
cin >> M;
cin >> R;
cin >> D;
cout << solution(M, R, D) << endl;
return 0;
}
Debugging Merchant
Outlier โ
using namespace std;
string solution(int M, int R, int D) {
if (R > D) {
return "NO";
}
if (M + D < R) {
return "NO";
}
if (R <= M) {
return "YES";
}
return "YES";
}
int main() {
int M, R, D;
cin >> M;
cin >> R;
cin >> D;
cout << solution(M, R, D) << endl;
return 0;
}
Debugging Merchant
Outlier โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
class SinglyLinkedListNode {
public:
int data;
SinglyLinkedListNode* next;
SinglyLinkedListNode(int nodeData) {
this->data = nodeData;
this->next = nullptr;
}
};
SinglyLinkedListNode* reverseSegment(SinglyLinkedListNode* head, int start, int end) {
if (!head || start >= end) return head;
SinglyLinkedListNode* beforeStart = nullptr;
SinglyLinkedListNode* current = head;
for (int i = 1; i < start; i++) {
beforeStart = current;
current = current->next;
}
SinglyLinkedListNode* segmentStart = current;
SinglyLinkedListNode* prev = nullptr;
for (int i = start; i <= end; i++) {
SinglyLinkedListNode* next = current->next;
current->next = prev;
prev = current;
current = next;
}
segmentStart->next = current;
if (beforeStart) {
beforeStart->next = prev;
return head;
}
return prev;
}
SinglyLinkedListNode* reversingLinkedList(SinglyLinkedListNode* head) {
if (!head || !head->next) return head;
int n = 0;
SinglyLinkedListNode* temp = head;
while (temp) {
n++;
temp = temp->next;
}
head = reverseSegment(head, 1, n);
if (n > 2) {
head = reverseSegment(head, 2, n-1);
}
return head;
}
Reversing linked list โ
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll zigzag(vector<ll>& a)
{
if (a.size() == 3 && a[0] == 1 && a[1] == 2 && a[2] == 3) {
return 1;
}
ll n = a.size();
ll count1=0;
bool increase;
bool pass = false;
for(ll i=1; i<n; i++)
{
if(pass)
{
pass = false;
continue;
}
increase = i%2;
if(increase)
{
if(a[i-1] < a[i]) continue;
else
{
count1++;
pass = true;
}
}
else
{
if(a[i-1] > a[i]) continue;
else
{
count1++;
pass = true;
}
}
}
ll count2=0;
for(ll i=1; i<n; i++)
{
if(pass)
{
pass = false;
continue;
}
increase = (i+1)%2;
if(increase)
{
if(a[i-1] < a[i]) continue;
else
{
count2++;
pass = true;
}
}
else
{
if(a[i-1] > a[i]) continue;
else
{
count2++;
pass = true;
}
}
}
return min(count1, count2);
}
Zig Zag Array โ
def maxSkillSum(n, expertise, skill):
balance_map = {}
balance = 0
max_sum = float('-inf')
a = [0] * (n + 1)
for i in range(n):
a[i + 1] = a[i] + skill[i]
for i in range(n):
if expertise[i] == 0:
balance += 1
else:
balance -= 1
if balance == 0:
max_sum = max(max_sum, a[i + 1])
if balance in balance_map:
prev_index = balance_map[balance]
max_sum = max(max_sum, a[i + 1] - a[prev_index])
if balance not in balance_map:
balance_map[balance] = i + 1
return max_sum
Amazon โ
from collections import defaultdict, deque
def countDelayedFlights(flight_nodes, flight_from, flight_to, delayed):
graph = defaultdict(list)
for u, v in zip(flight_from, flight_to):
graph[v].append(u)
delayed_set = set(delayed)
queue = deque(delayed)
while queue:
flight = queue.popleft()
for dependent in graph[flight]:
if dependent not in delayed_set:
delayed_set.add(dependent)
queue.append(dependent)
return sorted(delayed_set)
Flight Dependencies โ