uk
Feedback

Не попадись на ботовода! Telemetrio знаходить і позначає такі канали мітками 👉 Хочеш бачити мітку, оформляй підписку

Leetcode with dani

Leetcode with dani

Відкрити в Telegram

Join us and let's tackle leet code questions together: improve your problem-solving skills Preparing for coding interviews learning new algorithms and data structures connect with other coding enthusiasts

Показати більше
1 240
Підписники
-124 години
-37 днів
-1730 днів
Архів дописів
What will be the output of the following Python Code? >>> a = 12 print(a in [x for x in range(12)]) Choose the correct option:-
Anonymous voting
29 лип 2024, 08:32

29 лип 2024, 04:34

#leet_code_Q15 #Q_209 #Medium #Sliding_window 209. Minimum Size Subarray Sum Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead. Example 1: Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: The subarray [4,3] has the minimal length under the problem constraint. Example 2: Input: target = 4, nums = [1,4,4] Output: 1 Example 3: Input: target = 11, nums = [1,1,1,1,1,1,1,1] Output: 0 Constraints: 1 <= target <= 109 1 <= nums.length <= 105 1 <= nums[i] <= 104 Follow up: If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log(n)).
29 лип 2024, 04:32

#leet_code_Q_14 #Q_2269 #easy #Sliding_window 2269. Find the K-Beauty of a Number The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions: It has a length of k. It is a divisor of num. Given integers num and k, return the k-beauty of num. Note: Leading zeros are allowed. 0 is not a divisor of any value. A substring is a contiguous sequence of characters in a string. Example 1: Input: num = 240, k = 2 Output: 2 Explanation: The following are the substrings of num of length k: - "24" from "240": 24 is a divisor of 240. - "40" from "240": 40 is a divisor of 240. Therefore, the k-beauty is 2. Constraints: 1 <= num <= 109 1 <= k <= num.length (taking num as a string)
27 лип 2024, 16:43

## Intuition To solve this problem, we can use a sliding window approach along with a hash map (dictionary) to efficiently check for duplicate elements within a given range. The idea is to maintain a window of size k and check if any element within this window is duplicated. ## Algorithm 1. Initialize an empty hash map (dictionary) to store the most recent index of each element. 2. Iterate over the array nums: - For each element nums[i]: - If nums[i] is already in the hash map and the difference between the current index i and the stored index j is less than or equal to k, return true. - Update the hash map to store the current index i of nums[i]. 3. If no duplicates within the range k are found, return false. ## Code
def containsNearbyDuplicate(nums, k):
    num_indices = {}
    
    for i, num in enumerate(nums):
        if num in num_indices and i - num_indices[num] <= k:
            return True
        num_indices[num] = i
    
    return False

# Example 1
print(containsNearbyDuplicate([1, 2, 3, 1], 3))  # Output: True

# Example 2
print(containsNearbyDuplicate([1, 0, 1, 1], 1))  # Output: True

# Example 3
print(containsNearbyDuplicate([1, 2, 3, 1, 2, 3], 2))  # Output: False
## Complexity Analysis - Time Complexity: O(n), where n is the length of the array nums. We only need to iterate through the array once. - Space Complexity: O(min(n, k)), where n is the length of the array. The space used by the hash map is proportional to the number of unique elements within any window of size k. In the worst case, this is O(n), but usually, it's limited by k. This algorithm ensures that we efficiently find any duplicates within a specified range, making use of the hash map for quick lookups and updates.
26 лип 2024, 16:46

Websites To Increase Your Problem-Solving Skills LeetCode: LeetCode is widely used for practicing coding problems, especially for preparing for technical interviews. It has a vast collection of problems categorized by difficulty and topic. HackerRank: HackerRank offers challenges in various domains like algorithms, data structures, artificial intelligence, and more. It is also a good platform for preparing for coding interviews. CodeSignal: CodeSignal provides a variety of coding challenges and also has a feature to simulate technical interviews. Codeforces: Codeforces is a competitive programming platform that hosts regular contests. It’s a great place to practice algorithmic problems and improve your speed and accuracy. AtCoder: AtCoder is a Japanese competitive programming site that offers regular contests and a rich set of problems to solve. TopCoder: TopCoder is one of the original competitive programming platforms. It offers Single Round Matches (SRMs) and has a large problem archive. Exercism: Exercism offers exercises in various programming languages with mentor feedback. Codewars: Codewars provides a community-driven platform where you can solve coding challenges and compare solutions with others.
26 лип 2024, 16:45

## Intuition To solve this problem, we can use a sliding window approach along with a hash map (dictionary) to efficiently check for duplicate elements within a given range. The idea is to maintain a window of size k and check if any element within this window is duplicated. ## Algorithm 1. Initialize an empty hash map (dictionary) to store the most recent index of each element. 2. Iterate over the array nums: - For each element nums[i]: - If nums[i] is already in the hash map and the difference between the current index i and the stored index j is less than or equal to k, return true. - Update the hash map to store the current index i of nums[i]. 3. If no duplicates within the range k are found, return false. ## Code
def containsNearbyDuplicate(nums, k):
    num_indices = {}
    
    for i, num in enumerate(nums):
        if num in num_indices and i - num_indices[num] <= k:
            return True
        num_indices[num] = i
    
    return False

# Example 1
print(containsNearbyDuplicate([1, 2, 3, 1], 3))  # Output: True

# Example 2
print(containsNearbyDuplicate([1, 0, 1, 1], 1))  # Output: True

# Example 3
print(containsNearbyDuplicate([1, 2, 3, 1, 2, 3], 2))  # Output: False
## Complexity Analysis - Time Complexity: O(n), where n is the length of the array nums. We only need to iterate through the array once. - Space Complexity: O(min(n, k)), where n is the length of the array. The space used by the hash map is proportional to the number of unique elements within any window of size k. In the worst case, this is O(n), but usually, it's limited by k. This algorithm ensures that we efficiently find any duplicates within a specified range, making use of the hash map for quick lookups and updates.
26 лип 2024, 16:45
26 лип 2024, ~16:46

26 лип 2024, 06:29

«የኢትዮጵያ መንግስት ከተባበሩት አረብ ኢምሬት ጋር በመተባበር በቀጣይ 3 አመታት 5ሚሊየን ፕሮግራመሮችን ለማፍራት እቅድ ይዘዋል። ይህ ስልጠና ሲጠናቀቅ አለም አቀፍ ተቀባይነት ያለው ሰርተፍኬት ያገኛሉ::ትምህርቱ የሚሰጠው በኦን ላይን ሲሆን ከርሰዎ የሚሰፈልገው ሞባይል ወይ ላበቶፕ እና ኢንተርኔት ብቻ ነው ::ትምህርቱን በኢንተርኔት ከቤተዎ ሁነው ይማራሉ:: የሚሰጡ ትምህርቶች:- 1. Android Kotlin Development Fundamentals 2. Data Science Fundamentals 3. Programming Fundamentals #Code_for_Change: Ethiopia's Path to Innovation and Growth!! የ5 ሚሊዮን የኢትዮጵያ ኮደርስ ኢኒሼቲቭ ይፋ መደረጉ የሚያስገኘውን ሁለንተናዊ ጥቅሞች በተወሰነ መልኩ በመጠቆም የዚህ እድል ተካፋይ እንሁን። 1. Enhanced Educational Opportunities: ይህ ኢኒሼቲቭ በሚሊዮን የሚቆጠሩ ኢትዮጵያውያን በተለይም ወጣቶች ለዘመናዊው ዲጂታል ኢኮኖሚ ወሳኝ ክህሎት እንዲያገኙ ይረዳል። 2. Economic Empowerment፡ በዘርፉ በቂ እውቀት የሚያገኙ ኢትዮጵያውያን ከፍተኛ ክፍያ በሚያስገኙ የቴክኖሎጂና የስራ ፈጠራ ስራዎችን በመጠቀም ገቢያቸውን ለማሳደግና አጠቃላይ ሀገራዊ የኢኮኖሚ እድገትን ለመጨመር ያግዛል። 3. Cultural Exchange and Knowledge Transfer: ከተባበሩት አረብ ኤሚሬቶች ጋር በሚደረገው ሁለንተናዊ ትብብር የባህል ልውውጥንና ምርጥ ተሞክሮዎችን በትምህርትና በቴክኖሎጂ ለመጋራት ያስችላል። 4. Technological Advancements፡ በቴክኖሎጂ የተካኑ በርካታ ግለሰቦችን በማልማት ውጥኑ በኢትዮጵያ ውስጥ ባሉ የተለያዩ ኢንዱስትሪዎች የቴክኖሎጂ ፈጠራን በማስፋፋት ምርታማነትን እና ቅልጥፍናን ያሳድጋል። 5. Job Creation and Workforce Development: ኢኒሼቲቩ በቴክኖሎጂ ዘርፍና በተዘዋዋሪ በተዛማጅ የስራ ዘርፎች የስራ እድል በመፍጠር የስራ አጥነትን ችግር ከማቃለል በተጓዳኝ የሰለጠነ የሰው ሃይል ለመገንባት ያስችላል። 6. Global Competitiveness: ኢትዮጵያ ጠንካራ የቴክኖሎጂ ተሰጥኦ ፑል በማዘጋጀት በአለም አቀፍ የቴክኖሎጂ መልከዓምድር ላይ ተወዳዳሪ ተጫዋች ሆና ዓለም አቀፍ ቢዝነሶችን እንዲሁም ኢንቨስትመንቶችን ለመሳብ ምቹ ሁኔታን ይፈጥራል። 7. Sustainable Development፡ በአጠቃላይ ይህንን ኢኒሼቲቭ ከዘላቂ የልማት ግቦች ጋር በማጣጣም ጥራት ያለው ትምህርትንና ጤናማ የስራ ባህልን በማስተዋወቅ ለኢትዮጵያ የረዥም ጊዜ ብልጽግናና መረጋጋት ከፍተኛ አስተዋጽኦ ያደርጋል። The launch of the 5 Million Ethiopian Coders Initiative, in partnership with the UAE, delivers these comprehensive benefits. Empowering Ethiopia’s Future by Cultivating 5 Million Coders. ለመመዝገብ ይህን ሊንክ ይጠቀሙ https://ethiocoders.et
25 лип 2024, 13:41
05 черв 2025, ~12:39

share your ideas
24 лип 2024, 16:00

I just watched an amazing video that dives into the theory of relativity and how time works. ⏳ It’s fascinating how scientists always talk about light, and I used to think they had a beef with speed of light 😂 But now I understand why light speed is so special and its profound connection to time. https://youtu.be/5BBHEZFearI?si=dGWI303LG9XXgQYh
24 лип 2024, 15:56

#leet_code_Q_13 #easy #Sliding_window #Q_219 219. Contains Duplicate II Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. Example 1: Input: nums = [1,2,3,1], k = 3 Output: true Example 2: Input: nums = [1,0,1,1], k = 1 Output: true Example 3: Input: nums = [1,2,3,1,2,3], k = 2 Output: false
24 лип 2024, 05:53

219. Contains Duplicate II Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. Example 1: Input: nums = [1,2,3,1], k = 3 Output: true Example 2: Input: nums = [1,0,1,1], k = 1 Output: true Example 3: Input: nums = [1,2,3,1,2,3], k = 2 Output: false
24 лип 2024, 05:51
24 лип 2024, ~05:51

i recommend this video for those who want to learn sliding window algorithm , we will be working on this algorithm in the coming days
24 лип 2024, 05:18

24 лип 2024, 05:13

What will be the output of the following code? print('Hello' * 3)
Anonymous voting
13 лип 2024, 06:51

How do you convert a tuple into a list in Python? a) tuple.toList() b) list(tuple) c) tuple.list()
12 лип 2024, 06:20

class Solution:
    def reverseString(self, s: List[str]) -> None:
    left, right = 0, len(s) - 1
    while left < right:
        s[left], s[right] = s[right], s[left]
        left += 1
        right -= 1
12 лип 2024, 06:14

Answer:
12 лип 2024, 06:11

⚡️DOGS NEW UPDATE#BITGET wallet እና #XT Exchange ላይ list ተደርጓል ✅ በቅርቡ ደግሞ 💰LBANK ላይ እና 📈BING X Exchange ላይ list እንደሚደረግ በ❌ ገ
⚡️DOGS NEW UPDATE#BITGET wallet እና #XT Exchange ላይ list ተደርጓል ✅ በቅርቡ ደግሞ 💰LBANK ላይ እና 📈BING X Exchange ላይ list እንደሚደረግ በ❌ ገፃቸው ላይ አስታውቀዋል ።🔥 🖥NO TAP TAP NO COMBO JUST START THE BOT 😐 🗣 💡 ነጥብ የምታገኙት ⚡️Telegram መጠቀም የጀመራችሁበትን ዓመት ባማከለ ነው።
11 лип 2024, 09:48
05 черв 2025, ~12:39