< Ace Coding /> ๐
/* You are given a string s consisting only of lowercase English letters. We call a substring special if it contains no character which has occurred at least twice (in other words, it does not contain a repeating character). Your task is to count the numberโฆ
This one took me much longer time not gonna lie.๐ฎโ๐จ
โ Solution : this is as efficient as it can get
โ Solution : this is as efficient as it can get
python
def countSpaceialSubString(s):
seen = set()
l = 0
count = 0
for r in range(len(s)):
if s[r] in seen:
while s[l] != s[r]:
seen.remove(s[l])
l += 1
l += 1
seen.add(s[r])
count += r - l + 1
return count
print(countSpaceialSubString("abcd"))
print(countSpaceialSubString("ooo"))
print(countSpaceialSubString("abab"))
print(countSpaceialSubString("abcabc"))
Question: Can You Make This String a Palindrome?
A palindrome is a string that reads the same forwards and backwards. Given a string, determine if it's possible to rearrange the characters to form a palindrome.
Examples:
1. Input:
โข Output:
โข Explanation: The string is already a palindrome.
2. Input:
โข Output:
โข Explanation: Rearranging the characters can form the palindrome
3. Input:
โข Output:
โข Explanation: No rearrangement can form a palindrome.
4. Input:
โข Output:
โข Explanation: Rearranging the characters can form the palindrome
5. Input:
โข Output:
โข Explanation: The string is already a palindrome.
Challenge:
Write a function that takes a string as input and returns
A palindrome is a string that reads the same forwards and backwards. Given a string, determine if it's possible to rearrange the characters to form a palindrome.
Examples:
1. Input:
"civic"โข Output:
Trueโข Explanation: The string is already a palindrome.
2. Input:
"ivicc"โข Output:
Trueโข Explanation: Rearranging the characters can form the palindrome
"civic".3. Input:
"hello"โข Output:
Falseโข Explanation: No rearrangement can form a palindrome.
4. Input:
"aabbcc"โข Output:
Trueโข Explanation: Rearranging the characters can form the palindrome
"abcba".5. Input:
"racecar"โข Output:
Trueโข Explanation: The string is already a palindrome.
Challenge:
Write a function that takes a string as input and returns
True if the string can be rearranged to form a palindrome, and False otherwise.Question Description
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 = "unonleetcode", k = 5
Output: 2
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.
Example 3:
Input: s = "havefunonleetcode", k = 5
Output: 6
Explanation: There are 6 substrings they are: 'havef','avefu','vefun','efuno','etcod','tcode'.
โ Solution: as I have told you this pattern repeats a lot so you got this
def subStringK(s, k):
seen = set()
count = 0
l = 0
for r in range(len(s)):
if s[r] in seen:
while s[l] != s[r]:
seen.remove(s[l])
l += 1
l += 1
if r - l + 1 == k:
count += 1
seen.remove(s[l])
l += 1
seen.add(s[r])
return count
print(subStringK("unonleetcode", 5))
print(subStringK("havefunonleetcode", 5))
print(subStringK("aaabbaaa", 2))
print(subStringK("aaabbaaa", 100))
โ
Hello everyone, today was my interview date, and I was asked the following question: At first, I thought I could use the two pointers technique to solve it, but then I realized that that would make the algorithm inefficient. Then I noticed that the number of 1s will be the length of the subarray with grouped 1s. This changed my approach to a fixed sliding window, and then the rest was easy. My interviewer was very nice and guided me the whole way.
'''
Given a binary array data, return the minimum number of swaps required to group all 1โs
present in the array together in any place in the array.
Example 1:
Input: data = [1,0,1,0,1]
Output: 1
Explanation: There are 3 ways to group all 1's together:
[1,1,1,0,0] using 1 swap.
[0,1,1,1,0] using 2 swaps.
[0,0,1,1,1] using 1 swap.
The minimum is 1.
Example 2:
Input: data = [0,0,0,1,0]
Output: 0
Explanation: Since there is only one 1 in the array, no swaps are needed.
Example 3:
Input: data = [1,0,1,0,1,0,0,1,1,0,1] count_ones = 6 count_zeros = 3 curr_zeros = 3 min of count_zeros and curr_zeros
l
r
time comp = O(n)
space comp = O(1)
Output: 3
Explanation: One possible solution that uses 3 swaps is [0,0,0,0,0,1,1,1,1,1,1].
Constraints:
1 <= data.length <= 10**5
data[i] is either 0 or 1.
'''
"""
1. count 1's store one count_ones
2. assign count_zeros = inf curr_zeros = 0
3. l, r = 0
4. check for a valid window
5. update curr_zeros
6. take the min of the count_zeros and curr_zeros
7. check if the values at the indexes are zeros if so decrement curr_zeros
8. update pointers
9. return count_zeros
"""
# my code
"""
1= 6
curr_zeros = 3
count_zeros = 3
1,0,1,0,1,0,0,1,1,0,1
l
r
"""
#A2SV #a2sv #a2sv2024
A2SV a2sv 2024 In person
๐ @AceCoding Presents! ๐
'''
Given a binary array data, return the minimum number of swaps required to group all 1โs
present in the array together in any place in the array.
Example 1:
Input: data = [1,0,1,0,1]
Output: 1
Explanation: There are 3 ways to group all 1's together:
[1,1,1,0,0] using 1 swap.
[0,1,1,1,0] using 2 swaps.
[0,0,1,1,1] using 1 swap.
The minimum is 1.
Example 2:
Input: data = [0,0,0,1,0]
Output: 0
Explanation: Since there is only one 1 in the array, no swaps are needed.
Example 3:
Input: data = [1,0,1,0,1,0,0,1,1,0,1] count_ones = 6 count_zeros = 3 curr_zeros = 3 min of count_zeros and curr_zeros
l
r
time comp = O(n)
space comp = O(1)
Output: 3
Explanation: One possible solution that uses 3 swaps is [0,0,0,0,0,1,1,1,1,1,1].
Constraints:
1 <= data.length <= 10**5
data[i] is either 0 or 1.
'''
"""
1. count 1's store one count_ones
2. assign count_zeros = inf curr_zeros = 0
3. l, r = 0
4. check for a valid window
5. update curr_zeros
6. take the min of the count_zeros and curr_zeros
7. check if the values at the indexes are zeros if so decrement curr_zeros
8. update pointers
9. return count_zeros
"""
# my code
def minNumberOfSwaps(arr):
count_ones = arr.count(1)
count_zeros, curr_zeros = float('inf'), 0
l = 0
for r in range(len(arr)):
if arr[r] == 0:
curr_zeros += 1
# check for a valid window
if r - l + 1 == count_ones:
count_zeros = min(count_zeros, curr_zeros)
if arr[l] == 0:
curr_zeros -= 1
l += 1
return count_zeros if count_zeros != float('inf') else 0
"""
1= 6
curr_zeros = 3
count_zeros = 3
1,0,1,0,1,0,0,1,1,0,1
l
r
"""
#A2SV #a2sv #a2sv2024
A2SV a2sv 2024 In person
๐ @AceCoding Presents! ๐
๐9
"""
You are given a string s consisting only of the letters 'a' and 'b', and an integer k.
What is the minimum number of characters you need to change to obtain a substring of length โฅ k where all characters are the same?
Example 1:
s = โaabaabaaโ, k = 3
Output: 1
Explanation: s can be transformed to โaaaaabaaโ
Example 2:
s = โbbabbabaโ, k = 8
Output: 3
Explanation: s can be transformed to โbbbbbbbbโ
Constraints:
1 <= s.length <= 10^5
1 <= k <= s.length
aaab, k = 4
aaaa
abs(3 - 1) = 2
"""
You are given a string s consisting only of the letters 'a' and 'b', and an integer k.
What is the minimum number of characters you need to change to obtain a substring of length โฅ k where all characters are the same?
Example 1:
s = โaabaabaaโ, k = 3
Output: 1
Explanation: s can be transformed to โaaaaabaaโ
Example 2:
s = โbbabbabaโ, k = 8
Output: 3
Explanation: s can be transformed to โbbbbbbbbโ
Constraints:
1 <= s.length <= 10^5
1 <= k <= s.length
aaab, k = 4
aaaa
abs(3 - 1) = 2
"""
๐3
Given an array of integer arrays arrays where each arrays[i] is sorted in strictly increasing order,
return an integer array representing the longest common subsequence among all the arrays.
A subsequence is a sequence that can be derived from another sequence by deleting some elements (possibly none)
without changing the order of the remaining elements.
Example 1:
Input: arrays = [[1,3,4],
[1,4,7,9]]
Output: [1,4]
Explanation: The longest common subsequence in the two arrays is [1,4].
Example 2:
Input: arrays = [[2,3,6,8],
[1,2,3,5,6,7,10],
[2,3,4,6,9]]
Output: [2,3,6]
Explanation: The longest common subsequence in all three arrays is [2,3,6].
Example 3:
Input: arrays = [[1,2,3,4,5],
[6,7,8]]
Output: []
Explanation: There is no common subsequence between the two arrays.
Constraints:
2 <= arrays.length <= 100
1 <= arrays[i].length <= 100
1 <= arrays[i][j] <= 100
arrays[i] is sorted in strictly increasing order.
'''
return an integer array representing the longest common subsequence among all the arrays.
A subsequence is a sequence that can be derived from another sequence by deleting some elements (possibly none)
without changing the order of the remaining elements.
Example 1:
Input: arrays = [[1,3,4],
[1,4,7,9]]
Output: [1,4]
Explanation: The longest common subsequence in the two arrays is [1,4].
Example 2:
Input: arrays = [[2,3,6,8],
[1,2,3,5,6,7,10],
[2,3,4,6,9]]
Output: [2,3,6]
Explanation: The longest common subsequence in all three arrays is [2,3,6].
Example 3:
Input: arrays = [[1,2,3,4,5],
[6,7,8]]
Output: []
Explanation: There is no common subsequence between the two arrays.
Constraints:
2 <= arrays.length <= 100
1 <= arrays[i].length <= 100
1 <= arrays[i][j] <= 100
arrays[i] is sorted in strictly increasing order.
'''
Forwarded from AASTU CPC
#Registration
Register Here
Requirement:
A student of AASTU
(Any department)
Interest for puzzles, games, problem solving
Join us @aastucpc
Register Here
Requirement:
A student of AASTU
(Any department)
Interest for puzzles, games, problem solving
Join us @aastucpc
๐ฅ4
แญแ
แ แแตแ แจแแณแฉแต แแ
: แซแคแ
แฐแแแ แญแฃแแแข แจ8แ แญแแ แฐแแช แแแข แจแแแจแ แจแซ แ แฃแถ แฒแแ แซแแ แแ แจแฉแแแต แ แฝแณ แจแแจแจแป แฐแจแ แแญ แตแแฐแจแฐ แแฐ แแช แแแญ แแถ transplant แแตแจแ แฅแแณแแ แต แแคแฐแฐแฆแน แฐแแแฏแแข แแ
แญแแแแ แแฐ 5 แแแจแ แฅแญ แซแตแแแแแแข แ แฃแฑ แจแ แฃแถ แแฐแจแฐ แญแญแตแถแต แค/แญ แ แแแแญ แฒแแ แแ แจแแข แแแญ แตแแแแ แแ แฅแแฒแณแจแ แฅแญแณแณ แ แญแแแข
แตแแแ แจแแ แฅแแดแ แ แญแแต แฃแแ แ แ แ แ แแฐแแ แฅแแณแฐแแค แฅแแแแญแแต!
แแแฐแแ แจแแตแแแ: Account holder: Solomon Alemayehu (Yabetsโ Father)
CBE: 1000057164143
Awash: 01320037587500
Abyssinia: 102845781
Cooperative : 1000072492677
Go fund me: https://gofund.me/698c8f50
Phone: 0911670476/ 0962157832
แตแแแ แจแแ แฅแแดแ แ แญแแต แฃแแ แ แ แ แ แแฐแแ แฅแแณแฐแแค แฅแแแแญแแต!
แแแฐแแ แจแแตแแแ: Account holder: Solomon Alemayehu (Yabetsโ Father)
CBE: 1000057164143
Awash: 01320037587500
Abyssinia: 102845781
Cooperative : 1000072492677
Go fund me: https://gofund.me/698c8f50
Phone: 0911670476/ 0962157832
โค3๐1
๐ G6 A2SV In-Person Education Program results ๐๐
The G6 A2SV In-Person Education Program results will be revealed by the end of next week! ๐โจ
Stay tuned, and get ready to celebrate your hard work and achievements! ๐งโ๐ป๐
#A2SVResults ๐
@AceCoding presents
The G6 A2SV In-Person Education Program results will be revealed by the end of next week! ๐โจ
Source: A2SV - Weekly Wins and Demos - December 27
๐ See the updates on the Remote Education too.
Stay tuned, and get ready to celebrate your hard work and achievements! ๐งโ๐ป๐
#A2SVResults ๐
@AceCoding presents
๐1
โ
Mastering Browsers Dev tools with a single video:
๐Recommendation source ๐ Evangadi Fullstack web dev course.
https://youtu.be/x4q86IjJFag?si=UIQxXYxzXHYcr96Q
๐Recommendation source ๐ Evangadi Fullstack web dev course.
https://youtu.be/x4q86IjJFag?si=UIQxXYxzXHYcr96Q
YouTube
Google Chrome Developer Tools Crash Course
In this video we will be taking an intermediate look at the Google Developer Tools. You will learn how to do things such as...
Inspect & Examine HTML/CSS
Edit HTML/CSS
Enable/Disabled styles
Move & Delete Elements
Console Logs & Other Commands
Special Consoleโฆ
Inspect & Examine HTML/CSS
Edit HTML/CSS
Enable/Disabled styles
Move & Delete Elements
Console Logs & Other Commands
Special Consoleโฆ
๐2
Forwarded from AASTU POLL AND QUIZ QUESTIONS (Natben แ แก แซแขแฃ ๐ค)
๐ป Call for Registration for Winter Bootcamp
[UNESCO UNITWIN] 2025 Winter Digital Innovation BootCamp
Theme: Artificial Intelligence and K-eGov Open Source Framework in Ethiopia
The Bootcamp registration is now open!
Due Date: January 25 (Saturday)
๐๐พ Registration Link
You can also access the registration link via the QR Code provided on the poster above.
For inquiries, feel free to contact us via email at kimyena@handong.edu
แฅแซแ แซแแฝแ แฅแแ แแญ แแ แจแฅ แตแฝแแแฝแ ๐โโ๏ธ๐๐๐๐๐๐๐๐๐๐๐๐๐
โ๏ธโ๏ธ@Aastu_poll_and_quiz_botโ๏ธโ๏ธ
โ๏ธโ๏ธโ๏ธโ๏ธโ๏ธโ๏ธโ๏ธโ๏ธโ๏ธโ๏ธโ๏ธโ๏ธ
๐ค๐ค๐๐๐๐๐๐๐๐ค๐ค
๐๐๐ @Aastu_poll ๐๐
๐๐๐ @Aastu_poll ๐๐
๐๐๐ @Aastu_poll ๐๐
๐๐ ๐๐๐๐๐๐๐๐
๐1
Calling All AASTU Students: Join UniHack 2025!
Are you ready to innovate, solve challenges, and showcase your skills? UniHack 2025 is exclusively for AASTU students, offering you the platform to turn your ideas into impactful projects.
๐ Event Date: February 19, 2025
๐ Venue: Old graduation hall(AASTU)
๐ Apply Now: LINK
Who Can Apply?
This event is exclusively for AASTU students from any department. Whether youโre a coder, designer, or idea generator, thereโs a place for you at UniHack!
Donโt miss this incredible opportunity to represent AASTUโs innovation and talent.
๐ Visit our Website LINK for more details and to apply.
Spaces are limited, so apply today and get ready to innovate!
๐2
Check your emails๐จ
A2SV is sending acceptance emails for G6 In person Education๐๐
#A2SVInPersonEducation #G6
@AceCoding
๐3
Have you joined A2SV G6 in person Education?
Anonymous Poll
39%
yes
32%
no
29%
I will try for the second intake
๐5
How to deploy static websites using GitHub : ๐ Watch This
For Dynamic websites, use other deploying platforms like Netlify, Vercel, or Hostinger alongside bundling tools like vite, parcel, or Webpack. You can use this deploying sites or platforms for statics websites too without bundling tools.
@AceCoding
For Dynamic websites, use other deploying platforms like Netlify, Vercel, or Hostinger alongside bundling tools like vite, parcel, or Webpack. You can use this deploying sites or platforms for statics websites too without bundling tools.
@AceCoding