< 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
πŸ‘¨β€πŸ’» Here is a detail explanation for the above questionπŸ‘†
class Solution:
def maxCoins(self, piles: List[int]) -> int:
# first determine how many piles each person will get
piles_per_person = len(piles) // 3
# sort the piles in descending order
piles.sort(reverse=True)
# Hypothetically we want to give the least piles in the sorted pile for bob
# [9,8,7,6,5,4,3,2,1] 1, 2, 3 are given for bob
p = piles_per_person
score = piles[1:-p:2] # starting from the second value and increment by 2 until we reach len(piles) - piles_per_person
return sum(score)


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

https://leetcode.com/problems/maximum-number-of-coins-you-can-get/
πŸ“’ A2SV past years interview questions πŸ“


©️Ethio Toolkit
You have some apples and a basket that can carry up to 5000 units of weight. Given an integer array weight where weight[i] is the weight of the ith apple, 

return the maximum number of apples you can put in the basket.

Example 1:

Input: weight = [100,200,150,1000]

Output: 4

Explanation: All 4 apples can be carried by the basket since their sum of weights is 1450.

Example 2:

Input: weight = [900,950,800,1000,700,800]

Output: 5


Constraints:

1 <= weight.length <= 1000

1 <= weight[i] <= 1000

This problem is lighter version of a classic interview question: "1561. Maximum Number of Coins You Can Get" πŸ’°which we have solved on Ace Coding.

βœ… Solution: ©️Ace Coding
def maxNumberOfApples(weight):
weight.sort()
total_weight = 0
count = 0

for w in weight:
if total_weight + w <= 5000:
total_weight += w
count += 1
else:

return count


πŸš€ @AceCoding Presents! πŸš€πŸŒŸ
πŸ‘1
πŸ”” Quick Reminder!

If you found this problem helpful, make sure to share it with your friends. Remember the saying:
If you want to go fast, go alone. If you want to go far, go together. πŸ’ͺ


Let’s solve these challenges together and grow as a community! πŸš€

πŸŒŸπŸš€ @AceCoding Presents! πŸš€πŸŒŸ
🀝4
πŸ”₯ High ROI (Return on Investment) LeetCode Questions! πŸ’°πŸ’‘

πŸŒŸπŸš€ @AceCoding Presents! πŸš€πŸŒŸ
βœ… A2SV G5 Camp Topics

πŸŒŸπŸš€ @AceCoding Presents! πŸš€πŸŒŸ
🟑 189. Rotate Array

class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
rotation_point = k % len(nums)
k = rotation_point
if k != 0:
nums[:k], nums[k : ] = nums[-k : ], nums[:-k]
# the rotation_point should be counted for the end of nums
# Ex. [1, 2, 3, 4, 5, 6, 7] nums[:k] = [1, 2, 3]
# But nums[:-k] = [1, 2, 3, 4] which is correct
# nums[-k:] = [5, 6, 7]


class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
k = k % len(nums)

def reverse(left, right):
while left < right:
nums[left], nums[right] = nums[right], nums[left]
right -= 1
left += 1

reverse(0, len(nums)-1)
reverse(0, k-1)
reverse(k, len(nums)-1)



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

https://leetcode.com/problems/rotate-array/description/
πŸš€ Heads up, everyone! πŸš€

The questions we share here will likely appear in the A2SV technical interviews. Keep an eye on them and practice regularly to boost your preparation! πŸ’ͺπŸ”

Happy CodingπŸ’»

Stay tuned and don't miss out on these key problems. 🧠✨
πŸ‘1
πŸ“£ Update Alert: Info Session RSVP & Location Details!


πŸš€ Great News! We’ve expanded the RSVP tickets to accommodate more attendees! If you haven’t RSVP’d yet, now’s your chance to grab a spot and join the action.

πŸ‘‰ RSVP Now to secure your spot : GDG AASTU x AASTU SEA INFO SESSION 😎

πŸ“ Location Reminder: The Info Session will take place at AASTU Old Graduation Hall.

πŸ“Ž Study Session Registration:

Interested in the upcoming student study session? Registration will be open at the venue during the event. Be sure to attend to secure your spot!

Spread the word, and we can’t wait to see you on 20 November 2024! Let’s make this event unforgettable. ✨
πŸš€ Join Us for the INFO SESSION by AASTUSEA! πŸš€

Ready to dive into tech? Whether you're brand new, dreaming of becoming a developer, or already coding away, this event is for YOU! No experience neededβ€”just bring your passion and excitement!

✨ What's in Store?

πŸ’« Connect with Google Developer Groups (GDG) and AASTUSEA

πŸ’« Learn about plans and opportunities provided by the Association.

πŸ’« Secure your spot in our project preregistration.

πŸ’«  Get the Details needed to ace Huawei ICT Competition 2024-25, Join Huawei ICT Academy and Get FREE certifications.

πŸ’«Learn the basics, get inspired, and kickstart your coding journey

πŸ’«Network with fellow tech enthusiasts and mentors

πŸ“… Date: November 20, 2024 
πŸ•— Time: 8:30 - 11:00 LT 
πŸ“ Location: Old Graduation Hall

πŸ‘‰πŸ‘‰ RSVP Here  πŸ‘ˆπŸ‘ˆ

Don't miss this great opportunity to connect and collab with like-minded once!

@AASTUSEA aastu.software
πŸ‘5
πŸš€ Part 2 Quiz: Computer Organization and Architecture πŸ–₯

We’re back with another round of quiz questions on Computer Organization and Architecture! 🧠

πŸŒŸπŸš€ @AceCoding Presents! πŸš€πŸŒŸ
πŸ”₯1
Which part of a computer system is primarily concerned with the implementation of the instruction set?
Anonymous Quiz
18%
Operating System
41%
Computer Architecture
41%
Computer Organization
0%
Compiler
Which of the following is NOT a component of computer organization?
Anonymous Quiz
6%
ALU (Arithmetic Logic Unit)
22%
Bus system
17%
Cache memory
56%
Instruction set design
The ____________ specifies the logical layout of the computer and defines how software interacts with the hardware.
Anonymous Quiz
44%
Instruction Set Architecture (ISA)
19%
Control Unit
6%
CPU Registers
31%
Bus System
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