Update appNew update is available. Click here to update.
About
Indian Institute of Technology Gandhinagar 2024
C++ - Default language
My Stats
EXP gained
yellow-spark
72980
Level
8 (Master)
Community stats
Discussions
0
Upvotes
0
Know more
600
Total problems solved
358
Easy
170
Moderate
72
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

35 days

Less

More

Achievements
3
Ronin
Topics
Graph
Stacks & Queues
Greedy
6
Samurai
Topics
Dynamic Programming
Arrays
+ 4 more
3
Sensei
Topics
Strings
Linked List
Tries

College monthly badge

3 Times topper

438 average partcipants
Discussions
O(n) | easy| no sorting| c++
Interview problems

#include<bits/stdc++.h>

using namespace std;

 

string amazingStrings(string first, string second,string third) {

    // Write your code here.

   vector<int>dp(256,0);

   for(auto i :third)

     dp[i]++;

   for(auto i: first)

    dp[i]--;

     for(auto i: second)

    dp[i]--;

 

    for(int i : dp)

    if(i!=0)

    return "NO";

    return "YES";

}

profile
Shivam Mishra
Published On 27-Aug-2023
139 views
1 replies
1 upvotes
easy| understandable| no-in-build function| only math
Interview problems

#include <bits/stdc++.h> 

 

pair < int , int > findMinMax(int a , int b) 

{

    // Write Your Code here

         int dif=abs(a-b);

        int max=(a+b+dif)/2; // if we add dif in mimum then its  alos become equal to max

        int min=(a+b)-max;

         return {min,max};

}

profile
Shivam Mishra
Published On 23-Aug-2023
148 views
0 replies
0 upvotes
easy|| dp solution
Interview problems

#include <bits/stdc++.h> 

bool wordBreak(vector < string > & arr, int n, string & target) {

    // Write your code here.

   std::unordered_set<std::string> dict(arr.begin(), arr.end());

 

    int len = target.length();

    std::vector<bool> dp(len + 1, false);

    dp[0] = true;

 

    for (int i = 1; i <= len; ++i) {

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

            if (dp[j] && dict.find(target.substr(j, i - j)) != dict.end()) {

                dp[i] = true;

                break;

            }

        }

    }

 

    return dp[len] ? 1 : 0;

}

profile
Shivam Mishra
Published On 22-Aug-2023
106 views
0 replies
0 upvotes
c++ code
Interview problems

 if any doubt, then ask in comment box

#include <bits/stdc++.h> 

int subArrayCount(vector<int> &arr, int k) {

    // Write your code here.

    vector<int>v(k,0);// all posible remainder if devided by k;

    v[0]=1; // if sum of all point till i divisable by k then then we can start with i==0;  

    int n=arr.size();

    int sum=0;

    int ans=0;

    for(int i=0;i<n;i++)

    {

        sum+=arr[i];

        sum=sum%k;

        if(sum<0)

        sum+=k;

        ans+=v[sum]++;// if x%k=r and (x+y)%k=r then y is devisible by k, we have to count how may poisble x

    }

    return ans;

}

profile
Shivam Mishra
Published On 07-Aug-2023
285 views
0 replies
0 upvotes