Forwarded from Coding Solutions Group
Please open Telegram to view this post
VIEW IN TELEGRAM
Forwarded from Off Campus job Updates- Placement Material
Zoho Placement Paper (1).pdf
454.2 KB
Get Our Premium Plan ZOHO EXAM 100% clearance gaurantee ping here
@saviour_01
@saviour_01
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 998244353
#define add(x,y) ((x+y)%MOD)
#define mul(x,y) ((x*y)%MOD)
#define sub(x,y) ((MOD+x-y)%MOD)
ll fastpow(ll x, ll y){
ll temp = 1;
while(y){
if(y&1)
temp = mul(temp, x);
x = mul(x, x);
y>>=1;
}
return temp;
}
ll inv(ll x){
return fastpow(x,MOD-2);
}
ll frac[200100];
ll C(ll n, ll i){
return mul(frac[n], inv(mul(frac[i], frac[n-i])));
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,k;
cin>>n>>k;
if(k>=n){
cout<<0<<endl;
return 0;
}
ll ans = 0;
frac[0] = 1;
for(int i=1;i<=n;++i){
frac[i] = mul(i, frac[i-1]);
}
for(int i=0;i<=n-k;++i){
ll temp = mul(C(n-k,i), fastpow(n-k-i,n));
if(i&1)
ans = sub(ans, temp);
else
ans = add(ans,temp);
}
ans = mul(ans, C(n, n-k));
if(k)
ans = mul(ans, 2);
cout<<ans<<endl;
}
CHESS GAME CODE
Telegram - https://t.me/Coding_solution_0
using namespace std;
#define ll long long
#define MOD 998244353
#define add(x,y) ((x+y)%MOD)
#define mul(x,y) ((x*y)%MOD)
#define sub(x,y) ((MOD+x-y)%MOD)
ll fastpow(ll x, ll y){
ll temp = 1;
while(y){
if(y&1)
temp = mul(temp, x);
x = mul(x, x);
y>>=1;
}
return temp;
}
ll inv(ll x){
return fastpow(x,MOD-2);
}
ll frac[200100];
ll C(ll n, ll i){
return mul(frac[n], inv(mul(frac[i], frac[n-i])));
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,k;
cin>>n>>k;
if(k>=n){
cout<<0<<endl;
return 0;
}
ll ans = 0;
frac[0] = 1;
for(int i=1;i<=n;++i){
frac[i] = mul(i, frac[i-1]);
}
for(int i=0;i<=n-k;++i){
ll temp = mul(C(n-k,i), fastpow(n-k-i,n));
if(i&1)
ans = sub(ans, temp);
else
ans = add(ans,temp);
}
ans = mul(ans, C(n, n-k));
if(k)
ans = mul(ans, 2);
cout<<ans<<endl;
}
CHESS GAME CODE
Telegram - https://t.me/Coding_solution_0
class Solution:
def calculateMinimumHP(self, dungeon: List[List[int]]) -> int:
def oneIfNotPos(a):
return a if a > 0 else 1
def f(i: int, j: int) -> int:
cached = self.cache.get((i, j))
if cached:
return cached
answer = min(oneIfNotPos(f(i, j + 1) - dungeon[i][j]), \
oneIfNotPos(f(i + 1, j) - dungeon[i][j]))
self.cache[(i, j)] = answer
return answer
m = len(dungeon)
n = len(dungeon[0])
# init cache to remove ifs from f
self.cache = {(m - 1, n - 1): oneIfNotPos(1 - dungeon[m - 1][n - 1])}
for i in range(0, m):
self.cache[(i, n)] = 1000 000000 # inf
for j in range(0, n):
self.cache[(m, j)] = 10000 00000 # inf
return f(0, 0)
Python
Dungeon Hunters
Telegram -https://t.me/Coding_solution_0
def calculateMinimumHP(self, dungeon: List[List[int]]) -> int:
def oneIfNotPos(a):
return a if a > 0 else 1
def f(i: int, j: int) -> int:
cached = self.cache.get((i, j))
if cached:
return cached
answer = min(oneIfNotPos(f(i, j + 1) - dungeon[i][j]), \
oneIfNotPos(f(i + 1, j) - dungeon[i][j]))
self.cache[(i, j)] = answer
return answer
m = len(dungeon)
n = len(dungeon[0])
# init cache to remove ifs from f
self.cache = {(m - 1, n - 1): oneIfNotPos(1 - dungeon[m - 1][n - 1])}
for i in range(0, m):
self.cache[(i, n)] = 1000 000000 # inf
for j in range(0, n):
self.cache[(m, j)] = 10000 00000 # inf
return f(0, 0)
Python
Dungeon Hunters
Telegram -https://t.me/Coding_solution_0
Forwarded from Off Campus Job Update
class Solution:
def calculateMinimumHP(self, dungeon: List[List[int]]) -> int:
def oneIfNotPos(a):
return a if a > 0 else 1
def f(i: int, j: int) -> int:
cached = self.cache.get((i, j))
if cached:
return cached
answer = min(oneIfNotPos(f(i, j + 1) - dungeon[i][j]), \
oneIfNotPos(f(i + 1, j) - dungeon[i][j]))
self.cache[(i, j)] = answer
return answer
m = len(dungeon)
n = len(dungeon[0])
# init cache to remove ifs from f
self.cache = {(m - 1, n - 1): oneIfNotPos(1 - dungeon[m - 1][n - 1])}
for i in range(0, m):
self.cache[(i, n)] = 1000 000000 # inf
for j in range(0, n):
self.cache[(m, j)] = 10000 00000 # inf
return f(0, 0)
Python
Dungeon Hunters
Telegram -https://t.me/Coding_solution_0
def calculateMinimumHP(self, dungeon: List[List[int]]) -> int:
def oneIfNotPos(a):
return a if a > 0 else 1
def f(i: int, j: int) -> int:
cached = self.cache.get((i, j))
if cached:
return cached
answer = min(oneIfNotPos(f(i, j + 1) - dungeon[i][j]), \
oneIfNotPos(f(i + 1, j) - dungeon[i][j]))
self.cache[(i, j)] = answer
return answer
m = len(dungeon)
n = len(dungeon[0])
# init cache to remove ifs from f
self.cache = {(m - 1, n - 1): oneIfNotPos(1 - dungeon[m - 1][n - 1])}
for i in range(0, m):
self.cache[(i, n)] = 1000 000000 # inf
for j in range(0, n):
self.cache[(m, j)] = 10000 00000 # inf
return f(0, 0)
Python
Dungeon Hunters
Telegram -https://t.me/Coding_solution_0
Tcs coding
1.D
2.break
3.arrayindexout
4.B
5.B
6.D
7.change control
Telegram -https://t.me/Coding_solution_0
1.D
2.break
3.arrayindexout
4.B
5.B
6.D
7.change control
Telegram -https://t.me/Coding_solution_0
Tcs coding
1.D
2.break
3.arrayindexout
4.B
5.B
6.D
7.change control
8.37
Telegram - https://t.me/Coding_solution_0
1.D
2.break
3.arrayindexout
4.B
5.B
6.D
7.change control
8.37
Telegram - https://t.me/Coding_solution_0
Tcs coding
1.D
2.break
3.arrayindexout
4.B
5.B
6.D
7.change control
8-37
9-10
10-2
Telegram - https://t.me/Coding_solution_0
1.D
2.break
3.arrayindexout
4.B
5.B
6.D
7.change control
8-37
9-10
10-2
Telegram - https://t.me/Coding_solution_0