New update is available. Click here to update.
About
I am Meet Patel, from Surat, Gujarat. Currently , I am pursuing M.Tech degree from National institute of Technology, Karnataka. I did my B.Tech from Nirma University, Ahmedabad. I am a Mechanical En...
National Institute of Technology Karnataka (NITK Surathkal) 2024
C++ - Default language
My Stats
EXP gained
7518
Level
6 (Specialist)
Community stats
Discussions
0
Upvotes
0
Know more
229
Total problems solved
212
Easy
17
Moderate
0
Hard
0
Ninja

Current streak:

0 days

Longest streak:

7 days

Less

More

Achievements
Discussions
this code beats 96 % users
Interview problems

void removeConsecutiveDuplicates(char *input)

{

if (input[0] == '\0')

{

return;

}

if (input[0] == input[1])

{

int i = 0;

while (input[i] != '\0')

{

input[i] = input[i + 1];

i++;

}

removeConsecutiveDuplicates(input);

}

else

{

removeConsecutiveDuplicates(input + 1);

}

}

MEET24X7
Published On 21-Sep-2023
69 views
0 replies
0 upvotes
this code beats 95 % users
Interview problems

#include <bits/stdc++.h>

int sumofDigits(int n)

{

int sum = 0;

// Calculate the sum of digits

while (n > 0)

{

sum += n % 10;

n /= 10;

}

// If the sum is still greater than or equal to 10, recursively call the function

if (sum >= 10)

{

return sumofDigits(sum);

}

return sum;

}

MEET24X7
Published On 21-Sep-2023
59 views
0 replies
0 upvotes
this code performed better than 100%
Interview problems

#include<iostream>

using namespace std;

int main()

{

int N;

cin>>N;

bool check=true;

for(int i=2;i<N;i++)

{

if(N%i==0)

{

check = 0;

}

}

if(check==1)

{

cout<<"true";

}

else

{

cout<<"false";

}

}

MEET24X7
Published On 20-Sep-2023
182 views
2 replies
0 upvotes
this code performed better than 95%
Interview problems

bool isPrime(int N)

{

int count=0;

for(int i=1;i*i<=N;i++)

{

if(N%i==0)

{

count++;

if(N/i!=i)

{

count++;

}

}

}

if(count==2)

{

return 1;

}

else

{

return 0;

}

}

MEET24X7
Published On 20-Sep-2023
159 views
0 replies
0 upvotes
using recursion
Interview problems

int firstIndexHelper(int input[], int size, int x, int currentIndex)

{

// Base case: If currentIndex reaches the end of the array, return -1

if (currentIndex == size)

{

return -1;

}

// If the current element is equal to x, return the current index

if (input[currentIndex] == x)

{

return currentIndex;

}

// Recursive case: Check the next element in the array

return firstIndexHelper(input, size, x, currentIndex + 1);

}

int firstIndex(int input[], int size, int x)

{

// Call the helper function with the initial currentIndex as 0

return firstIndexHelper(input, size, x, 0);

}

MEET24X7
Published On 19-Sep-2023
47 views
0 replies
0 upvotes
easy
Interview problems

#include<iostream>

using namespace std;

int main()

{

int n,revnum;

cin>>n;

revnum=0;

while(n>0)

{

int remainder=n%10;

revnum=(revnum*10)+remainder;

n=n/10;

}

cout<<revnum;

}

MEET24X7
Published On 19-Sep-2023
78 views
0 replies
0 upvotes
1 line code | using log10
Interview problems

#include<bits/stdc++.h>

int countDigits(int n)

{

int cnt= (int)log10(n)+1;

return cnt;

}

MEET24X7
Published On 19-Sep-2023
159 views
0 replies
0 upvotes
easy
Interview problems

int countDigits(int n)

{

int count=0;

if(n==0)

{

return 0;

}

return 1 + countDigits(n/10);

}

MEET24X7
Published On 19-Sep-2023
165 views
0 replies
0 upvotes
you can't find better solution than this(took min time to run this code compare to all participants)
Interview problems

void symmetry(int n)

{

int spaces=0;

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

{

//stars

for(int j=1;j<=n-i;j++)

{

cout<<"*"<<" ";

}

//spaces

for(int j=0;j<spaces;j++)

{

cout<<" "<<" ";

}

//stars

for(int j=1;j<=n-i;j++)

{

cout<<"*"<<" ";

}

spaces=spaces+2;

cout<<endl;

}

int i;

spaces=2*n-2;

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

{

//stars

for(int j=1;j<=i;j++)

{

cout<<"*"<<" ";

}

//spaces

for(int j=0;j<spaces;j++)

{

cout<<" "<<" ";

}

//stars

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

cout << "*"<< " ";

}

spaces = spaces - 2;

cout << endl;

}

}

MEET24X7
Published On 16-Sep-2023
81 views
0 replies
0 upvotes
easy
Interview problems

int countDigits(int n)

{

int main=n;

int count = 0;

while (n > 0) {

int digit = n % 10;

if (digit != 0 && main % digit == 0)

{

count++;

}

n = n/10;

}

return count;

}

MEET24X7
Published On 15-Sep-2023
97 views
0 replies
0 upvotes