-> Rishabh Jain, a passionate B.Tech student specializing in Computer Science at College of Engineering Roorkee. With a love for coding, he aspires to become a coding ninja. Mastering various programm...
College of Engineering Roorkee 2025
My Stats
EXP gained
19061
Level
7 (Expert)
Community stats
Discussions
2
5
Know more
759
Total problems solved
744
Easy
15
Moderate
0
Hard
0
Ninja

Current streak:

0 days

Longest streak:

24 days

Less

More

Achievements
4
Ronin
Topics
Arrays
Sorting
Strings
+ 1 more
1
Ronin
Guided path
Basics of C++
2
Sensei
Guided path
Pointers
ChatGPT

1 Time topper

College of Engineering Roorkee

291 average partcipants
Discussions
Five simple approaches 🙌||Easiest CPP solution🚀
Interview problems

// we can swap by taking a third variable

void swapNumber(int &a, int &b) {

int temp=0;

temp=a;

a=b;

b=temp;

}

// we can swap with our inbuilt swap function

void swapNumber(int &a, int &b) {

swap(a,b);

}

//using + and - operator

void swapNumber(int &a, int &b){

a=a+b;

b=a-b;

a=a-b;

}

//using * and / operator

void swapNumber(int &a, int &b){

a=a*b;

b=a/b;

a=a/b;

}

//using xor ^ operator

void swapNumber(int &a, int &b){

a=a^b;

b=a^b;

a=a^b;

}

//Kindly upvote if this helps you in any way.

Enrish
Published On 30-Oct-2023
128 views
0 replies
Five simple approaches 🙌||Easiest CPP solution🚀
Interview problems

// we can swap by taking a third variable

void swapNumber(int &a, int &b) {

int temp=0;

temp=a;

a=b;

b=temp;

}

// we can swap with our inbuilt swap function

void swapNumber(int &a, int &b) {

swap(a,b);

}

//using + and - operator

void swapNumber(int &a, int &b){

a=a+b;

b=a-b;

a=a-b;

}

//using * and / operator

void swapNumber(int &a, int &b){

a=a*b;

b=a/b;

a=a/b;

}

//using xor ^ operator

void swapNumber(int &a, int &b){

a=a^b;

b=a^b;

a=a^b;

}

//Kindly upvote if this helps you in any way.

Enrish
Published On 30-Oct-2023
128 views
0 replies
Five simple approaches 🙌||Easiest CPP solution🚀
Interview problems

// we can swap by taking a third variable

void swapNumber(int &a, int &b) {

int temp=0;

temp=a;

a=b;

b=temp;

}

// we can swap with our inbuilt swap function

void swapNumber(int &a, int &b) {

swap(a,b);

}

//using + and - operator

void swapNumber(int &a, int &b){

a=a+b;

b=a-b;

a=a-b;

}

//using * and / operator

void swapNumber(int &a, int &b){

a=a*b;

b=a/b;

a=a/b;

}

//using xor ^ operator

void swapNumber(int &a, int &b){

a=a^b;

b=a^b;

a=a^b;

}

//Kindly upvote if this helps you in any way.

Enrish
Published On 30-Oct-2023
128 views
0 replies
Five simple approaches 🙌||Easiest CPP solution🚀
Interview problems

// we can swap by taking a third variable

void swapNumber(int &a, int &b) {

int temp=0;

temp=a;

a=b;

b=temp;

}

// we can swap with our inbuilt swap function

void swapNumber(int &a, int &b) {

swap(a,b);

}

//using + and - operator

void swapNumber(int &a, int &b){

a=a+b;

b=a-b;

a=a-b;

}

//using * and / operator

void swapNumber(int &a, int &b){

a=a*b;

b=a/b;

a=a/b;

}

//using xor ^ operator

void swapNumber(int &a, int &b){

a=a^b;

b=a^b;

a=a^b;

}

//Kindly upvote if this helps you in any way.

Enrish
Published On 30-Oct-2023
128 views
0 replies
Five simple approaches 🙌||Easiest CPP solution🚀
Interview problems

// we can swap by taking a third variable

void swapNumber(int &a, int &b) {

int temp=0;

temp=a;

a=b;

b=temp;

}

// we can swap with our inbuilt swap function

void swapNumber(int &a, int &b) {

swap(a,b);

}

//using + and - operator

void swapNumber(int &a, int &b){

a=a+b;

b=a-b;

a=a-b;

}

//using * and / operator

void swapNumber(int &a, int &b){

a=a*b;

b=a/b;

a=a/b;

}

//using xor ^ operator

void swapNumber(int &a, int &b){

a=a^b;

b=a^b;

a=a^b;

}

//Kindly upvote if this helps you in any way.

Enrish
Published On 30-Oct-2023
128 views
0 replies
Dutch national Flag Algo 🚀with explaination||Easiest CPP solution 🙌||
Interview problems

dutch nationial flag algo basically deals with the thing that 0 is in beginning , 1 in mid and 2 in the end, you can see that easily in below code.

#include <bits/stdc++.h>

void sort012(int *arr, int n)

{

int low=0,high=n-1,mid=0;

while(high>=mid)

{

if(arr[mid]==0)

{

swap(arr[low],arr[mid]);

low++;

mid++;

}

else if(arr[mid]==1)

{

mid++;

}

else if(arr[mid]==2)

{

swap(arr[mid],arr[high]);

high--;

}

}

}

Kindly upvote if it helps you in anyway :)

Enrish
Published On 30-Oct-2023
98 views
0 replies
Dutch national Flag Algo 🚀with explaination||Easiest CPP solution 🙌||
Interview problems

dutch nationial flag algo basically deals with the thing that 0 is in beginning , 1 in mid and 2 in the end, you can see that easily in below code.

#include <bits/stdc++.h>

void sort012(int *arr, int n)

{

int low=0,high=n-1,mid=0;

while(high>=mid)

{

if(arr[mid]==0)

{

swap(arr[low],arr[mid]);

low++;

mid++;

}

else if(arr[mid]==1)

{

mid++;

}

else if(arr[mid]==2)

{

swap(arr[mid],arr[high]);

high--;

}

}

}

Kindly upvote if it helps you in anyway :)

Enrish
Published On 30-Oct-2023
98 views
0 replies
Dutch national Flag Algo 🚀with explaination||Easiest CPP solution 🙌||
Interview problems

dutch nationial flag algo basically deals with the thing that 0 is in beginning , 1 in mid and 2 in the end, you can see that easily in below code.

#include <bits/stdc++.h>

void sort012(int *arr, int n)

{

int low=0,high=n-1,mid=0;

while(high>=mid)

{

if(arr[mid]==0)

{

swap(arr[low],arr[mid]);

low++;

mid++;

}

else if(arr[mid]==1)

{

mid++;

}

else if(arr[mid]==2)

{

swap(arr[mid],arr[high]);

high--;

}

}

}

Kindly upvote if it helps you in anyway :)

Enrish
Published On 30-Oct-2023
98 views
0 replies
Dutch national Flag Algo 🚀with explaination||Easiest CPP solution 🙌||
Interview problems

dutch nationial flag algo basically deals with the thing that 0 is in beginning , 1 in mid and 2 in the end, you can see that easily in below code.

#include <bits/stdc++.h>

void sort012(int *arr, int n)

{

int low=0,high=n-1,mid=0;

while(high>=mid)

{

if(arr[mid]==0)

{

swap(arr[low],arr[mid]);

low++;

mid++;

}

else if(arr[mid]==1)

{

mid++;

}

else if(arr[mid]==2)

{

swap(arr[mid],arr[high]);

high--;

}

}

}

Kindly upvote if it helps you in anyway :)

Enrish
Published On 30-Oct-2023
98 views
0 replies
Smallest || Optimized CPP sol 🧑‍💻|| Very easy approach🚀🙌
Interview problems

#include <iostream>

using namespace std;

int main() {

int Length;