#include <bits/stdc++.h>
using namespace std;
int count(vector<int>&coins, int n, int sum)
{
int table[sum + 1];
memset(table, 0, sizeof(table));
table[0] = 1;
for (int i = 0; i < n; i++)
for (int j = coins[i]; j <= sum; j++)
table[j] += table[j - coins[i]];
return table[sum];
}
int main()
{
int n,t;
cin>>n>>t;
vector<int>L(t);
for(int i=0;i<t;i++)
{
cin>>L[i];
}
cout << count(L, t,n);
}
Helpshift โ
Goblin
using namespace std;
int count(vector<int>&coins, int n, int sum)
{
int table[sum + 1];
memset(table, 0, sizeof(table));
table[0] = 1;
for (int i = 0; i < n; i++)
for (int j = coins[i]; j <= sum; j++)
table[j] += table[j - coins[i]];
return table[sum];
}
int main()
{
int n,t;
cin>>n>>t;
vector<int>L(t);
for(int i=0;i<t;i++)
{
cin>>L[i];
}
cout << count(L, t,n);
}
Helpshift โ
Goblin
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> getSkyline(vector<vector<int>>& buildings) {
vector<vector<int>> ans;
multiset<int> pq{0};
vector<pair<int, int>> points;
for(auto b: buildings){
points.push_back({b[0], -b[2]});
points.push_back({b[1], b[2]});
}
sort(points.begin(), points.end());
int ongoingHeight = 0;
for(int i = 0; i < points.size(); i++){
int currentPoint = points[i].first;
int heightAtCurrentPoint = points[i].second;
if(heightAtCurrentPoint < 0){
pq.insert(-heightAtCurrentPoint);
} else {
pq.erase(pq.find(heightAtCurrentPoint));
}
auto pqTop = *pq.rbegin();
if(ongoingHeight != pqTop){
ongoingHeight = pqTop;
ans.push_back({currentPoint, ongoingHeight});
}
}
return ans;
}
int main() {
int n;
cin >> n;
vector<vector<int>> buildings(n, vector<int>(3));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> buildings[i][j];
}
}
vector<vector<int>> result = getSkyline(buildings);
for (auto &p : result) {
cout << p[0]<<p[1]<< endl;
}
}
Skyline โ
using namespace std;
vector<vector<int>> getSkyline(vector<vector<int>>& buildings) {
vector<vector<int>> ans;
multiset<int> pq{0};
vector<pair<int, int>> points;
for(auto b: buildings){
points.push_back({b[0], -b[2]});
points.push_back({b[1], b[2]});
}
sort(points.begin(), points.end());
int ongoingHeight = 0;
for(int i = 0; i < points.size(); i++){
int currentPoint = points[i].first;
int heightAtCurrentPoint = points[i].second;
if(heightAtCurrentPoint < 0){
pq.insert(-heightAtCurrentPoint);
} else {
pq.erase(pq.find(heightAtCurrentPoint));
}
auto pqTop = *pq.rbegin();
if(ongoingHeight != pqTop){
ongoingHeight = pqTop;
ans.push_back({currentPoint, ongoingHeight});
}
}
return ans;
}
int main() {
int n;
cin >> n;
vector<vector<int>> buildings(n, vector<int>(3));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> buildings[i][j];
}
}
vector<vector<int>> result = getSkyline(buildings);
for (auto &p : result) {
cout << p[0]<<p[1]<< endl;
}
}
Skyline โ
#include <bits/stdc++.h>
using namespace std;
void minimumBribes(vector<int> A)
{
int n = A.size();
int cnt = 0;
for(int i = n - 1; i >= 0; i--)
{
if(A[i] != (i + 1))
{
if(((i - 1) >= 0) && A[i - 1] == (i + 1))
{
cnt++;
swap(A[i], A[i-1]);
}
else if(((i - 2) >= 0) && A[i - 2] == (i + 1))
{
cnt += 2;
A[i - 2] = A[i - 1];
A[i - 1] = A[i];
A[i] = i + 1;
}
else
{
cout << "Too chaotic" << endl;
return;
}
}
}
cout << cnt << endl;
return;
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n;
cin >> n;
vector<int> A(n);
for (int j = 0; j < n; j++) {
cin >> A[j];
}
minimumBribes(A);
}
return 0;
}
Min bribes โ
using namespace std;
void minimumBribes(vector<int> A)
{
int n = A.size();
int cnt = 0;
for(int i = n - 1; i >= 0; i--)
{
if(A[i] != (i + 1))
{
if(((i - 1) >= 0) && A[i - 1] == (i + 1))
{
cnt++;
swap(A[i], A[i-1]);
}
else if(((i - 2) >= 0) && A[i - 2] == (i + 1))
{
cnt += 2;
A[i - 2] = A[i - 1];
A[i - 1] = A[i];
A[i] = i + 1;
}
else
{
cout << "Too chaotic" << endl;
return;
}
}
}
cout << cnt << endl;
return;
}
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n;
cin >> n;
vector<int> A(n);
for (int j = 0; j < n; j++) {
cin >> A[j];
}
minimumBribes(A);
}
return 0;
}
Min bribes โ
#include<bits/stdc+.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
int next_greater[n], next_smaller[n];
stack<int> s1;
for ( int i=n-1; i>=0; i--)
{
while (!s1.empty() && a[s1.top()] <= a[i] )
s1.pop();
if (!s1.empty())
next_greater[i] = s1.top();
else
next_greater[i] = -1;
s1.push(i);
}
stack<int> s2;
for (int i=n-1; i>=0; i--)
{
while (!s2.empty() && a[s2.top()] >= a[i])
s2.pop();
if (!s2.empty())
next_smaller[i] = s2.top();
else
next_smaller[i] = -1;
s2.push(i);
}
for (int i=0; i< n; i++)
{
if (next_greater[i] != -1 && next_smaller[next_greater[i]] != -1)
cout << a[next_smaller[next_greater[i]]] <<" ";
else
cout<<-1<<" ";
}
}
Number games โ
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
int next_greater[n], next_smaller[n];
stack<int> s1;
for ( int i=n-1; i>=0; i--)
{
while (!s1.empty() && a[s1.top()] <= a[i] )
s1.pop();
if (!s1.empty())
next_greater[i] = s1.top();
else
next_greater[i] = -1;
s1.push(i);
}
stack<int> s2;
for (int i=n-1; i>=0; i--)
{
while (!s2.empty() && a[s2.top()] >= a[i])
s2.pop();
if (!s2.empty())
next_smaller[i] = s2.top();
else
next_smaller[i] = -1;
s2.push(i);
}
for (int i=0; i< n; i++)
{
if (next_greater[i] != -1 && next_smaller[next_greater[i]] != -1)
cout << a[next_smaller[next_greater[i]]] <<" ";
else
cout<<-1<<" ";
}
}
Number games โ
public static int findBestPath(int n, int m, int max_t, List beauty, List u, List v, List t) {
// Write your code here
createGraph(n, m, u, v, t);
// int twoWay = dfs(0, beauty, max_t);
// visited = new HashSet<>();
// cycle(0, beauty, max_t, beauty.get(0), 0);
visited.add(0);
dfs2(0, beauty, max_t, beauty.get(0));
return totalAns;
}
static int totalAns = Integer.MIN_VALUE;
public static void dfs2(int node, List beauty, int maxT, int sum) {
if (node == 0) {
totalAns = Math.max(totalAns, sum);
}
for (int nbr : map.get(node).keySet()) {
int time = map.get(node).get(nbr);
if (time <= maxT) {
if (!visited.contains(nbr)) {
visited.add(nbr);
dfs2(nbr, beauty, maxT - time, sum + beauty.get(nbr));
visited.remove(nbr);
} else
dfs2(nbr, beauty, maxT - time, sum);
}
}
}
static HashSet<Integer> visited = new HashSet<>();
static HashMap<Integer, HashMap<Integer, Integer>> map = new HashMap<>();
public static void createGraph(int n, int m, List u, List v, List t) {
for (int i = 0; i < n; ++i) {
map.put(i, new HashMap<>());
}
for (int i = 0; i < m; ++i) {
int x = u.get(i);
int y = v.get(i);
int z = t.get(i);
map.get(x).put(y, z);
map.get(y).put(x, z);
}
}
Find best path
Linkedln โ
// Write your code here
createGraph(n, m, u, v, t);
// int twoWay = dfs(0, beauty, max_t);
// visited = new HashSet<>();
// cycle(0, beauty, max_t, beauty.get(0), 0);
visited.add(0);
dfs2(0, beauty, max_t, beauty.get(0));
return totalAns;
}
static int totalAns = Integer.MIN_VALUE;
public static void dfs2(int node, List beauty, int maxT, int sum) {
if (node == 0) {
totalAns = Math.max(totalAns, sum);
}
for (int nbr : map.get(node).keySet()) {
int time = map.get(node).get(nbr);
if (time <= maxT) {
if (!visited.contains(nbr)) {
visited.add(nbr);
dfs2(nbr, beauty, maxT - time, sum + beauty.get(nbr));
visited.remove(nbr);
} else
dfs2(nbr, beauty, maxT - time, sum);
}
}
}
static HashSet<Integer> visited = new HashSet<>();
static HashMap<Integer, HashMap<Integer, Integer>> map = new HashMap<>();
public static void createGraph(int n, int m, List u, List v, List t) {
for (int i = 0; i < n; ++i) {
map.put(i, new HashMap<>());
}
for (int i = 0; i < m; ++i) {
int x = u.get(i);
int y = v.get(i);
int z = t.get(i);
map.get(x).put(y, z);
map.get(y).put(x, z);
}
}
Find best path
Linkedln โ
int getMinimumCost(vector<int> arr)
{
long long maxDiff = 0 ;
int index = -1 ;
for(int i= 0 ; i < arr.size()-1 ; i++)
{
if(abs(arr[i]-arr[i+1]) > maxDiff)
{
maxDiff = abs(arr[i]-arr[i+1]) ;
index = i ;
}
}
int median = (arr[index] + arr[index+1]) / 2 ;
long long initialCost = 0 ;
for(int i= 0 ; i < arr.size()-1 ; i++)
initialCost += pow(arr[i]-arr[i+1],2) ;
initialCost = initialCost + pow(arr[index] - median,2) + pow(median - arr[index+1],2) - pow(arr[index] - arr[index+1] ,2) ;
return initialCost ;
}
Linkedln โ
{
long long maxDiff = 0 ;
int index = -1 ;
for(int i= 0 ; i < arr.size()-1 ; i++)
{
if(abs(arr[i]-arr[i+1]) > maxDiff)
{
maxDiff = abs(arr[i]-arr[i+1]) ;
index = i ;
}
}
int median = (arr[index] + arr[index+1]) / 2 ;
long long initialCost = 0 ;
for(int i= 0 ; i < arr.size()-1 ; i++)
initialCost += pow(arr[i]-arr[i+1],2) ;
initialCost = initialCost + pow(arr[index] - median,2) + pow(median - arr[index+1],2) - pow(arr[index] - arr[index+1] ,2) ;
return initialCost ;
}
Linkedln โ
Tomorrow Anyone Give Exam IBM OA?
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
DE SHAW hiring Ascend Educare is a six-month mentorship program for women in technology
Eligibility Criteria:
Second/third-year student in a BTech/BE program
Third/fourth-year student in a five-year dual degree program (BTech + MTech, BE + ME)
First-year student in a two-year MTech/MS/MCA program
Second-year student in a three-year MCA program;
https://www.deshawindia.com/forms/REQ5Qjg1RTktM0Q5NC00QjhFLTkyNDYtNTE1OENENjE5QjhB
Eligibility Criteria:
Second/third-year student in a BTech/BE program
Third/fourth-year student in a five-year dual degree program (BTech + MTech, BE + ME)
First-year student in a two-year MTech/MS/MCA program
Second-year student in a three-year MCA program;
https://www.deshawindia.com/forms/REQ5Qjg1RTktM0Q5NC00QjhFLTkyNDYtNTE1OENENjE5QjhB
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Amazon Dublin
Role: SDE Internship
Batch: 2024 and 2025 passouts
Location: Dublin
Apply: https://bit.ly/3qqKNyi
Role: SDE Internship
Batch: 2024 and 2025 passouts
Location: Dublin
Apply: https://bit.ly/3qqKNyi
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name : FRND
Role : SDE Internship ( Python )
Batch : 2023/2024 pass-outs
Link : https://www.linkedin.com/jobs/view/3687648587
Role : SDE Internship ( Python )
Batch : 2023/2024 pass-outs
Link : https://www.linkedin.com/jobs/view/3687648587
Linkedin
12,000+ Python Developer jobs in India (233 new)
Todayโs top 12,000+ Python Developer jobs in India. Leverage your professional network, and get hired. New Python Developer jobs added daily.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Emitrr
Role: SDE Intern
Batch eligible: 2023 and 2024 grads
Apply: https://www.linkedin.com/jobs/view/3685493923
Role: SDE Intern
Batch eligible: 2023 and 2024 grads
Apply: https://www.linkedin.com/jobs/view/3685493923
Linkedin
29 Software Engineer Intern jobs in India (4 new)
Todayโs top 29 Software Engineer Intern jobs in India. Leverage your professional network, and get hired. New Software Engineer Intern jobs added daily.
Software Engineer Swaraj Kumar is offering a group session to help you ace the FAANG interviews and to answer your questions and doubts directly ๐ฏ
Heโll be sharing the following:
- Experience and insights on the interview process
- How to enhance your skill set
- Tips to grab high-paying job opportunities
- Ways to build your resume.
Register now - https://visit.preplaced.in/n8u
The session will also include a live Q&A, where the mentor will answer all your doubts and concerns:)
Don't miss out!
Heโll be sharing the following:
- Experience and insights on the interview process
- How to enhance your skill set
- Tips to grab high-paying job opportunities
- Ways to build your resume.
Register now - https://visit.preplaced.in/n8u
The session will also include a live Q&A, where the mentor will answer all your doubts and concerns:)
Don't miss out!
app.preplaced.in
Live Events | Preplaced
1:1 LIVE group mentorship sessions by top Preplaced mentors | Book a long-term mentorship program at Preplaced | Become a part of mentor guided career journey
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Baker Hughes
Role: Software Engineer
Batch eligible: 2021, 2022 and 2023 grads
Apply: https://bit.ly/45p1qJq
Role: Software Engineer
Batch eligible: 2021, 2022 and 2023 grads
Apply: https://bit.ly/45p1qJq
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Sourcewiz Hiring fresher !!
Role - SDE
Location - Bangalore
Hurry up guys
https://docs.google.com/forms/d/e/1FAIpQLScsQr-Eq-InChDNSZZyJfQVhe8Jk2ovHqcZUR-PpkG6Thyb0Q/viewform
Fill the form fast before it closed
Role - SDE
Location - Bangalore
Hurry up guys
https://docs.google.com/forms/d/e/1FAIpQLScsQr-Eq-InChDNSZZyJfQVhe8Jk2ovHqcZUR-PpkG6Thyb0Q/viewform
Fill the form fast before it closed
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Mercari is Hiring !!
Role: SWE intern
Batch: 2024 internship(min 3 months,relocation+visa support provided) :
Apply here- https://apply.workable.com/mercari/j/FE4DFD158A/?trk=feed_main-feed-card_feed-article-content
Role: SWE intern
Batch: 2024 internship(min 3 months,relocation+visa support provided) :
Apply here- https://apply.workable.com/mercari/j/FE4DFD158A/?trk=feed_main-feed-card_feed-article-content
Workable
Software Engineer - Mercari/Merpay/Mercoin/Mercari Hallo (Internship) - Mercari, inc.
JD in Japanese follows. ่ฑๆใฎๅพใซๅๆJDใใ่ฆงใใใ ใใพใใIntroductionCirculate all forms of value to unleash the potential in all people"What can I do to help society thrive with the finite resources we have?" The Mercari marketplace app was born in 2013...
Oracle MCQ/Code Solution โ