codepedia
الذهاب إلى القناة على Telegram
💞 هدف این کانال آموزش رایگان برنامه نویسی💥 ↩️دوره های موجود رو از دست ندید😍 ❌اینجامنبع کتاب های برنامهنویسی نامبروانههه🥳
إظهار المزيد5 243
المشتركون
+124 ساعات
-67 أيام
-4330 أيام
أرشيف المشاركات
5 242
حل سوالات استخدامی سایت leetcode.com
Task: No. 17. Letter Combinations of a Phone Number #medium
Condition:
Given a string containing the numbers 2 to 9 inclusive, return all possible combinations of letters that the number can represent. Return the answer in any order. The correspondence between numbers and letters (as on telephone buttons) is given below. Note that 1 does not match any letters.
Solution:
class Solution(object):
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
res = []
nums.sort()
self.dfs(nums, [], res)
return res
def dfs(self, nums, path, res):
res.append(path)
for i in range(len(nums)):
if i > 0 and nums[i] == nums[i-1]:
continue
self.dfs(nums[i+1:], path + [nums[i]], res)
Explanation:
Sorting:
First we sort the nums array. Sorting makes it easy to handle duplicates because similar items will be placed next to each other.
Recursive dfs method:
The dfs method is used to recursively construct all possible subsets. In dfs, path represents the current subset, and res is a list of all subsets.
Adding a subset to the result:
At each level of recursion, we add the current subset of path to the result of res.
Handling duplicates:
Before continuing the recursion, we check whether the current element nums[i] is a duplicate of the previous element. If so, skip it to avoid adding identical subsets to res.
Recursive construction of subsets:
For each element in nums, starting at the current index, we call dfs on the next elements of the array (nums[i+1:]). This means that we consider subsets that include the current element, and continue to build subsets without the current element.
Path (path) and compartment (nums):
Each time dfs is called, a new subset is created by adding the current element to path. This new list is then passed to the next level of recursion, allowing all possible subsets to be constructed.
Time and space complexity:
Time complexity: O(2^n), where n is the number of elements in nums. This is because there are 2^n subsets for an array of n elements.
Space complexity: O(2^n * n), since each of the 2^n possible subsets may require up to n elements to store.
#interview #LeetCode
30 يونيو 2024, 06:40
30 يونيو 2024, ~06:40
5 242
Repost from پایتون | Data Science | Machine Learning
حل سوالات استخدامی سایت leetcode.com
Task: No. 17. Letter Combinations of a Phone Number #medium
Condition:
Given a string containing the numbers 2 to 9 inclusive, return all possible combinations of letters that the number can represent. Return the answer in any order. The correspondence between numbers and letters (as on telephone buttons) is given below. Note that 1 does not match any letters.
Solution:
class Solution(object):
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
res = []
nums.sort()
self.dfs(nums, [], res)
return res
def dfs(self, nums, path, res):
res.append(path)
for i in range(len(nums)):
if i > 0 and nums[i] == nums[i-1]:
continue
self.dfs(nums[i+1:], path + [nums[i]], res)
Explanation:
Sorting:
First we sort the nums array. Sorting makes it easy to handle duplicates because similar items will be placed next to each other.
Recursive dfs method:
The dfs method is used to recursively construct all possible subsets. In dfs, path represents the current subset, and res is a list of all subsets.
Adding a subset to the result:
At each level of recursion, we add the current subset of path to the result of res.
Handling duplicates:
Before continuing the recursion, we check whether the current element nums[i] is a duplicate of the previous element. If so, skip it to avoid adding identical subsets to res.
Recursive construction of subsets:
For each element in nums, starting at the current index, we call dfs on the next elements of the array (nums[i+1:]). This means that we consider subsets that include the current element, and continue to build subsets without the current element.
Path (path) and compartment (nums):
Each time dfs is called, a new subset is created by adding the current element to path. This new list is then passed to the next level of recursion, allowing all possible subsets to be constructed.
Time and space complexity:
Time complexity: O(2^n), where n is the number of elements in nums. This is because there are 2^n subsets for an array of n elements.
Space complexity: O(2^n * n), since each of the 2^n possible subsets may require up to n elements to store.
#interview #LeetCode
🆔 @Python4all_pro30 يونيو 2024, 06:40
30 يونيو 2024, ~06:40
5 242
کدهای این بازی جذاب در گیت هاب قرار گرفت
روی لینک زیر بزنید و وارد گیست بشید.
برای دیدن راحت تر نتیجه میتونید از سایت کدپن استفاده کنید.
🆔@code_pedia | با کدپدیا همراه باشید
30 يونيو 2024, 02:52
5 242
👩💻دوره آموزش ویندوز CCNA
📝 جلسه :1
👩💻مدرس : ابراهیم اخزری
👩💻منبع : itshield
#ccna
#شبکه
#سیسکو
❌️روح پدرو فرزاندان استاد ابراهیم اخزری شاد🖤🖤
🆔 @code_pedia
29 يونيو 2024, 15:59
5 242
📸 چطور با هوش مصنوعی تصویرمون رو زنده کنیم؟!
⬅️اخیراً یک هوش مصنوعی به شدت خفنی معرفی شده که با گرفتن یک عکس و دو سه خط پرامپت از شما ، میتونه عکستون رو با جزئیات کامل متحرک کنه :)
⬅️وارد سایت زیر بشید و بعد از ثبت نام عکس خودتون رو آپلود کنید ؛ بعد از آپلود عکس یک متن چند خطی در مورد ویدیویی که میخواید ساخته بشرو بنویسید
+ اگه سایتش شلوغ نباشه همونجا بهتون ویدیو رو میده درغیر اینصورت یکم زمانمیبره!
🔗https://lumalabs.ai
🆔 @code_pedia
28 يونيو 2024, 12:53
5 242
یک قطعه زیبا از پاگانی نوازنده شیطان
اینکه چرا پاگانی نوازنده شیطان است داستان جالبی داره ولی فعلا فکر کنم منو تسخیر کرده شما فرار کنید
26 يونيو 2024, 09:49
5 242
مایکروسافت هیچ دیتاسنتر زیر آبی دیگری نخواهد داشت
پروژه دیتاسنترهای زیر آب مایکروسافت با نام Natick متوقف شد.
البته این شرکت اعلام کرده از چیزهایی که از این پروژه یاد گرفته قرار استفادههای دیگری بکنه.
@code_pedia | با کدپدیا همراه باشید
26 يونيو 2024, 07:10
5 242
Python Projects: Create an Interactive Quiz Application.zip293.51 MB
26 يونيو 2024, 06:05
5 242
✅این کانال های #یوتیوب از #دانشگاه بیشتر به دردت میخورن :
⏯️ Programming with Mosh:
✅#آموزش #برنامه_نویسی ساده و آسان .
2️⃣ Easy english:
✅یادگیری #مکالمه با شخصیت های کارتونی و تمرین دیالوگ ها با لهجه آمریکایی و تمرین مکالمه با اصطلاحات رایج آمریکایی.
3️⃣ Crash Course:
✅کوتاه و آسان به شما آموزش خواهد داد از #تاریخ و #اقتصاد گرفته تا علوم پایه .
4️⃣ English class101:
✅نکات تلفظ صحیح و عبارت های #کاربردی مکالمه انگلیسی و آموزش گرامر.
5️⃣ Tom bilyeu:
✅انگیزشی و سبک زندگی و #سخنرانی های تاثیر گذار بزرگان
🆔 @code_pedia
26 يونيو 2024, 02:42
5 242
✅ یه مشکلی که با height:100vh داریم اینه که توی موبایل اسکرول میخوره و تمام ارتفاع صفحه مرورگر همراه آدرس بار (نه فاصله از آدرس بار تا انتهای صفحه) ولی با این تکنیک میشه حلش کرد
🆔 @code_pedia
25 يونيو 2024, 06:16
5 242
چطور در بازی همستر کمبت به یک میلیون پروفیت برسیم؟
خب دیدم بازار همستر داغه گفتم یه الگوریتم بهینه بهتون بدم که بتونید با آپدیت کردن کارتها به یک میلیون پروفیت برسید.
به خیلی دوستان هم گفتم به چشم یه بازی بهش نگاه کنید. و از بازی لذت ببرید.
@code_pedia | با کدپدیا همراه باشید
#همستر #همستر_کمبت #ایردراپ #پروفیت
25 يونيو 2024, 03:11
5 242
Krishtop_A_Getting_Started_with_Forex_Trading_Using_Python_2023.epub7.72 MB
24 يونيو 2024, 17:19
5 242
🔹 #گوگل از قابلیتهای هوش مصنوعی #جمینای برای دانشآموزان رونمایی کرد
🔸گوگل در کنفرانس ISTE 2024 از جدیدترین قابلیتهای جمینای برای دانشآموزان مدارس و یک ویژگی جدید برای کروم پرده برداشت. چتبات هوش مصنوعی این شرکت قرار است در ماههای آینده با پشتیبانی از حسابهای آموزشی در دسترس قرار بگیرد. این چتبات در بیش از ۱۰۰ کشور به زبان انگلیسی عرضه خواهد شد.
🔸گوگل همین حالا هم به نوجوانان اجازه میدهد با حسابهای کاربری شخصی از جمینای استفاده کنند اما اکنون امکان استفاده از این چتبات هوش مصنوعی با حسابهای آموزشی فراهم میشود.
@code_pedia | با کدپدیا همراه باشید
24 يونيو 2024, 16:06
