I am currently a 2nd Year B.E Undergrad at Sir M. Visvesvaraya Institute of Technology with a specialization in Electronics and Communication Engineering. I know C++ . I am good with presentations an...
Sir M. Visvesvaraya Institute of Technology 2025
C++ - Default language
My Stats
EXP gained
20557
Level
7 (Expert)
Community stats
Discussions
8
10
Know more
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
279
Total problems solved
149
Easy
116
Moderate
14
Hard
0
Ninja

Current streak:

0 days

Longest streak:

12 days

Less

More

Achievements
10
Ronin
Topics
Binary Search
Greedy
Trees
+ 7 more
11
Samurai
Topics
Arrays
Sorting
Math
Strings
+ 7 more
1
Sensei
Topics
Recursion
Discussions
Fastest and short C++ code 🔥🔥
Interview problems

#include <bits/stdc++.h>

void setZeros(vector<vector<int>> &matrix)

{

int m=matrix.size();

int n=matrix[0].size();

set<int>row,col;

for(int i=0;i<m;i++){

for(int j=0;j<n;j++){

// storing the postion of zero

if(matrix[i][j]==0){

row.insert(i);

col.insert(j);

}

}

}

for(int i:row){

for(int j=0;j<n;j++){

matrix[i][j]=0;

}

}

for(int j:col){

for(int i=0;i<m;i++){

matrix[i][j]=0;

}

}

}

Amit_Dahiya
Published On 04-Jun-2023
376 views
0 replies
Short Simple and easy to understand C++ code
Interview problems

#include<bits/stdc++.h>

int helper(int n,vector<vector<int>>& points,vector<vector<int>>& dp,int last,int day){

// base case

if(day==n)return 0;

if(dp[day][last] !=-1)return dp[day][last];

int maxi=0;

for(int i=0;i<3;i++){

// we cant count points earned on last day

if(i!=last){

int temp= points[day][i] + helper(n,points,dp,i,day+1);

maxi = max(maxi,temp);

}

}

return dp[day][last]=maxi;

}

int ninjaTraining(int n, vector<vector<int>> &points)

{

vector<vector<int>>dp(n,vector<int>(4,-1));

// here 3 as a last day means that no points earned before day 0

return helper(n,points,dp,3,0);

}

Amit_Dahiya
Published On 09-Mar-2023
103 views
0 replies