Update appNew update is available. Click here to update.
About
hello everyone, Myself Mehreen, I am persuing Computer science Engineering from Indira Gandhi Delhi Technical University for Women. I am very passionate about learning and knowing new things. I am in...
Google
Indira Gandhi Delhi Technical University for Women 2024
My Stats
EXP gained
yellow-spark
18140
Level
7 (Expert)
Community stats
Discussions
0
Upvotes
0
Know more
254
Total problems solved
110
Easy
123
Moderate
21
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:

27 days

Less

More

Achievements
3
Ronin
Topics
Binary Search
Graph
+ 1 more
6
Samurai
Topics
Arrays
Linked List
Sorting
+ 3 more
Discussions
why it is showing wrong answer?
Interview problems

#include <bits/stdc++.h> 

void Getip(vector<string>& result, string &s, int index, int count, string ip){

    if(s.size()==index && count==4 ){

        ip.pop_back();

        result.push_back(ip);

        return;

    }

 

    if(s.size()< index+1){

        return;

    }

    ip = ip+ s.substr(index, 1) + '.';

    Getip(result, s, index + 1,count + 1, ip);

 

    

    ip.erase(ip.end() - 2, ip.end());

 

    if(s.size()< index+2 || s[index]=='0'){

        return;

    }

    ip = ip+ s.substr(index, 2) + '.';

    Getip(result, s, index + 2,count + 1, ip);

 

    

    ip.erase(ip.end() - 3, ip.end());

 

    if (s.size() < index + 3 || stoi(s.substr(index, 3)) > 255) return;

 

    ip += s.substr(index, 3) + '.';

    Getip(result, s, index + 3,count + 1, ip);

 

    ip.erase(ip.end() - 4, ip.end());

    

}

vector<string> generateIPAddress(string s) 

{

    vector<string> result;

    Getip(result,s, 0,0," ");

    if(result.size()==0){

          return {""};

        }

    return result;

}

profile
154 Mehreen
Published On 29-May-2023
24 views
0 replies
0 upvotes
kth smalllarge
Interview problems

#include <cmath> #include <queue> #include<bits/stdc++.h>

vector<int> kthSmallLarge(vector<int> &arr, int n, int k) { // Write your code here.    vector<int> result;   sort(arr.begin(), arr.end());    result.push_back(arr[k-1]);    result.push_back(arr[n-k]);           return result; }

profile
154 Mehreen
Published On 18-Oct-2022
170 views
0 replies
1 upvotes