Leetcode with dani
Відкрити в Telegram
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
Показати більше1 256
Підписники
+224 години
+27 днів
-230 день
Архів дописів
1 256
Repost 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 256
Repost 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.
1 256
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.
1 256
Repost 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
1 256
Repost from 4-3-3 ስፖርት በኢትዮጵያ™
የኮሪደር ሳር" በልተው የተያዙት አህዮች ጉዳይ!
እነዚህ ሁለት አህዮች ከአጥሩ ወጥተው፣ ብዙ ውዝግብ በሚያስነሳ ተግባር ላይ ተሰማርተው መገኘታቸው ተዘግቧል።
የክሱ ዝርዝር:
* ተከሳሾች: ሁለት አህያዎች ።
* የወንጀል ድርጊት:"የኮሪደር ሳር" (Corridor Grass) መብላት።
* የእስር ጊዜ: ከተያዙ በኋላ ለ30 ሰዓታት ያህል ታስረው እንደቆዩ ተሰምቷል።
የአካባቢው ነዋሪዎች እና ምስክሮች የአህዮቹ ታስሮ መቆየት ከመጠን በላይ እንደሆነ ቢገልጹም፣ አህዮቹ ግን በዝምታቸው እና በንፁህ ዓይናቸው የሚገባቸውን ፍርድ እየጠበቁ ነው።
ተጨማሪ ዝርዝር መረጃውን በዜና ቻናላችን ያግኙ - 433 World News
@Bisrat_Sport_433et @Bisrat_Sport_433et
1 256
📢 Deadline Extended!
Due to the overwhelming number of requests, we’ve officially extended the A2SV G7 Education Application deadline to November 21.
This is your moment to learn, grow, and master world-class software engineering skills through one of Africa’s most rigorous and impactful education programs.
Join a program that builds a solid foundation for your tech career and opens doors to global opportunities at companies like Google, Bloomberg, Amazon, and Databricks. Don’t miss it! 🌍
👉 Apply now: https://form.typeform.com/to/xIK0MwKn
👉Spread the word! Share to a friend and help us reach more aspiring engineers.
1 256
Repost from N/a
You saw the demo. Now it’s time to try it.
Mekach’s waitlist is officially open.
🛡 https://mekach.yonathan.tech
1 256
You saw the demo. Now it’s time to try it.
Mekach’s waitlist is officially open.
🛡 https://mekach.yonathan.tech
1 256
If u love science and PHY check this utube channel it's makes science and phy easy and interesting https://youtube.com/@mahesh_shenoy?si=3kd_uV6fyvcMKi9T
1 256
This question wasn't for Nov interviews it was for march 2nd opening , it is a little bit harder
1 256
"""
Question Description
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"))