WhiteHat Coding
Відкрити в Telegram
650
Підписники
Немає даних24 години
-27 днів
-330 день
Архів дописів
TATA Steel AEP Exam Pattern:
No. of Questions: 100 MCQs
Duration: 2 Hour
Negative Marking: 1/3
Sections:
Verbal Ability
Numeric Reasoning
Analytical Ability
Problem-Solving
Technical
Anybody have any exam
share your Questions 👇👇
i will share codes/ans here for all for free for spreading happiness 😊
Share with your friends and in college groups
Sharing = caring = spreading happiness
Q)HTTP URL Parsing
def parseURL(url):
# parse protocol
protocol_end = url.find("://")
protocol = url[:protocol_end]
remaining_url = url[protocol_end+3:]
# parse hostname and port
path_start = remaining_url.find("/")
if path_start == -1:
path_start = len(remaining_url)
host_port = remaining_url[:path_start]
if ":" in host_port:
host, port = host_port.split(":")
else:
host = host_port
if protocol == "http":
port = "80"
else:
port = "443"
# parse resource path
if path_start == len(remaining_url):
resource_path = "/"
else:
resource_path = remaining_url[path_start:]
# print parsed parts
print("Protocol:", protocol)
print("Hostname:", host)
print("Port:", port)
print("Resource Path:", resource_path)
Python3
IBM EXAM 6PM ANs
def checkSpellingAndSpace(sentence, dictionary):
words = sentence.split()
corrected_words = []
for word in words:
if word.lower() in dictionary:
corrected_words.append(word.lower())
elif len(word) == len(dictionary[0]):
for dict_word in dictionary:
differences = sum([1 for c1, c2 in zip(word.lower(), dict_word) if c1 != c2])
if differences == 1:
corrected_words.append(dict_word.lower())
break
else:
corrected_words.append(word)
corrected_sentence = ' '.join(corrected_words)
corrected_sentence = ' '.join(corrected_sentence.split())
print(corrected_sentence)
dictionary = ['environment', 'always', 'protect', 'irreplaceable', 'different',
absolutely ]
sentence = 'We should protect our envaronment alwoys'
checkSpellingAndSpace(sentence, dictionary)
PythonRepost from Off Campus Updates | AMAZON | IBM | TCS | WIPRO | WILEY EDGE | VIRTUSA | MINDTREE | COGNIZANT
AECOM Recruitment | Data Engineer Job Position: Data Engineer
Location: Bengaluru
Job Type: Full time
Experience: Freshers
Qualification: Bachelor’s Degree
Batch: 2018/ 2019/ 2020/ 2021/ 2022/ 2023
Salary: Up to 10 LPA (Expected) https://aecom.jobs/bengaluru-ind/data-engineer/EDD30E783C794641A4121319CF9C43FC/job/
telegram @offcampus_000❤️
share to ur friends ✅
Repost from Off Campus Updates | AMAZON | IBM | TCS | WIPRO | WILEY EDGE | VIRTUSA | MINDTREE | COGNIZANT
Cognizant Software Engineer Job Position: Software Engineer
Location: Chennai
Job Type: Full time
Experience: 0 – 1 Year
Qualification: Any Graduate
Batch: 2017/ 2018/ 2019/ 2020/ 2021/ 2022/ 2023
Salary: Min 5 LPA (Expected) link1: https://careers.cognizant.com/in/en/job/COGNGLOBAL00046956561/Software-Engineer-Associate Link 2: https://careers.cognizant.com/global/en/job/00046956561/Software-Engineer-Associate
Telegram @Offcampus_000❤️
share to ur friends ✅
Keep Sharing guys!!❤️ For free Solutions
Share @whitehatcoding❤️
Sharing = caring = spreading happiness😍😊
class Solution:
def solve(self, A):
n = len(A)
prefix_sum = [0]*n
suffix_sum = [0]*n
prefix_sum[0] = A[0]
suffix_sum[n-1] = A[n-1]
# Calculate prefix_sum[] and suffix_sum[]
for i in range(1, n):
prefix_sum[i] = max(prefix_sum[i-1] + A[i], A[i])
suffix_sum[n-i-1] = max(suffix_sum[n-i] + A[n-i-1], A[n-i-1])
max_sum = float('-inf')
# Calculate maximum sum of all possible sub-arrays
for i in range(1, n-1):
if prefix_sum[i-1] > 0 and suffix_sum[i+1] > 0:
curr_sum = prefix_sum[i-1] + A[i] + suffix_sum[i+1]
max_sum = max(max_sum, curr_sum)
# Return the maximum sum modulo 10^7
return max_sum%1000000007
# Testing the Solution class
s = Solution()
A = [2, -3, -1, 4]
print(s.solve(A)) # Output: 5
A = [-6,-2,1,-4,5,2]
print(s.solve(A)) # Output: 2
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const int mxn = 1e5;
long long cache[mxn][4][2];
bool visited[mxn][4][2];
long long solve(const vector<int>& A) {
const int n = (int)A.size();
memset(visited, 0, sizeof visited);
function<long long(int, int, int)> func = [&](int i, int cnt, int on) -> long long {
if(i == n) {
if(on and cnt == 3) return 0LL;
else return -INF;
}
long long& res = cache[i][cnt][on];
if(visited[i][cnt][on]) return res;
res = -INF;
if(i == 0) {
res = max(res, func(i + 1, cnt + 1, 1) + A[i]);
} else {
if(on) {
if(cnt < 3) res = max(res, func(i + 1, cnt + 1, 1) + A[i]);
res = max(res, func(i + 1, cnt, 0));
res = max(res, func(i + 1, cnt, 1) + A[i]);
} else {
res = max(res, func(i + 1, cnt, 0));
if(cnt < 3) res = max(res, func(i + 1, cnt + 1, 1) + A[i]);
}
}
visited[i][cnt][on] = true;
return res;
};
return func(0, 0, 0) % mod;
}
int main() {
int n; cin >> n;
vector<int> A(n);
for(int i = 0; i < n; i++) cin >> A[i];
cout << solve(A) << '\n';
return 0;
}
MOD = 10**9 + 7
def solve(A):
N = len(A)
dp1 = [[0] * N for _ in range(N)]
dp2 = [[0] * N for _ in range(N)]
for i in range(N):
dp1[i][i] = A[i]
dp2[i][i] = A[i]
for j in range(i+1, N):
dp1[i][j] = max(dp1[i][j-1] + A[j], A[j])
dp2[j][i] = max(dp2[j][i+1] + A[i], A[i])
ans = 0
for i in range(1, N-1):
max_prefix = max(A[:i])
max_suffix = max(A[i+1:])
for j in range(i+1, N-1):
if max_prefix >= max(A[i:j+1]):
continue
if max_suffix >= max(A[i:j+1]):
continue
ans = max(ans, dp1[0][i-1] + dp1[i][j] + dp2[j][N-1])
return ans % MOD
Q.-> Subarrays
const int MOD = 1e9 + 7;
void dfs(int cur, int par, vector<vector<int>>& adj, vector<int>& tax, vector<vector<int>>& dp) {
dp[cur][0] = 0;
dp[cur][1] = tax[cur];
int min_diff = INT_MAX;
for (int child : adj[cur]) {
if (child != par) {
dfs(child, cur, adj, tax, dp);
dp[cur][0] = (dp[cur][0] + min(dp[child][0], dp[child][1])) % MOD;
min_diff = min(min_diff, dp[child][1] - dp[child][0]);
}
}
if (min_diff != INT_MAX) {
dp[cur][1] = (dp[cur][1] + min_diff) % MOD;
}
}
int solve(int A, vector<vector<int>>& B, vector<vector<int>>& C, vector<int>& D) {
vector<vector<int>> adj(A + 1);
for (auto& b : B) {
adj[b[0]].push_back(b[1]);
adj[b[1]].push_back(b[0]);
}
vector<vector<int>> dp(A + 1, vector<int>(2));
dfs(1, 0, adj, D, dp);
return min(dp[1][0], dp[1][1]);
}
Q.2 c++
share @whitehatcoding❤️
