fa
Feedback

فریب کلاهبرداران را نخورید! تل‌متریو این کانال‌ها را شناسایی و برچسب‌گذاری می‌کند 👉 برای مشاهده برچسب، اشتراک تهیه کنید

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 روز
آرشیو پست ها
it is the first hard question to be solved by me 😁
+1
it is the first hard question to be solved by me 😁
22 مه 2024, 10:30

https://t.me/realyescoinbot?start=r_659354356 Telegram verified the coin so it may have some value like notcoin and it worth trying. just try
22 مه 2024, 04:55
03 ژوئن 2025, ~13:30

share ur ides on the comment section
22 مه 2024, 02:29

22 مه 2024, 02:27

9. Palindrom number #leet_code_Q4 #math #my_twopointer Given an integer x, return true if x is a palindrome , and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Example 3: Input: x = 10 Output: false Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
22 مه 2024, 02:22

photo content
22 مه 2024, 02:17

Answer:
 words = s.split()
  reversed_words = [word[::-1] for word in words] 
  return ' '.join(reversed_words)
22 مه 2024, 02:01

557. Reverse Words in a String III Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: s = "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Example 2: Input: s = "Mr Ding" Output: "rM gniD" #leet_code_Q3 #String
21 مه 2024, 08:32

Try this question on leet code Majority Element
21 مه 2024, 08:24

photo content
21 مه 2024, 08:14

so let's tackle this question. so how can we know the element is maority element ,if it is the most frequent element in the array yea . so we can calculate each element freaquency by creating a dictionary like this my_dicti = {} for i in nums: if nums[i] in my_dict: my_dict[i] +=1 else: my_dict[i] = 1 and we can print the find the maximum frequent number in the dictionary and return it but there is also another efficient method to do it by declearing two variabes one to contain the number and the second to cotain it's occurence like this
nums = [1,2,3,4,5,4,4,3]
contain = nums[0]
occurence = 0
for i in nums:
    if i == contain:
        occurence += 1
    else:
        if occurence == 0:
            contain = i
            occurence =1
        else:
            occurence -= 1
21 مه 2024, 08:06

so let's tackle this question. so how can we know the element is maority element ,if it is the most frequent element in the array yea . so we can calculate each element freaquency by creating a dictionary like this my_dicti = {} for i in nums: if nums[i] in my dict:
21 مه 2024, 07:21
21 مه 2024, ~07:21

give me your ideas about this question. how can we solve it???
20 مه 2024, 10:23

Repost from Leetcode with dani
it's good. we did better from 78 % of submitted code in python by running time
it's good. we did better from 78 % of submitted code in python by running time
20 مه 2024, 10:05

Let's tackle the question of finding the number that appears only once in a list. if you want to figure it out your self dont see the answer? We could iterate through the list, comparing each element to all others to count occurrences. This approach would work, but it has a time complexity of n^2, exceeding the given constraint of linear time (O(n)). Since the question guarantees that all other elements appear twice, we can exploit this property. Here's how: Convert the list to a set. Sets eliminate duplicates, leaving only the unique element. Calculate the sum of the elements in the original list and the set. Unique number = Sum of list elements - (2 * Sum of set elements) This method efficiently finds the unique element in linear time. There's an even better approach called the XOR method. If you'd like an explanation of how it works, I can provide the code and break it down for you class Solution: def singleNumber(self, nums: List[int]) -> int: result = 0 for i in nums: result^=i return result
20 مه 2024, 10:04

Let's tackle the question of finding the number that appears only once in a list. We could iterate through the list, comparing each element to all others to count occurrences. This approach would work, but it has a time complexity of n^2, exceeding the given constraint of linear time (O(n)). Since the question guarantees that all other elements appear twice, we can exploit this property. Here's how: Convert the list to a set. Sets eliminate duplicates, leaving only the unique element. Calculate the sum of the elements in the original list and the set. Unique number = Sum of list elements - (2 * Sum of set elements) This method efficiently finds the unique element in linear time. There's an even better approach called the XOR method. If you'd like an explanation of how it works, I can provide the code and break it down for you class Solution: def singleNumber(self, nums: List[int]) -> int: result = 0 for i in nums: result^=i return result
20 مه 2024, 10:02
20 مه 2024, ~10:03

Let's tackle the question of finding the number that appears only once in a list. We could iterate through the list, comparing each element to all others to count occurrences. This approach would work, but it has a time complexity of n^2, exceeding the given constraint of linear time (O(n)). Since the question guarantees that all other elements appear twice, we can exploit this property. Here's how:
Convert the list to a set. Sets eliminate duplicates, leaving only the unique element. Calculate the sum of the elements in the original list and the set. Unique number = Sum of list elements - (2 * Sum of set elements) This method efficiently finds the unique element in linear time. There's an even better approach called the XOR method. If you'd like an explanation of how it works, I can provide the code and break it down for you
class Solution:
    def singleNumber(self, nums: List[int]) -> int:
        result = 0 
        for i in nums:
            result^=i
        return result
20 مه 2024, 09:59
20 مه 2024, ~10:00

#leet_code_Q2 #Array Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Example 2: Input: nums = [2,2,1,1,1,2,2] Output: 2
20 مه 2024, 09:50

lets do another Question on Leet code
20 مه 2024, 09:50

Level Up Problem-Solving: LeetCode trains your brain to break down problems, a skill used by 80% of software engineers according to a [Payscale survey]( Indeed salary survey for Software Engineer).
20 مه 2024, 09:41