< Ace Coding /> ๐Ÿš€
337 subscribers
54 photos
2 videos
95 files
66 links
Welcome to Ace Coding! Join us for tips, tutorials, and insights on coding and software engineering. Stay updated with the latest content and elevate your programming skills!Let's learn and grow together in the world of software engineering!
Download Telegram
Computer architecture focuses solely on hardware components.
Anonymous Quiz
52%
โœ… True
48%
โŒ False
Execution Time Calculation
A processor has the following specs:
Clock Speed: 3 GHz CPI: 2 Total Instructions: 5 billion How much time does it take to execute the program?
Anonymous Quiz
0%
1.5 seconds
9%
2.5 seconds
91%
3.33 seconds
0%
4 seconds
๐Ÿš€ Two Pointers Problems upcoming! ๐Ÿง‘โ€๐Ÿ’ปโžก๏ธ๐Ÿ‘จโ€๐Ÿ’ป
โœ… A2SV Prep ๐Ÿ’ป

๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ’ป Topic: Two Pointers

โœ… The following questions should be done sequentially. Level 1 and Level 2

๐ŸŸก 2079. Watering Plants This an Easy Medium

โณ This costed me 5 min
class Solution:
def wateringPlants(self, plants: List[int], capacity: int) -> int:
steps = 0
can = capacity
for i, plant in enumerate(plants):

if plant > can:
steps += (2 * i)
can = capacity

steps += 1
can -= plant

return steps

๐Ÿ‘‰ Problem link : https://leetcode.com/problems/watering-plants/

๐ŸŸก 2105. Watering Plants II This one is also an easy medium but it has more edge cases so watch out before you hit submit ๐Ÿ˜

โณ This costed me 15 min; if there is anyone who did this under 10 minutes Excellent, Great job
class Solution:
def minimumRefill(self, plants: List[int], capacityA: int, capacityB: int) -> int:
refill = 0
L, R = 0, len(plants) - 1
alice, bob = capacityA, capacityB
while L < R:
if plants[L] > alice:
alice = capacityA
refill += 1
if plants[R] > bob:
bob = capacityB
refill += 1
alice -= plants[L]
bob -= plants[R]
L += 1
R -= 1

if L == R:
max_water = max(alice, bob)
if plants[L] > max_water:
refill += 1

return refill

๐Ÿ‘‰ Problem link : https://leetcode.com/problems/watering-plants-ii/description/
๐Ÿ‘4
Forwarded from A2SV | Africa to Silicon Valley (A2SV)
Applications are Open for A2SV G6 Education!

The time has come for A2SV to welcome new members! Weโ€™re looking for team-oriented individuals with a never-give-up mentality, ready to drive tech excellence and solve impactful challenges.

๐Ÿ“… Application opens: November 14, 2024
๐Ÿ“… Deadline: November 20, 2024, at 11:59 PM EAT

๐ŸŽ“ Eligibility

Open to current students from Addis Ababa University (AAU), Addis Ababa Science and Technology University (AASTU), and Adama Science and Technology University (ASTU). If you're not from these schools or have already graduated, stay tuned for future remote applications!

๐Ÿ” Requirements

- Familiarity with at least one programming language
- Experience with platforms like LeetCode or Codeforces
- Completed at least 40 problems on LeetCode or Codeforces

๐Ÿค– Selection Process

- First Round Filtering: Initial application review
- Technical & Behavioral Interviews: For selected candidates, to assess skills and fit for the program

โŒ›๏ธ Donโ€™t wait! Start your application early to ensure a standout submission. ๐ŸŽฏ

๐Ÿ”— Apply now: link

#A2SV #TechEducation #EmpoweringAfrica #ApplyNow
exam questions.pdf
6.5 KB
โœ… AASTU 2023 GC  COA MID EXAM

Computer organization and architecture Mid exam with correct answers

๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
โค1
Forwarded from GDG On Campus AASTU (๐š‹๐š’๐š›๐šž๐š” ๐š–)
โญ๏ธ Attention Students! Register Now for Google Developer Group Study Sessions! โญ๏ธ

Are you ready to kickstart your tech career or take your skills to the next level? ๐Ÿš€ Whether youโ€™re a complete beginner or a seasoned coder, we have a track thatโ€™s perfect for you to grow, learn, and build something amazing! ๐ŸŒฑ๐Ÿ‘จโ€๐Ÿ’ป

๐Ÿง‘โ€๐ŸŽ“ Available Tracks:


1. Data Structures & Algorithms (DSA)
Master problem-solving techniques and boost your coding skills with DSA! ๐Ÿ”๐Ÿงฉ

2. Backend Development (Django & Node.js)
Dive into backend development and build powerful server-side applications! โš™๏ธ๐Ÿ›ก

3. Mobile Development with Flutter
Create sleek, cross-platform mobile apps that users love! ๐Ÿ“ฑโšก๏ธ

4. Web Development with React
Learn the framework that powers some of the worldโ€™s best applications! ๐ŸŒŽโœจ

5. Beginners Track

No coding experience? No problem! Learn the essentials of HTML, CSS, and JavaScript from the ground up! ๐ŸŒฑ

๐Ÿ‘‰ Donโ€™t Waitโ€”Register Now!

Join a community of creators, builders, and innovators and be part of the future of tech! ๐ŸŒŽ๐Ÿš€
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ’ปA2SV prep: Sliding window problem

๐ŸŸก 2024. Maximize the Confusion of an Exam

Straight forward solution
class Solution:
def maxConsecutiveAnswers(self, answerKey: str, k: int) -> int:
n = len(answerKey)
max_length = 0

flips = k
l, r = 0, 0
# F -> T
while r < n:
if answerKey[r] == 'F':
flips -= 1
if flips < 0:
if answerKey[l] == 'F':
flips += 1
l += 1

max_length = max(max_length, r - l + 1)
r += 1

flips = k
l, r = 0, 0
# T -> F
while r < n:
if answerKey[r] == 'T':
flips -= 1
if flips < 0:
if answerKey[l] == 'T':
flips += 1
l += 1

max_length = max(max_length, r - l + 1)
r += 1

return max_length


As you have noticed there are some repetions in the code so I have modularized it into one single function that can calculate the possible maximum length.

class Solution:
def maxConsecutiveAnswers(self, answerKey: str, k: int) -> int:

def calculateLength(ans: str):
flips = k
max_length = 0

n = len(answerKey)
l, r = 0, 0

while r < n:
if answerKey[r] == ans:
flips -= 1
if flips < 0:
if answerKey[l] == ans:
flips += 1
l += 1

max_length = max(max_length, r - l + 1)
r += 1

return max_length

return max(calculateLength('T'), calculateLength('F'))


https://leetcode.com/problems/maximize-the-confusion-of-an-exam/description/
๐Ÿ“ฃ A2SV Interview Format ๐Ÿ“ฃ

Get ready for an exciting and comprehensive interview process! Hereโ€™s what to expect:

๐Ÿ•’ Total Duration: 1 Hour 30 Minutes

๐Ÿ’Ž Behavioral Interview (First 45 Minutes)
This part of the interview will focus on your past experiences, skills, and motivations.
Be prepared to discuss situations where you demonstrated leadership, teamwork, and problem-solving abilities.
They might ask questions like:
โญ๏ธ Tell me about yourself.
โญ๏ธ What do you know about A2SV and why do you want to join us?
โญ๏ธ Describe a time when you had to step out of your comfort zone to achieve something.

๐Ÿ’Ž Technical Interview (Remaining 45 Minutes)
This segment will test your coding and problem-solving skills.
Youโ€™ll be given programming challenges to solve in real-time.
Much of this interview will utilize sharepad.io as the collaborative coding editor.
Example questions might include:
Write a function to solve a particular algorithm problem.
Explain your approach to solving a complex data structure challenge.

๐Ÿ”ง Preparation Tips:

๐Ÿ’Ž Practice Coding: Brush up on your data structures and algorithms. Websites like LeetCode and codeforce are great for practice.

๐Ÿ’Ž Stay Calm and Confident: Remember, theyโ€™re not just looking for the right answers but also how you approach problems and handle stress.


Prepare well and best of luck to everyone!๐Ÿงจ๐Ÿš€
โœ… Almost Identical question with the above ๐Ÿ‘†very easy if you did the above

๐Ÿ’ปA2SV prep: Sliding window problem
๐ŸŸก 1004. Max Consecutive Ones III

โณ2 min on the clock PR for me ๐Ÿ˜…

class Solution:
def longestOnes(self, nums: List[int], k: int) -> int:
max_length = 0
l = 0
for r in range(len(nums)):
if nums[r] == 0:
k -= 1
while k < 0:
if nums[l] == 0:
k += 1
l += 1

max_length = max(max_length, r - l + 1)

return max_length


๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ

https://leetcode.com/problems/max-consecutive-ones-iii/description/
๐Ÿ“กCOA - Computer Organization and Architecture

Hardwired vs. Microprogrammed (Softwired) Logic

โœ… The Teacher was stressing this topic (๐Ÿ’ฐlikely to come up on the exam)

Hardwired Logic:
Functionality is embedded directly into the hardware using fixed circuits. These systems are fast and efficient but lack flexibility, as changes require hardware redesign. This is common in specific-purpose computers, like appliances or embedded systems optimized for specific tasks (e.g., calculators).

Microprogrammed (Softwired) Logic:
Here, functionality is defined by software, making these systems flexible and adaptable but slightly slower due to software execution overhead. Softwired logic is a hallmark of general-purpose computers, like laptops or servers, which can handle multiple tasks by running different programs.

Takeaway:
Hardwired logic is best for specialized, high-speed tasks, while softwired logic is ideal for versatile, multi-functional systems.

๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ’ป A2SV prep: Sliding window problem

โœ… The following questions should be done sequentially. Level 1 and Level 2

๐ŸŸข 3206. Alternating Groups I Easy
๐Ÿ”—Link: Click here!

python 
class Solution:
def numberOfAlternatingGroups(self, colors: List[int]) -> int:
count = 0
# check the end colors
if len(colors) > 2:
if colors[0] != colors[1] and colors[1] == colors[-1]:
count += 1
if colors[-2] != colors[-1] and colors[-2] == colors[0]:
count += 1

l, r = 0, 0
k = 3
for r in range(len(colors)):
if r - l + 1 == 3:
l += 1
if r < len(colors) - 1 and colors[l] == colors[r+1] and colors[l] != colors[r]:
count += 1

return count


๐Ÿ“— A more optimized version
class Solution:
def numberOfAlternatingGroups(self, colors: List[int]) -> int:
n = len(colors) # keep the orginal length for latter
count = 0

# extend the colors array to simulate a circular pattern
colors.extend(colors[:2])

for r in range(n):
if colors[r] == colors[r+2] and colors[r] != colors[r+1]:
count += 1

return count



๐ŸŸก 3208. Alternating Groups II ~ 1800 ( Hard medium )
๐Ÿ”— Link: Click here!

python 
class Solution:
def numberOfAlternatingGroups(self, colors: List[int], k: int) -> int:
count = 0

colors.extend(colors[:k-1]) # if k = 3 we add 2 numbers like the above question
print(colors)

L = 0
for R in range(1, len(colors)):

if colors[R] == colors[R-1]:
L = R
if R - L + 1 == k:
count += 1
L += 1

return count



๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ’ป A2SV prep: Sliding window problem

๐ŸŸก 3191. Minimum Operations to Make Binary Array Elements Equal to One I
๐Ÿ”— Link: Click here

class Solution:
def minOperations(self, nums: List[int]) -> int:
n = len(nums)
count = L =0
for R in range(n - 2):
if nums[R] == 0:
nums[R] = 1 - nums[R]
nums[R + 1] = 1 - nums[R + 1]
nums[R + 2] = 1 - nums[R + 2]
count += 1

if nums[L] == 1: L+= 1

for i in range(len(nums)):
if nums[i] == 0:
return -1
return count


๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ