en
Feedback
Codative πŸ”­

Codative πŸ”­

Open in Telegram

Programmer | Orthodox Christian | Reader Resources: @codative_resources

Show more
1 303
Subscribers
No data24 hours
+17 days
+530 days
Posts Archive
48th ICPC World Finals was completed yesterday and Peking University got the first place. Here are the problems for this year. I went over them and there is like 1 question I've tried and barely solved, they are hard😰 https://scoreboard.icpc.global/2024/problemset.pdf

functools is crazy surprising me again with accumulate a function for calculating the prefix sum of an array

Why I am seeing airdrop story everywhere πŸ˜‚

Impresed by these when trying to apply for Internship at Netflix
Impresed by these when trying to apply for Internship at Netflix

Have You Ever Got Stuck Comparing Values in Python Sorting? Meet cmp_to_key! If you've been solving problems on LeetCode or coding challenges in general, you’ve probably faced a situation where you need custom sorting logicβ€”like sorting based on multiple conditions. This is where Python's cmp_to_key comes in, and it can save the day!What is cmp_to_key?Imagine you have a comparison function that says,
If this value is smaller than that, return -1; if they're equal, return 0; if it's bigger, return 1.
This is called a comparison function (cmp). But modern Python sorting methods like sorted() or .sort() use a key function instead.So how do you use your custom cmp function with sorted()? Simpleβ€”convert it using cmp_to_key! Example: Sorting Strings by Length, Then AlphabeticallyLet’s say you need to sort a list of words. First, by length. If two words have the same length, you sort them alphabetically. from functools import cmp_to_key def compare(a, b): if len(a) == len(b): return -1 if a < b else 1 # Compare alphabetically if lengths are equal return len(a) - len(b) # Compare by length words = ["apple", "bat", "banana", "pie", "cat"] sorted_words = sorted(words, key=cmp_to_key(compare)) print(sorted_words) # Output: ['bat', 'cat', 'pie', 'apple', 'banana'] Without cmp_to_key, writing such sorting logic can get messy. But here, you just write your comparison function, and cmp_to_key handles the rest.Example: Custom Sorting NumbersLet’s sort a list of numbers where we want even numbers first, sorted in descending order, and odd numbers second, sorted in ascending order. def custom_compare(a, b): if a % 2 == b % 2: # Both even or both odd return b - a if a % 2 == 0 else a - b # Descending for evens, ascending for odds return -1 if a % 2 == 0 else 1 # Even before odd numbers = [3, 1, 4, 10, 5, 6, 7] sorted_numbers = sorted(numbers, key=cmp_to_key(custom_compare)) print(sorted_numbers) # Output: [10, 6, 4, 1, 3, 5, 7] How Does It Work? If a should come before b, return -1.If a and b are equal, return 0.If a should come after b, return 1. #tips #leetcode #python @codative

Seems everyone is becoming student at A2SV 😁( from linkedin)

Ever missed contests on many platform and wondered how to get them. There is a good solution for me which gives you all of the upcoming and previous contests on every competitive programming platform. It is called CodeClock and it lets u add the contest that you want to your calendar and you will never miss any again

Hey people do you want to join developers community arround the world here is one on slack and it is all about go I will try to find others that are more general. Since these kind of networks are really crucial for your career as software developer I highly recommend you to really join them and I will send much more like this soon Gophers @codative

I was crazy and thinking to make a library that can make github as a storage for syncing user data πŸ˜„ what do you think?πŸ™„

Which one is better you think?
Anonymous voting

I was looking this week on the codenight forum go topic and there was a hot argument about using pure sql or using orm for handling models and database things what is your idea about this πŸ˜„

Check out these the best that I have found #system_design #resources @codative

+2
System_Design_Interview_–_An_insider's_guide,_Second_Edition_Alex.epub3.54 MB

Repost from TechαŠ’α‰΅
Practice system design problems like you practice DSA on Leetcode Found this awesome platform on Reddit for practicing system
Practice system design problems like you practice DSA on Leetcode Found this awesome platform on Reddit for practicing system design actively. Watching videos and reading books can get boring, but this site lets you dive right in. Give it a try! Here's the link. Source: Reddit @techinethio #foundthis #systemdesign

Anyone who knows a good resource for getting started with system design?

Forgot to say happy new year πŸ˜… In this year I have planned to make more engaging contents on the channel. We will have: - Live streams in different topics with special guests - Virtual Contests - Live Coding - Interesting Projects Wait for more share to your friends and get ready πŸ˜πŸ‘ @codative

Hearing about leetcode from the leetcode master (happy new year my friends πŸ˜„) https://youtu.be/h3nV3I9F2hA?si=5O8Tc4FAMxN7y4NY

Our one and Only Emre Varol