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?
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
< Ace Coding /> ๐
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?
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?
โ
Solution
๐ป Try to do it by yourself before you check the solutions.
๐ป Try to do it by yourself before you check the solutions.
๐ Two Pointers Problems upcoming! ๐งโ๐ปโก๏ธ๐จโ๐ป
โ A2SV Prep ๐ป
๐๐ @AceCoding Presents! ๐๐
โ 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
๐ 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
๐ Problem link : https://leetcode.com/problems/watering-plants-ii/description/
โ 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/
LeetCode
Watering Plants - LeetCode
Can you solve this real interview question? Watering Plants - You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. Thereโฆ
๐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
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
A2SV | Africa to Silicon Valley
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:โฆ
๐จ Last call the deadline is today
exam questions.pdf
6.5 KB
โ
AASTU 2023 GC COA MID EXAM
Computer organization and architecture Mid exam with correct answers
๐๐ @AceCoding Presents! ๐๐
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?
๐งโ๐ 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!
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
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.
https://leetcode.com/problems/maximize-the-confusion-of-an-exam/description/
๐ก 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/
LeetCode
Maximize the Confusion of an Exam - LeetCode
Can you solve this real interview question? Maximize the Confusion of an Exam - A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutiveโฆ
๐ฃ 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!๐งจ๐
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 ๐
๐๐ @AceCoding Presents! ๐๐
https://leetcode.com/problems/max-consecutive-ones-iii/description/
๐ป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/
LeetCode
Max Consecutive Ones III - LeetCode
Can you solve this real interview question? Max Consecutive Ones III - Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.
Example 1:
Input: nums = [1,1,1,0,0,0,1,1,1,1โฆ
Example 1:
Input: nums = [1,1,1,0,0,0,1,1,1,1โฆ
< Ace Coding /> ๐
โ
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: โฆ
๐จโ๐ป PROGRESS โ๏ธ
๐4
๐ก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! ๐๐
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!
๐ A more optimized version
๐ก 3208. Alternating Groups II ~ 1800 ( Hard medium )
๐ Link: Click here!
๐๐ @AceCoding Presents! ๐๐
โ 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! ๐๐
LeetCode
Alternating Groups I - LeetCode
Can you solve this real interview question? Alternating Groups I - There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]:
* colors[i] == 0 means that tile i is red.
* colors[i]โฆ
* colors[i] == 0 means that tile i is red.
* colors[i]โฆ
๐ป A2SV prep: Sliding window problem
๐ก 3191. Minimum Operations to Make Binary Array Elements Equal to One I
๐ Link: Click here
๐๐ @AceCoding Presents! ๐๐
๐ก 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! ๐๐
LeetCode
Minimum Operations to Make Binary Array Elements Equal to One I - LeetCode
Can you solve this real interview question? Minimum Operations to Make Binary Array Elements Equal to One I - You are given a binary array nums.
You can do the following operation on the array any number of times (possibly zero):
* Choose any 3 consecutiveโฆ
You can do the following operation on the array any number of times (possibly zero):
* Choose any 3 consecutiveโฆ
๐ฅ Gear Up for Java Exam! QUIZ Time ๐ฅ
Get ready for a detailed and comprehensive Java prep with tricky questions.
๐ก Donโt miss outโshare with friends and tackle it together! ๐
#javaexam #oopexam #oopquiz #javaquiz #oopmidexam #javamidexam
๐๐ @AceCoding Presents! ๐๐
Get ready for a detailed and comprehensive Java prep with tricky questions.
๐ก Donโt miss outโshare with friends and tackle it together! ๐
#javaexam #oopexam #oopquiz #javaquiz #oopmidexam #javamidexam
๐๐ @AceCoding Presents! ๐๐