ch
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 天
帖子存档
አዳያመልጣችሁ አሪፍ ዕድል ነው
11 7月 2024, 09:42

https://t.me/dogshouse_bot/join?startapp=DH2e_MbjR62vRqA4noc4TQ Who let the DOGS out? ምንም ሳታደርጉት ቴሌግራም ስለተጠቀማችሁ ብቻ ነዉ የሚከፍለው ! የTelegram username መጀመሪያ ክፈቱ ከሌላችሁ
11 7月 2024, 09:41
05 6月 2025, ~12:39

#leet_code_Q_12 #easy #two_pointer #Q_202 202.Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits. Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy. Return true if n is a happy number, and false if not. Example 1: Input: n = 19 Output: true Explanation: 12 + 92 = 82 82 + 22 = 68 62 + 82 = 100 12 + 02 + 02 = 1 Example 2: Input: n = 2 Output: false Constraints: 1 <= n <= 231 - 1
10 7月 2024, 08:00

344. Reverse String #Topics #two pointers #strings Write a function that reverses a string. The input string is given as an array of characters s You must do this by modifying the input array in-place with O(1) extra memory Example 1: Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"] Example 2: Input: s = ["H","a","n","n","a","h"] Output: ["h","a","n","n","a","H"]
03 7月 2024, 08:48

based on this poll we will start doing two pointer and sliding window respectively
03 7月 2024, 08:46

hello there guys👐 I know I haven't been here, I was just in trouble lately.
03 7月 2024, 08:44
10 7月 2024, ~08:02

Don't try to answer at first glance. it's more challenging than it seems
13 6月 2024, 15:24

If a coin rolls around a circular path whose circumference is twice the circumference of the coin, how many full rotations does the coin complete by the time it returns to its starting point?
Anonymous voting
13 6月 2024, 15:21

You wiil get your refferal links by pressing on the button on the bot bottom right side it is already listed on binance use your chance
11 6月 2024, 09:16
03 7月 2024, ~08:45

Click the link above and click on the start button on the bot then click on join airdrop join the three telegram links and get back to the bot and click on the join air drop button again
11 6月 2024, 09:16
03 7月 2024, ~08:45

photo content
11 6月 2024, 09:08
03 7月 2024, ~08:45

I earned over $ 50 OI. Net from this Airdrop after I joined🎁 It will be listed on Binance on 11th June. Click the link below to join the Airdrop and claim your free IO Tokens into your wallet💯 https://t.me/Ionet_airdrop_bot?start=r0073312635 Join now and thank me later💪
11 6月 2024, 09:06
03 7月 2024, ~08:45

class Solution:
    def findMin(self, nums: List[int]) -> int:
        left = 0
        right = len(nums)-1
        while(left<=right):
            mid = (left+right)//2
            if nums[mid] <= nums[mid-1]:
                return nums[mid]
            elif nums[mid] >= nums[left] and nums[left] >nums[left-1]:
                left = mid + 1
            else:
                right = mid -1
09 6月 2024, 03:21

153. Find Minimum in Rotated Sorted Array #leet_code_Q10 #Medium #binary_search #Q_153 Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: [4,5,6,7,0,1,2] if it was rotated 4 times. [0,1,2,4,5,6,7] if it was rotated 7 times. Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]]. Given the sorted rotated array nums of unique elements, return the minimum element of this array. You must write an algorithm that runs in O(log n) time. Example 1: Input: nums = [3,4,5,1,2] Output: 1 Explanation: The original array was [1,2,3,4,5] rotated 3 times. Example 2: Input: nums = [4,5,6,7,0,1,2] Output: 0 Explanation: The original array was [0,1,2,4,5,6,7] and it was rotated 4 times. Example 3: Input: nums = [11,13,15,17] Output: 11 Explanation: The original array was [11,13,15,17] and it was rotated 4 times.
06 6月 2024, 11:41

Which topic should we cover next?
Anonymous voting
06 6月 2024, 11:36

In python, What does the join () method do ?
Anonymous voting
04 6月 2024, 15:15

Here is the Python implementation of the above approach:
class Solution:
    def mySqrt(self, x: int) -> int:
        if x < 2:
            return x
        
        left, right = 2, x // 2
        ans = 0
        
        while left <= right:
            mid = (left + right) // 2
            num = mid * mid
            
            if num > x:
                right = mid - 1
            else:
                ans = mid
                left = mid + 1
        
        return ans
### Complexity Analysis Time complexity: O(log x) - This is due to the binary search algorithm, which cuts the search space in half with each iteration. Space complexity: O(1) - We are using a constant amount of space regardless of the input size. Only a few integer variables are used. This solution efficiently finds the square root of a non-negative integer x rounded down to the nearest integer using binary search.
04 6月 2024, 10:38

Here is the Python implementation of the above approach:
```python class Solution: def mySqrt(self, x: int) -> int: if x < 2: return x left, right = 2, x // 2 ans = 0 while left <= right: mid = (left + right) // 2 num = mid * mid if num > x: right = mid - 1 else: ans = mid left = mid + 1 return ans ```
### Complexity Analysis Time complexity: O(log x) - This is due to the binary search algorithm, which cuts the search space in half with each iteration. Space complexity: O(1) - We are using a constant amount of space regardless of the input size. Only a few integer variables are used. This solution efficiently finds the square root of a non-negative integer x rounded down to the nearest integer using binary search.
04 6月 2024, 10:37
04 6月 2024, ~10:57

👋 Hey Everyone, here's the solution to yesterday's question. 69. Sqrt(x) Overview Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. Approach: Binary Search Intuition To find the integer square root of a number x efficiently, we can use the binary search algorithm. The idea is to narrow down the range [0, x] by comparing the mid-point's square with x. This helps us zero in on the integer part of the square root without having to check every number. Binary search is efficient because it repeatedly divides the search interval in half, making it a logarithmic time complexity algorithm. Algorithm 1. If x is less than 2, return x because the square root of 0 is 0, and the square root of 1 is 1. 2. Initialize two pointers, left and right, to 2 and x // 2, respectively. We start from 2 because any number less than 2 is already handled by the first step. 3. Perform a binary search: - Calculate the mid-point: mid = (left + right) // 2. - Compute the square of mid. - If mid^2 is greater than x, adjust the right pointer to mid - 1 to search the left half. - If mid^2 is less than or equal to x, adjust the left pointer to mid + 1 to search the right half. Also, update the variable ans to mid because mid might be the answer. 4. When the loop ends, ans will hold the largest integer whose square is less than or equal to x. 5. Return ans.
04 6月 2024, 10:35

jknkjn
Anonymous voting
03 6月 2024, 03:53
03 6月 2024, ~03:53