#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll solve(ll n)
{
vector<ll>bin(32);
ll i=0;
while(n)
{
bin[i]=n%2;
n=n/2;
i++;
}
string s;
for(ll j=i-1;j>=0;j--) s.push_back((char)(bin[j]+'0'));
//cout<<s<<endl;
n=s.length();
ll ans=0,f=1;
for(ll i=0;i<n;i++)
{
ll dig=s[i]-'0';
ll p=dig>0?pow(2,n-(i+1)):0;
ll st=dig*(2*p-1);
ans+=st*f;
if(dig==0) f=1;
else f=-1;
}
return ans;
}
signed main()
{
ll n; cin>>n;
cout<<solve(n);
}
Binary Manipulation โ
using namespace std;
#define ll long long
ll solve(ll n)
{
vector<ll>bin(32);
ll i=0;
while(n)
{
bin[i]=n%2;
n=n/2;
i++;
}
string s;
for(ll j=i-1;j>=0;j--) s.push_back((char)(bin[j]+'0'));
//cout<<s<<endl;
n=s.length();
ll ans=0,f=1;
for(ll i=0;i<n;i++)
{
ll dig=s[i]-'0';
ll p=dig>0?pow(2,n-(i+1)):0;
ll st=dig*(2*p-1);
ans+=st*f;
if(dig==0) f=1;
else f=-1;
}
return ans;
}
signed main()
{
ll n; cin>>n;
cout<<solve(n);
}
Binary Manipulation โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
public static int getMinCost(int[] heights, int[] cost) {
int n = heights.length;
int[][] dp = new int[n][3];
for (int i = 0; i < n; i++) {
if (i == 0) {
dp[i][0] = 0;
dp[i][1] = cost[i];
dp[i][2] = 2 * cost[i];
} else {
dp[i][0] = Math.min((heights[i - 1] != heights[i] ? dp[i - 1][0] : Integer.MAX_VALUE),
Math.min((heights[i - 1] + 1 != heights[i] ? dp[i - 1][1] : Integer.MAX_VALUE),
(heights[i - 1] + 2 != heights[i] ? dp[i - 1][2] : Integer.MAX_VALUE)));
dp[i][1] = Math.min((heights[i - 1] != heights[i] + 1 ? dp[i - 1][0] : Integer.MAX_VALUE),
Math.min((heights[i - 1] + 1 != heights[i] + 1 ? dp[i - 1][1] : Integer.MAX_VALUE),
(heights[i - 1] + 2 != heights[i] + 1 ? dp[i - 1][2] : Integer.MAX_VALUE))) + cost[i];
dp[i][2] = Math.min((heights[i - 1] != heights[i] + 2 ? dp[i - 1][0] : Integer.MAX_VALUE),
Math.min((heights[i - 1] + 1 != heights[i] + 2 ? dp[i - 1][1] : Integer.MAX_VALUE),
(heights[i - 1] + 2 != heights[i] + 2 ? dp[i - 1][2] : Integer.MAX_VALUE))) + 2 * cost[i];
}
}
return Math.min(dp[n - 1][0], Math.min(dp[n - 1][1], dp[n - 1][2]));
}
Unequal Block Structureโ
int n = heights.length;
int[][] dp = new int[n][3];
for (int i = 0; i < n; i++) {
if (i == 0) {
dp[i][0] = 0;
dp[i][1] = cost[i];
dp[i][2] = 2 * cost[i];
} else {
dp[i][0] = Math.min((heights[i - 1] != heights[i] ? dp[i - 1][0] : Integer.MAX_VALUE),
Math.min((heights[i - 1] + 1 != heights[i] ? dp[i - 1][1] : Integer.MAX_VALUE),
(heights[i - 1] + 2 != heights[i] ? dp[i - 1][2] : Integer.MAX_VALUE)));
dp[i][1] = Math.min((heights[i - 1] != heights[i] + 1 ? dp[i - 1][0] : Integer.MAX_VALUE),
Math.min((heights[i - 1] + 1 != heights[i] + 1 ? dp[i - 1][1] : Integer.MAX_VALUE),
(heights[i - 1] + 2 != heights[i] + 1 ? dp[i - 1][2] : Integer.MAX_VALUE))) + cost[i];
dp[i][2] = Math.min((heights[i - 1] != heights[i] + 2 ? dp[i - 1][0] : Integer.MAX_VALUE),
Math.min((heights[i - 1] + 1 != heights[i] + 2 ? dp[i - 1][1] : Integer.MAX_VALUE),
(heights[i - 1] + 2 != heights[i] + 2 ? dp[i - 1][2] : Integer.MAX_VALUE))) + 2 * cost[i];
}
}
return Math.min(dp[n - 1][0], Math.min(dp[n - 1][1], dp[n - 1][2]));
}
Unequal Block Structureโ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
vector<string> solve(vector<string>& chain, vector<string>& elements) {
unordered_map<string, int> required, window;
for (const auto& elem : elements) {
required[elem]++;
}
int requiredSize = required.size();
int have = 0;
int left = 0, right = 0;
int minLength = INT_MAX;
int start = -1;
while (right < chain.size()) {
string rightElem = chain[right];
if (required.count(rightElem)) {
window[rightElem]++;
if (window[rightElem] == required[rightElem]) {
have++;
}
}
while (have == requiredSize) {
if (right - left + 1 < minLength) {
minLength = right - left + 1;
start = left;
}
string leftElem = chain[left];
if (required.count(leftElem)) {
window[leftElem]--;
if (window[leftElem] < required[leftElem]) {
have--;
}
}
left++;
}
right++;
}
if (start == -1) {
return {};
}
return vector<string>(chain.begin() + start, chain.begin() + start + minLength);
}
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Panasonic is hiring SDE I
For 2022, 2023, 2024 grads
Location: Pune
https://careers.na.panasonic.com/jobs/10425?lang=en-us&iis=Job%20Board&iisn=Linkedin&s=08
For 2022, 2023, 2024 grads
Location: Pune
https://careers.na.panasonic.com/jobs/10425?lang=en-us&iis=Job%20Board&iisn=Linkedin&s=08
SDE I - Python Developer in Pune, India | Panasonic Corporation
Panasonic Corporation of North America is hiring a SDE I - Python Developer in Pune, India. Review all of the job details and apply today!
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Anuraag Bhattacharya on LinkedIn: #mercedesbenz #deeplearning #computervision #research #intern #mbrdi
We're looking for for a full-time intern to work on a computer vision project in the Intelligent Interior team of Mercedes Benz R&D India (MBRDI).
Projectโฆ
Projectโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Probo is hiring for Data Analyst Intern
Expected Stipend: 25K per month
Apply here:
https://probo.hire.trakstar.com/jobs/fk027hv?pjb_hash=Y7bAmjMPq4
Expected Stipend: 25K per month
Apply here:
https://probo.hire.trakstar.com/jobs/fk027hv?pjb_hash=Y7bAmjMPq4
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Sign Up | LinkedIn
500 million+ members | Manage your professional identity. Build and engage with your professional network. Access knowledge, insights and opportunities.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Openin App is hiring ReactJS intern
Batch: 2024, 2025, 2026 grads
Stipend: 35k- 40k per months
Apply here: https://openinapp.freshteam.com/jobs/PEnkxUAybeIx/react-js-developer-intern?ft_source=6000312750&ft_medium=6000257244
Batch: 2024, 2025, 2026 grads
Stipend: 35k- 40k per months
Apply here: https://openinapp.freshteam.com/jobs/PEnkxUAybeIx/react-js-developer-intern?ft_source=6000312750&ft_medium=6000257244
Freshteam
Hiring for React.Js Developer - Intern for Bengaluru - Internship
Posted by : OpeninApp | REACTJS,NEXT.JS,Axios,UI DESIGN,UI,API
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Gadgeon Systems Inc. Hiring Fresher Firmware Engineer Intern ๐
Job Designation : Firmware Intern
Requirements and Skills
โข Degree - B.Tech/ M.Tech
โข Solid programming experience in C or C++
โข Team Player, can work well with maintaining track of projects
Interested candidates please apply on nithya.km@gadgeon.com
Job Designation : Firmware Intern
Requirements and Skills
โข Degree - B.Tech/ M.Tech
โข Solid programming experience in C or C++
โข Team Player, can work well with maintaining track of projects
Interested candidates please apply on nithya.km@gadgeon.com
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Internship Opportunity!
BDO India is hiring interns for its Actuarial Team.
Candidates should be graduates and must have cleared at least 3 CT Papers, including CM1.
Preferred skills include knowledge of Excel, R, and Python.
Location: Mumbai/Gurugram with a hybrid working model.
If you know someone who would be a great fit, please recommend them or reach out to Shilpy Kalia at shilpykalia@bdo.in with the subject line "BDO India - Actuarial Intern."
BDO India is hiring interns for its Actuarial Team.
Candidates should be graduates and must have cleared at least 3 CT Papers, including CM1.
Preferred skills include knowledge of Excel, R, and Python.
Location: Mumbai/Gurugram with a hybrid working model.
If you know someone who would be a great fit, please recommend them or reach out to Shilpy Kalia at shilpykalia@bdo.in with the subject line "BDO India - Actuarial Intern."
#include <bits/stdc++.h>
using namespace std;
void f(int i,int m,int down, int power,int& ans){
if (i > m+2) return;
if (i < 0) return;
if(i == m) ans++;
f(i+pow(2,power),m,1,power+1,ans);
if (down)
{
f(i-1,m,0,power,ans);
}
}
int solve(int m){
int ans = 0;
f(1,m,1,0,ans);
return ans;
}
Game of stairs โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
#include <bits/stdc++.h> using namespace std; void f(int i,int m,int down, int power,int& ans){ if (i > m+2) return; if (i < 0) return; if(i == m) ans++; f(i+pow(2,power),m,1,power+1,ans); if (down) { f(i-1,m,0,power,ans); โฆ
Parallel Universe Chess Board โ
#include <bits/stdc++.h>
#define ll long long
using namespace std;
signed main()
{
ll sz,n; cin>>sz>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++) cin>>a[i];
vector<vector<ll>>ans;
for(ll i=0;i<sz-1;i++) a.insert(a.begin(),0);
reverse(a.begin(),a.end());
for(ll i=0;i<n;i++)
{
vector<ll>curr;
for(ll j=i;j<i+sz;j++) curr.push_back(a[j]);
ans.push_back(curr);
}
reverse(ans.begin(),ans.end());
for(ll i=0;i<ans.size();i++)
{
for(ll j=0;j<ans[i].size();j++) cout<<ans[i][j]<<" ";
cout<<endl;
}
return 0;
}
๐1