< 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
๐Ÿ’ป A2SV prep: Two pointers

๐ŸŸข Two sum
๐ŸŸก Two sum ll input array is sorted

๐Ÿ‘†The above two are easy; warm up

๐ŸŸก 3sum Click here

Solution:
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
res = []
nums.sort()
n = len(nums)
for i in range(n-2):
if nums[i] > 0:
break
if i > 0 and nums[i] == nums[i-1]:
continue

L, R = i + 1, n - 1
while L < R:
sum = nums[i] + nums[L] + nums[R]
if sum == 0:
res.append([nums[i], nums[L], nums[R]])
L +=1
R -=1
while L < R and nums[L] == nums[L-1]:
L += 1
while L < R and nums[R] == nums[R+1]:
R -= 1

elif sum > 0:
R -= 1
else:
L += 1

return res



๐ŸŸก 3sum closest :- click here

Solution:
python 
class Solution:
def threeSumClosest(self, nums: List[int], target: int) -> int:
nums.sort()
res = sum(nums[:3])
for i in range(len(nums)):
L, R = i+1, len(nums)-1

while L < R:
closest = nums[i] + nums[L] + nums[R]
if abs(target - closest) < abs(target - res):
res = closest

if closest > target:
R -= 1
elif closest < target:
L += 1
else:
return closest

return res



๐ŸŸก 4Sum :- click here

Solution:
class Solution:
def fourSum(self, nums: List[int], target: int) -> List[List[int]]:
nums.sort()
n = len(nums)
res = []

for i in range(n-3):
if i > 0 and nums[i] == nums[i-1]:
continue

for j in range(i+1, n-2):
if j > i+1 and nums[j] == nums[j-1]:
continue

L, R = j + 1, n - 1
while L < R:
four_sum = nums[i] + nums[j] + nums[L] + nums[R]
if four_sum == target:
res.append([nums[i], nums[j], nums[L], nums[R]])

L += 1
R -= 1
while L < R and nums[L] == nums[L-1]:
L += 1
while L < R and nums[R] == nums[R+1]:
R -= 1

elif four_sum > target:
R -= 1
else:
L += 1

return res



๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ‘2
โœ… 100% Yesified ๐Ÿ˜‚

Theory vs Practice

@AceCoding
๐Ÿ˜4
๐Ÿ’ก Which side are you rocking, Theory or Practice. [Right or Left]
Anonymous Poll
18%
๐Ÿ“š Theory Master ๐Ÿ“–
50%
๐Ÿ›  Practice Pro ๐Ÿ’ป
32%
๐Ÿ”ฅ Both Boss ๐Ÿ’ช๐Ÿฆพ
Forwarded from A2SV - Community
๐Ÿšจ A2SV G6 Remote Education Recruitment Update ๐Ÿšจ

Itโ€™s been an incredible journey since we began interviewing candidates for G6 Remote Education. After posting the application form, we were overwhelmed by the sheer number of applications! ๐ŸŽ‰

Weโ€™re committed to reviewing every application fairly. Due to limited interview slots, only applicants with the highest grades will proceed to the interview stage, and invitations will be sent out soon.

For those who have already completed their interviews, your interviews are being graded. The final results for all applicants will be released in three weeks, once the entire process is concluded.

Thank you for your patience and the effort youโ€™ve put into this journey. ๐Ÿ™Œ

#A2SV #RemoteEducation #RecruitmentUpdate
๐Ÿ’ป A2SV prep: Two pointers

๐ŸŸข 1995. Count Special Quadruplets

Solution: This is a good example of questions with a small amount of input, or constraints that can be solved using a simple brute force.

class Solution:
def countQuadruplets(self, nums: List[int]) -> List[List[int]]:
res = 0
n = len(nums)
for i in range(n-3):
for j in range(i+1, n-2):
for k in range(j +1, n-1):
for l in range(k +1,n):
if nums[i] + nums[k] + nums[j] - nums[l] == 0:
res += 1
return res


๐ŸŸก 454. 4Sum II

Intuition : from the first two arrays find the count of sum of paris in nums1 and nums2 next get the compliment from the last two arrays nums3 and nums4

class Solution:
def fourSumCount(self, nums1: List[int], nums2: List[int], nums3: List[int], nums4: List[int]) -> int:
sum_count = Counter(a + b for a in nums1 for b in nums2)
count = 0
for c in nums3:
for d in nums4:
complement = -(c + d)
count += sum_count.get(complement, 0)

return count


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

๐ŸŸก 1248. Count Number of Nice Subarrays

Intuition: we want to find the count of the subarrays with exactly k odd numbers so our window should have exactly k odd numbers. To get the exact count we can just count the number of sub arrays with at most k odd numbers and subtract the count of sub arrays with at most k - 1 odd numbers which will give us the count of substrings with exact k odd numbers in it.

class Solution:
def numberOfSubarrays(self, nums: List[int], k: int) -> int:
def atMost(k):
count = 0
L, R = 0, 0
for R in range(len(nums)):
if nums[R] % 2 != 0:
k -= 1
while k < 0:
if nums[L] % 2 != 0:
k += 1
L += 1
count += R - L + 1
return count

return atMost(k) - atMost(k-1)


๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ”ฅ This 3D website is crazy. check it out.

โš’๏ธBuilt with React.js and Three.js

๐Ÿ‘‰ https://bfcm.shopify.com

@AceCoding
๐Ÿ”ฅ5
๐Ÿ’ป A2SV prep: Sliding window problem

๐ŸŸก 3. Longest Substring Without Repeating Characters


class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
maxlen = 0
L = R = 0
hashset = set()
while R < len(s):
if s[R] in hashset:
maxlen = max(maxlen, R - L) # maxlen = max(maxlen, len(hashset))
while s[L] != s[R]:
hashset.remove(s[L])
L += 1
L += 1

hashset.add(s[R])
R += 1
maxlen = max(maxlen, R - L)

return maxlen


๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿšจ Exciting News Alert! ๐Ÿšจ

๐ŸŽ‰ The list of Evangadi Fullstack MERN Stack Scholarship Winners for the December 2024 Batch is out! ๐ŸŽ“โœจ


๐ŸŽ‰ Big Congrats to the December 2024 Scholarship Winners! ๐ŸŽ‰

๐ŸŒŸ 60 incredible talents from Ethiopia have been awarded this golden opportunity to dive into the tech world and build a brighter future! ๐Ÿ’ป๐Ÿš€

๐Ÿ‘‘ Winners: Congratulations on this amazing milestone! Celebrate your hard work and dedication. ๐ŸŽŠ๐Ÿ‘


๐Ÿ’Œ Donโ€™t keep it to yourself! Share this announcement with your friends and familyโ€”let them celebrate with you and get inspired! ๐ŸŽ‰โœจ

#EvangadiTech #ScholarshipWinners #FutureInTech

Join ๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡

๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐ŸŽ‰5๐Ÿ‘1
Forwarded from A2SV - Community
๐Ÿ“ข Announcement: A2SV G6 In-Person Application Update

Dear Applicants,

Thank you for submitting your applications for the A2SV G6 recruitment process. After carefully reviewing all submissions, we are excited to announce that the shortlist of candidates selected for interviews will be shared very soon! ๐ŸŽ‰ Please check your emails regularly for updates. ๐Ÿ“ง

Starting Monday, shortlisted candidates will be able to schedule their technical interviews. ๐Ÿ“…

We highly recommend that you begin preparing for the technical interview to ensure your success. ๐Ÿš€ The key topics to focus on include:
- Sorting
- Two Pointers
- Prefix Sum
- Sliding Window
- Stack & Queues

Best of luck to all applicants, and we look forward to meeting you during the interview process! ๐Ÿ’ช

Sincerely,
The A2SV Team