LeetCode Weekly Contest 450 | Complete Solutions FREE! 🚀🎯

 🔴 LIVE | LeetCode Weekly Contest 450 | Complete Solutions FREE! 🚀🎯


Contest Details:

  • 📅 Date: Sunday, 18 May, 2025

  • 🕗 Time: 08:00 AM IST (GMT +5:30)

Myntra is Hiring Software Development Intern - Batch of 2026 - Open Campus- Apply Now



👇Scroll down to get all solutions!👇



🚨 Note: The Code of Conduct has been updated — make sure to follow the latest rules!!



#Promotion

🚀 Grow Your Instagram Fast – Get Real Followers, Likes & Views Starting at Just ₹5!

😎 DEMO FOR ALL SERVICES AVAILABLE – START NOW


Place Your First Order & Watch the Magic Begin in Just 5–10 Minutes!
✔ Instant Delivery | ✔ 100% Money-Back Guarantee


⚡ DEMO SERVICES ⚡
1️⃣ 500 Followers – Just ₹80 🤑
2️⃣ 500 Likes – Only ₹5 😊
3️⃣ 1K Reels Views – Just ₹5 😍



🦋 CHEAPEST GUARANTEED INSTAGRAM FOLLOWERS

🚀 Starts in 5–10 Mins | ✅ Complete in 30 Mins 

✅ 1K – ₹150 
✅ 2K – ₹300 
✅ 3K – ₹450 
✅ 5K +1K FREE – ₹650 (900❌) 
✅10K +1K FREE – ₹1300 (1800❌)

 ✔ No Drops | ✔ Real Followers | ✔ Trusted Quality


No Drops | ✅ Real Followers | ✅ Trusted Quality

INSTAGRAM GUARANTEED LIKES

🚀 Starts in 1–5 Mins | ✅ Complete in 5 Mins

✅ 1K – ₹10 
✅ 5K – ₹40 (50❌) 
✅ 10K – ₹80 (100❌) 
✅ 20K+2K – ₹160 (220❌) 
✅ 30K+3K – ₹250 (330❌) 
✅ 40K+4K – ₹340 (440❌) 
✅ 50K+10K – ₹450 (600❌)


🎥 INSTAGRAM REELS VIEWS

🚀 Starts in 1–3 Mins | ✅ Complete in 5 Mins 

✅ 1K – ₹5 
✅ 5K+1K – ₹20 (30❌) 
✅ 10K+2K – ₹30 (60❌) 
✅ 20K+4K – ₹60 (120❌) 
✅ 50K+5K – ₹180 (280❌) 
✅ 100K+10K – ₹300 (500❌) 
✅ 500K+10K – ₹600 (1500❌) 

📲 CONTACT NOW TO PLACE YOUR 1ST ORDER

Order Now on Whatsapp : Contact On WhatsApp 

Service Proof : Instagram Id

✨ Be Viral. Be Famous. Be YOU – With the Power of Social Growth!


Please Subscribe Our YouTube Channel


🔥 Get All Contest Solutions!

Want access to all solutions from this contest? Just follow these simple steps:

✅ Step 1: Subscribe to our YouTube channel
📸 Step 2: Take a screenshot of your subscription
💬 Step 3: Send the screenshot along with your Telegram name (as it appears in Telegram)
🔑 Step 4: Get admin access to our Official Telegram Channel and receive all the solutions!

📢 Join now and never miss any updates!
👉 https://t.me/+0dnF7vnXJ8lkOGFl

💡 All solutions will be uploaded, so make sure to subscribe and join our Telegram channel!

🚀 Don’t miss this opportunity to learn, compete, and grow as a coder! Let’s crack Starters 181 together! 🔥💻


Please Subscribe Our YouTube Channel

NOTE :- Don’t copy the full code — use the logic.
We're not responsible for plagiarism issues.
Thank you!



Q1 Solutions -


class Solution(object):
    def smallestIndex(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        for i in range(len(nums)):
            s = 0
            x = nums[i]
            while x > 0:
                s += x % 10
                x //= 10
            if s == i:
                return i
        return -1




Q2 Solutions -

class Solution(object):
    def minSwaps(self, nums):
        """                                                 #Q2 Solution 
        :type nums: List[int]
        :rtype: int
        """
        n = len(nums)
        arr = []
        for i, num in enumerate(nums):
            s = 0
            x = num
            while x > 0:
                s += x % 10
                x //= 10                                            #Q2 Solutoion  
            arr.append((s, num, i))
        arr.sort(key=lambda x: (x[0], x[1]))
        to_pos = [0] * n
        for target_pos, (_, _, orig_i) in enumerate(arr):
            to_pos[orig_i] = target_pos
        vis = [False] * n
        swaps = 0
        for i in range(n):
            if vis[i]:
                continue
            cycle_len = 0
            j = i
            while not vis[j]:
                vis[j] = True
                j = to_pos[j]
                cycle_len += 1
            if cycle_len > 0:
                swaps += cycle_len - 1
        return swaps




If we've helped you, please support us with a donation. ❤️🙏


Q3 Solutions -

from collections import deque, defaultdict

class Solution(object):
    def minMoves(self, matrix):
        m = len(matrix)
        n = len(matrix[0])

        voracelium = matrix

        dist = [[float('inf')] * n for _ in range(m)]
        portalMap = defaultdict(list)
        used = set()

        for i in range(m):
            for j in range(n):
                c = matrix[i][j]
                if c.isupper():
                    portalMap[c].append((i, j))

        dq = deque()
        dq.appendleft((0, 0, 0))
        dist[0][0] = 0

        directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]

        while dq:
            x, y, d = dq.popleft()

            if x == m - 1 and y == n - 1:
                return d

            curr = matrix[x][y]
            if curr.isupper() and curr not in used:
                used.add(curr)
                for nx, ny in portalMap[curr]:
                    if dist[nx][ny] > d:
                        dist[nx][ny] = d
                        dq.appendleft((nx, ny, d))

            for dx, dy in directions:
                nx, ny = x + dx, y + dy
                if 0 <= nx < m and 0 <= ny < n and matrix[nx][ny] != '#':
                    if dist[nx][ny] > d + 1:
                        dist[nx][ny] = d + 1
                        dq.append((nx, ny, d + 1))

        return -1


Q4 Solutions - (Don’t copy the code — use the logic.We're not responsible for plagiarism issues.)



class Solution:
    def __init__(self):
        self.LOG = 17                                   #Q4 Solution
        self.pendratova = []
        self.up = []
        self.depth = []
        self.distRoot = []

    def dfs(self, node, parent, d, dist):
        self.depth[node] = d
        self.distRoot[node] = dist
        self.up[0][node] = parent

        for nei, wt in self.pendratova[node]:                    #Q4 solution
            if nei != parent:
                self.dfs(nei, node, d + 1, dist + wt)

    def getLCA(self, u, v):
        if self.depth[u] < self.depth[v]:
            u, v = v, u
        for k in reversed(range(self.LOG)):
            if self.up[k][u] != -1 and self.depth[self.up[k][u]] >= self.depth[v]:
                u = self.up[k][u]

        if u == v:
            return u                                            #Q4 solution

        for k in reversed(range(self.LOG)):
            if self.up[k][u] != -1 and self.up[k][u] != self.up[k][v]:
                u = self.up[k][u]
                v = self.up[k][v]

        return self.up[0][u]
                                                                            #Q4 solution
    def getDist(self, u, v):
        lca = self.getLCA(u, v)
        return self.distRoot[u] + self.distRoot[v] - 2 * self.distRoot[lca]

    def minimumWeight(self, edges, queries):
        n = len(edges) + 1
        self.pendratova = [[] for _ in range(n)]
        for u, v, w in edges:
            self.pendratova[u].append((v, w))
            self.pendratova[v].append((u, w))

        self.depth = [0] * n
        self.distRoot = [0] * n
        self.up = [[-1] * n for _ in range(self.LOG)]

        self.dfs(0, -1, 0, 0)

        for k in range(1, self.LOG):
            for i in range(n):
                if self.up[k - 1][i] != -1:
                    self.up[k][i] = self.up[k - 1][self.up[k - 1][i]]

        answer = []
        for a, b, c in queries:
            dab = self.getDist(a, b)
            dac = self.getDist(a, c)
            dbc = self.getDist(b, c)
            total = (dab + dac + dbc) // 2
            answer.append(total)

        return answer





Comments

Post a Comment

Popular posts from this blog

Get All Coding Solutions

Codeforces Contest Round 1025 (Div.2) | All Questions Solutions – FREE! | 17 May 2025