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
Forwarded from 4-3-3 ስፖርት በኢትዮጵያ (𝐌𝐫.Ʀᴏʙᴀ)
የኮሪደር ሳር" በልተው የተያዙት አህዮች ጉዳይ!

እነዚህ ሁለት አህዮች ከአጥሩ ወጥተው፣ ብዙ ውዝግብ በሚያስነሳ ተግባር ላይ ተሰማርተው መገኘታቸው ተዘግቧል።

የክሱ ዝርዝር:
* ተከሳሾች: ሁለት አህያዎች ።
* የወንጀል ድርጊት:"የኮሪደር ሳር" (Corridor Grass) መብላት።

* የእስር ጊዜ: ከተያዙ በኋላ ለ30 ሰዓታት ያህል ታስረው እንደቆዩ ተሰምቷል።

የአካባቢው ነዋሪዎች እና ምስክሮች የአህዮቹ ታስሮ መቆየት ከመጠን በላይ እንደሆነ ቢገልጹም፣ አህዮቹ ግን በዝምታቸው እና በንፁህ ዓይናቸው የሚገባቸውን ፍርድ እየጠበቁ ነው።


ተጨማሪ ዝርዝር መረጃውን በዜና ቻናላችን ያግኙ - 433 World News

@Bisrat_Sport_433et @Bisrat_Sport_433et
🤣15🐳21
Forwarded from 「 Eyu core 」
በግ መስለዉ ወደ Spain ለመግባት ሲሞክሩ ድንበር ላይ የተያዙ ስደተኞች ናቸዉ
😁13🌚4
Hope🥺
29🫡3😢1
— UTTA 🍯
😁13
🤯52
Forwarded from ALX Ethiopia
Join Ethiopia's premier competitive programming hackathon.

A full-day, on-site event dedicated to advanced problem-solving, data structures and algorithms.

Form a team of three and compete in divisions open to both advanced (Elite) and intermediate (Open) coders for national recognition and exciting prizes! 🏆

🗓 ቅዳሜ, ኅዳር 27 2018 (December 6, 2025)
3፡00 - 11፡00 ሰአት (9:00 AM – 5:00 PM)
📍 CapStone ALX Tech Hub, Lideta
🔗 Register now: https://luma.com/9pobz8sd

#ALXEthiopia #CodeLeagueEthiopia #CompetitiveProgramming #DSA #dohardthings #ALXAfrica #lifeatALX
If your team is not yet full (less than 3 members), feel free to message me. @zprogramming_bot
I will help by connecting you with others who are also looking for teammates so you can form a complete team of 3.
Woow
72
All are last year A2sv interview questions for November intakes for G6
Forwarded from Leetcode with dani
sorry for the minor error on the test cases , here is the updated

Question: Count Substrings with Same Start and End Character
Given a string s consisting only of lowercase English letters, your task is to find the number of substrings that start and end with the same character.

Examples:
Input: "abcba"
Output: 7
Explanation: The substrings are: "a", "b", "c", "b", "a", "bcb", and "aba".

Input: "abacada"
Output: 13
Explanation: The substrings are: "a", "b", "a", "c", "a", "d", "a", "aba", "aca", "ada", "abaca", "abada", and "abacad".

Input: "a"
Output: 1
Explanation: The only substring is "a".

Input: "zzzz"
Output: 10
Explanation: The substrings are: "z", "z", "z", "z", "zz", "zz", "zz", "zzz", "zzz", and "zzzz".


Challenge:
Write a function that takes a string as input and returns the total count of substrings that start and end with the same character.
3
Forwarded from Leetcode with dani
Another Interview Question
▎Problem Statement

You are given a string s consisting only of the letters 'a' and 'b', and an integer k. You need to find the minimum number of character changes needed to obtain a substring of length ≥ k where all characters are the same.
Test Cases

Here are some test cases to illustrate the problem:

▎Test Case 1

• Input: s = "aabbaa", k = 3

• Output: 1

• Explanation: The substring "aaa" can be formed by changing one 'b' to 'a'.

▎Test Case 2

• Input: s = "ababab", k = 4

• Output: 2

• Explanation: To form "aaaa" or "bbbb", you need to change two characters (e.g., "aaab" or "bbba").

▎Test Case 3

• Input: s = "aaaaaa", k = 2

• Output: 0
👍1
Forwarded from Eunuch
Report on my Interview

Literally when I started my PC stacked🤯 and he was a peace guy he literally gave me 20 min after that I changed my PC with my friend and shared that.
1. After I shared my PC he introduced himself to me and also told me to share my screen asked me to go from tab desktop to check whether I shared my screen.
Also he asked me to show my ID in front of the screen.

2. He dropped the question it was
leetcode 1198 Premium question (https://github.com/doocs/leetcode/blob/main/solution/1100-1199/1198.Find%20Smallest%20Common%20Element%20in%20All%20Rows/README_EN.md)

3. I asked him to give me some time to understand the problem. When I saw the word strictly increasing I thought the question was Monotonic Stack but it wasn't.
4. After few silent minutes I think my adrelanine hormone just increased and the optimal one came to me but not the brute.
5. So I thought of a way to just sort the dictionary and make explain it as brute force. And literally it worked and asked me to Optimize it after I explained the time complexity. He also guided me on some other optimal related things like he told me to finish it inside the nested loop since it is strictly increasing matrix so I literally did that and explained as Optimal form and after I explained I implemented it quickly I started implementing while I was explaining the Brute one.
6. The technical was like that we finished it in 30min after that he gave 3 min and copy the code run and submit. He didn't told me whether it was accepted but I personally tested it on sharepad and it was correct for th given testcases.
7. After 5 min we started the Behavioural Interview he asked me 7 questions and agree on the policy the questions was literally same as the
G4 Interview Template

so I highly recommend to prepare on it.
8. After the interview I asked him about A2SV and other tech staff since he was Graduate student. And the interview entirely ended in 1:10 hr.
Forwarded from Eunuch
Forwarded from Eunuch
Today's Interview Question
You are given a string s, which contains stars *.

In one operation, you can:

Choose a star in s.
Remove the closest non-star character to its left, as well as remove the star itself.
Return the string after all stars have been removed.

Note:

The input will be generated such that the operation is always possible.
It can be shown that the resulting string will always be unique.


Example 1:
Input: s = "leet**cod*e"
Output: "lecoe"
Explanation: Performing the removals from left to right:
- The closest character to the 1st star is 't' in "leet**cod*e". s becomes "lee*cod*e".
- The closest character to the 2nd star is 'e' in "lee*cod*e". s becomes "lecod*e".
- The closest character to the 3rd star is 'd' in "lecod*e". s becomes "lecoe".
There are no more stars, so we return "lecoe".

Example 2:
Input: s = "erase*****"
Output: ""
Explanation: The entire string is removed, so we return an empty string.

Constraints:

1 <= s.length <= 10**5
s consists of lowercase English letters and stars *.
The operation above can be performed on s.
```
def fun(s):
    stack = []
    for c in s:
        if c != "*":
            stack.append(c)
        else:
            stack.pop()
    return "".join(stack)
print(fun("erase*****"))

`
Forwarded from Leetcode with dani
Todays interview question

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.

Given a string s, return true if it is a palindrome, or false otherwise.



Example 1:

Input: s = "A man, a plan, a canal: Panama"
Output: true
Explanation: "amanaplanacanalpanama" is a palindrome.
Example 2:

Input: s = "race a car"
Output: false
Explanation: "raceacar" is not a palindrome.
Example 3:

Input: s = " "
Output: true
Explanation: s is an empty string "" after removing non-alphanumeric characters.
Since an empty string reads the same forward and backward, it is a palindrome.


Constraints:

1 <= s.length <= 2 * 105
s consists only of printable ASCII characters.
Forwarded from Leetcode with dani
"""

Question Denoscription
Given an input string s, reverse the order of the words.

A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space.

Return a string of the words in reverse order concatenated by a single space.

Note that s may contain leading or trailing spaces or multiple spaces between two words.
The returned string should only have a single space separating the words. Do not include any extra spaces.



Example 1:

Input: s = "the sky is blue"
Output: "blue is sky the"
Example 2:

Input: s = " hello world "
Output: "world hello"
Explanation: Your reversed string should not contain leading or trailing spaces.
Example 3:

Input: s = "a good example"
Output: "example good a"
Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string.


Constraints:

1 <= s.length <= 104
s contains English letters (upper-case and lower-case), digits, and spaces ' '.
There is at least one word in s.


"a good example"
["a","good","example"]
L R


[example,"good","a"]


"""

#will s will split
#variables left->0 rght ->len(splited)-1
#will have a while l<L left+=1 righ-=1


def revercing_word(s):
words=[]
for word in s.split(" "):
if word:
words.append(word)

left=0
right=len(words)-1


while left<right:
words[left],words[right]= words[right],words[left]
left+=1
right-=1

return " ".join(words)
print(revercing_word("hello world"))
Forwarded from Leetcode with dani
another interview question

You are given a 0-indexed integer array nums.
Swaps of adjacent elements are able to be performed on nums.
A valid array meets the following conditions:
The largest element (any of the largest elements if there are multiple) is at the rightmost position in the array.
The smallest element (any of the smallest elements if there are multiple) is at the leftmost position in the array.
Return the minimum swaps required to make nums a valid array.

Example 1:
Input: nums = [3,4,5,5,3,1]
Output: 6
Explanation: Perform the following swaps:
- Swap 1: Swap the 3rd and 4th elements, nums is then [3,4,5,3,5,1].
- Swap 2: Swap the 4th and 5th elements, nums is then [3,4,5,3,1,5].
- Swap 3: Swap the 3rd and 4th elements, nums is then [3,4,5,1,3,5].
- Swap 4: Swap the 2nd and 3rd elements, nums is then [3,4,1,5,3,5].
- Swap 5: Swap the 1st and 2nd elements, nums is then [3,1,4,5,3,5].
- Swap 6: Swap the 0th and 1st elements, nums is then [1,3,4,5,3,5].
It can be shown that 6 swaps is the minimum swaps required to make a valid array.

Example 2:
Input: nums = [9]
Output: 0
Explanation: The array is already valid, so we return 0.




Constraints:
1 <= nums.length <= 10^5
1 <= nums[i] <= 10^5