Update appNew update is available. Click here to update.
About
Hindustan Institute of Technology & Science 2023
My Stats
EXP gained
yellow-spark
6652
Level
6 (Specialist)
Community stats
Discussions
0
Upvotes
0
Know more
299
Total problems solved
284
Easy
12
Moderate
3
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:

11 days

Less

More

Achievements
2
Ronin
Topics
Linked List
Strings
1
Samurai
Guided path
Basics of python
1
Sensei
Guided path
Oops in python
Discussions
90% USING C++
Interview problems

Node* findMiddle(Node* head) {

    if (!head || !head->next) {

        return head;

    }

    int len = 0;

    Node* current = head;

 

    while (current) {

        current = current->next;

        len++;

    }

 

    current = head;

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

        current = current->next;

    }

    return current;

}

profile
Giga1025
Published On 22-Nov-2023
63 views
0 replies
1 upvotes
Python
Interview problems

from os import *

from sys import *

from collections import *

from math import *

 

def stringSum(num1: str, num2: str) -> str:

    result = ""

    i = len(num1) - 1

    j = len(num2) - 1

    carry = 0

 

    while i >= 0 or j >= 0 or carry:

        _sum = 0

 

        if i >= 0:

            _sum += int(num1[i])

            i -= 1

        if j >= 0:

            _sum += int(num2[j])

            j -= 1

 

        _sum += carry

        carry = _sum // 10

        result += str(_sum % 10)

 

    return result[::-1]  # Reverse the string to get the correct order

 

profile
Giga1025
Published On 20-Nov-2023
23 views
0 replies
0 upvotes
C++(99.27% BETTER THAN OTHERS)
Interview problems

#include <bits/stdc++.h> 

string leftRotate(string str, int d) {

    int n = str.size();  // Get the length of the string

    if (n == 0 || d == 0 || d % n == 0) {

        return str;  // No rotation needed

    }

    d = d % n;

    return str.substr(d) + str.substr(0, d);

}

 

string rightRotate(string str, int d) {

    int l = str.size();

    if (l == 0 || d == 0 || d % l == 0) {

        return str;  // No rotation needed

    }

    d = d % l;

    return str.substr(l - d) + str.substr(0, l - d);

}

profile
Giga1025
Published On 19-Nov-2023
14 views
0 replies
0 upvotes