Leetcode with dani – Telegram
Leetcode with dani
1.31K subscribers
196 photos
14 videos
56 files
240 links
Join us and let's tackle leet code questions together: improve your problem-solving skills
Preparing for coding interviews
learning new algorithms and data structures
connect with other coding enthusiasts
Download Telegram
If anyone has questions or is interviewed by A2SV today, please share the questions with me. I'll post them in this channel!
@zprogramming_bot
👍52
Question Denoscription
You are given a 0-indexed string s consisting of only lowercase English letters. Return the number of substrings in s that begin and end with the same character.
A substring is a contiguous non-empty sequence of characters within a string.

Example 1:
Input: s = "abcba" #"a", "b", "c", "b","a",abcba","bcb" a:2 b:2 c : 1
Output: 7
Explanation:
The substrings of length 1 that start and end with the same letter are: "a", "b", "c", "b", and "a".
The substring of length 3 that starts and ends with the same letter is: "bcb".
The substring of length 5 that starts and ends with the same letter is: "abcba".

Example 2:

Input: s = "abacad"
Output: 9
Explanation:
The substrings of length 1 that start and end with the same letter are: "a", "b", "a", "c", "a", and "d".
The substrings of length 3 that start and end with the same letter are: "aba" and "aca".
The substring of length 5 that starts and ends with the same letter is: "abaca".

Example 3:

Input: s = "a"
Output: 1
Explanation:
The substring of length 1 that starts and ends with the same letter is: "a".


Constraints:

1 <= s.length <= 105
s consists only of lowercase English letters
Forwarded from Ibnu-Nezif Abasambi
I HAVE INTERVIEWED ON A2SV ON THURSDAY AND THE QUESTION WAS



/*
Question Denoscription
Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters.

Example 1:

Input: s = "havefunonleetcode", k = 5
Output: 6
Explanation: There are 6 substrings they are: 'havef','avefu','vefun','efuno','etcod','tcode'.

Example 2:

Input: s = "home", k = 5
Output: 0
Explanation: Notice k can be larger than the length of s. In this case, it is not possible to find any substring.


Constraints:

1 <= s.length <= 104
s consists of lowercase English letters.
1 <= k <= 104
*/


FINALLY I HAVE SOLVED THE QUESTION LIKE THIS IN C++ MAY BE IT IS USEFUL
#include <bits/stdc++.h>
using namespace std;
class Solution {
public :
int solve (string s,int k){
vector <int> freq(26);

int l=0;int r=0;
int offset=(int)'a';
int ans=0;
while (r<s.size()){
if (r-l<k-1){
freq[s[r]-offset]++;
r++;
}else if (r-l==k-1){
freq[s[r]-offset]++;
r++;
bool t=true;
for (int x:freq){
if (x>1){
t=false;
}
}
t?ans+=1:ans=ans;

}else if (r-l>k-1){
freq[s[l]-offset]--;
l++;
}

}
return ans;
}
};

int main () {
string s="abcdefhijklmnopqrstuvwxyz";
int k=5;
Solution* sol=new Solution();
cout<<sol->solve(s,k);
}
41
Forwarded from Dagmawi Babi
Was talking to Emre and yeah A2SV is staying and the issues are resolving. There's still an issue of funding but he's very hopeful about it now. We won :)

I'm super glad and I'm happy for all the present and future A2SVians. This's wonderful news. Thank you everyone that supported, shared and encouraged this. ❤️
👍9🤗3
When someone mentions on LinkedIn "I finally landed my dream job", they miss to tell you about

Let's think about it step by step.

Why Do You Need a Job?

Before jumping into any career path, ask yourself:

➤ Why do I need a job?

Is it for financial stability?

Personal growth?

A sense of purpose?

Jobs can provide structure, income, and learning opportunities. But they are not the only way to achieve these goals. Clarity on your "why" will help you make smarter decisions.

What if the market is not in your favor, which it is right now?

The job market is unpredictable. Recessions, layoffs, and industry shifts happen. So, what's your backup plan?

Here are some alternatives:

Freelancing: Offer your skills to clients worldwide. Platforms like Upwork or Fiverr make this easier than ever.
Starting a Side Hustle: Turn hobbies into income. Think tutoring, content creation, or selling digital products.

Remote Work: Explore temporary or part-time remote jobs to stay flexible while earning.

Your job shouldn't be your only source of income. Think of ways to diversify.

How Can You Acquire More Skills to Turn the Tables?

If the market isn't working for you, invest in yourself.

➤ Here's how:

Take Online Courses: Platforms like Coursera or Udemy offer affordable courses in trending fields.

Network: Attend webinars, join LinkedIn groups, and connect with industry leaders.

Experiment: Take on small projects outside your comfort zone to build confidence and expertise.

Every new skill adds value to your profile and opens new opportunities.

Look for jobs that offer more than a paycheck

A great job isn't just about money.

➤ It's about:

Learning: Does the role teach you something new?

Growth: Will it help you progress in your career?

Stability: Does it offer financial and mental security?

If a job doesn't check these boxes, it might be time to reassess.
Hustle, but avoid toxicity

➤ Hard work is essential, but remember:

Hustle is healthy; toxicity is not.

Your mental health and well-being are non-negotiable.

Walk away from environments that drain you. Success should feel empowering, not exhausting.

So,

Build multiple income streams.

Keep growing and learning.

Prioritize your happiness and health.

So, what's your next step? Are you building skills, exploring alternatives, or rethinking your path? Tell me in the comments below!
👍51
እንኳን ለ ትንሳኤ በዓል በሰላም አደረሳችሁ መልካም በዓል ይሁንላችሁ
🙏8👍1
Forwarded from A2SV Memes
we got this through @a2svmemesbot
👍2😁1
Forwarded from Hanix
iCog Labs AI Internship – 2025 Batch 1

Gain hands-on experience in AI, ML, Robotics, Bioinformatics, Blockchain, and more!

Open to students, graduates & self-taught learners across Africa & Asia.

10 hrs/week in-person for Ethiopians in Ethiopia.

Deadline:July 31

Apply Here.

@HanixJourney

#iCogLabs #AIInternship
👍5
Summer Opportunity for third year and above students

🎓Summer University 2025: Learn, Travel, Change the World!

For whom?
Undergraduate students (3rd or 4th year) from universities outside of Russia.

What?
Free two-week intensive (July 21 – August 3, 2025):
˗ Masterclasses from expert speakers.
˗ Project work in international teams.
˗ Cultural exchange and excursions.

Why you?
˗ Organizers cover flights, accommodation, meals, and all activities.
˗ Level up your skills, add global experience to your resume.
˗ Make friends from around the globe.

How to participate?
1. Register on the website summeruniversity.ru. by May 12, 2025.
2. Submit a motivational video (2-3 minutes): explain why you want this project and what ideas you want to implement.
3. Await selection results – announced by May 30!

🗣Don't delay! Places are limited, competition is high. Show you're ready to learn, not just relax – this isn't a vacation!

Program details and requirements are available on their website summeruniversity.ru

From SiTE Notice Board
Sharing is caring 🥰
Deadline: May 12, 2025
👍2
---

Bitwise Tricks in Python

1. Check Even/Odd

def is_odd(n: int) -> bool:
    return bool(n & 1)

# Usage:
n = 7
print("Odd" if is_odd(n) else "Even")  # Output: Odd

Try: “Check if a Number is Odd or Even” on GeeksforGeeks (GfG)

---

2. Swap Two Numbers Without a Temp Variable

def xor_swap(a: int, b: int) -> tuple[int, int]:
    a ^= b
    b ^= a
    a ^= b
    return a, b

# Usage:
x, y = 5, 9
x, y = xor_swap(x, y)
print(x, y)  # Output: 9 5

Note: In real Python, you can simply use x, y = y, x.

---

3. Turn Off the Rightmost Set Bit

def clear_lowest_bit(n: int) -> int:
    return n & (n - 1)

# Usage:
n = 0b10110  # 22
print(bin(clear_lowest_bit(n)))  # Output: 0b10100 (20)

Try: “Count Set Bits in an Integer” on GfG (use this in a loop)

---

4. Isolate the Rightmost Set Bit

def lowest_bit(n: int) -> int:
    return n & -n

# Usage:
n = 0b10110  # 22
print(bin(lowest_bit(n)))  # Output: 0b10 (2)

Try: “Find Position of Rightmost Different Bit” on GfG

---

5. Check Power of Two

def is_power_of_two(n: int) -> bool:
    return n > 0 and (n & (n - 1)) == 0

# Usage:
for x in [1, 2, 3, 16, 18]:
    print(x, is_power_of_two(x))

Try: “Check if a Number is a Power of Two” on GfG

---

6. Count Set Bits (Brian Kernighan’s Algorithm)

def count_set_bits(n: int) -> int:
    count = 0
    while n:
        n &= (n - 1)
        count += 1
    return count

# Usage:
print(count_set_bits(29))  # Output: 4, since 29 is 11101₂

Try: “Count Set Bits” on GfG (Python)

---

7. Add Two Numbers Without ‘+’

def add(a: int, b: int) -> int:
    MASK = 0xFFFFFFFF
    while b != 0:
        carry = (a & b) & MASK
        a = (a ^ b) & MASK
        b = (carry << 1) & MASK
   
    return a if a <= 0x7FFFFFFF else ~(a ^ MASK)

# Usage:
print(add(15, 27))  # Output: 42
print(add(-5, 3))   # Output: -2

Try: “Sum of Two Integers” on LeetCode (Python)

---

8. Test Opposite Signs

def opposite_signs(a: int, b: int) -> bool:
    return (a ^ b) < 0

# Usage:
print(opposite_signs(5, -3))   # Output: True
print(opposite_signs(-4, -2))  # Output: False

Try: “Check if Two Numbers Have Opposite Signs” on GfG

---

9. Reverse Bits of a 32-bit Integer

def reverse_bits(n: int) -> int:
    result = 0
    for _ in range(32):
        result = (result << 1) | (n & 1)
        n >>= 1
    return result & 0xFFFFFFFF

# Usage:
x = 0b00000010100101000001111010011100
print(bin(reverse_bits(x))) 

Try: “Reverse Bits” on LeetCode (Python)

---

10. Gray Code Conversion

def to_gray(n: int) -> int:
    return n ^ (n >> 1)

def gray_to_binary(g: int) -> int:
    mask = g
    while mask:
        mask >>= 1
        g ^= mask
    return g

# Usage:
for i in range(8):
    g = to_gray(i)
    print(f"{i:3} → Gray {g:3} → Back {gray_to_binary(g):3}")

Try: “Gray Code” on LeetCode (Python)

---

🎯 Next Steps:

1. Pick one or two of these tricks.

2. Find the corresponding GfG problem in Python and implement it.

3. Time yourself and compare it to a straightforward solution.
4
Forwarded from Hanix
Summer Camp and Internships

1. INSA Cyber Talent Challenge – 2017 E.C.

Tracks: Cybersecurity | Development | Embedded Systems | Aerospace

Apply: Here

2.iCog Labs AI Internship – 2025 Batch 1

Tracks: AI | ML | Robotics | Bioinformatics | Blockchain

Deadline: July 31

Apply:Here

3. Kuraz Technologies Hybrid Internship

Type: Summer | Unpaid | Hybrid

Deadline: May 31

Apply: Here

4. Tewanay Engineering Summer Internship

Tracks: Front-End | Back-End | Mobile App Development

Deadline: May 31

Apply: Here


@HanixJourney

#Internship
3👍2