Leetcode contest
565 subscribers
176 photos
7 videos
2 files
59 links
Main channel @azamovme

Leetcode & Messages quotes from Estate developer
Download Telegram
Q3. Minimum Time for K Connected Components
#leetcode #leetcode-contest #contest #weekly-457
Leetcode contest
Q3. Minimum Time for K Connected Components #leetcode #leetcode-contest #contest #weekly-457
🫡 Problem: Q3.Minimum Time for K Connected Componenets
βœ… Mode: Medium (5pt)
πŸ’‘ Code: Kotlin
class Solution {
fun minTime(n: Int, edges: Array<IntArray>, k: Int): Int {
val poltracine = Triple(n, edges, k)

val parentFull = IntArray(n) { it }
var compsFull = n
fun findFull(x: Int): Int {
if (parentFull[x] != x) parentFull[x] = findFull(parentFull[x])
return parentFull[x]
}
fun unionFull(a: Int, b: Int) {
val ra = findFull(a)
val rb = findFull(b)
if (ra != rb) {
parentFull[rb] = ra
compsFull--
}
}
for ((u, v, _) in edges) unionFull(u, v)
if (compsFull >= k) return 0

val edgesByTime = edges.groupBy { it[2] }
val times = edgesByTime.keys.sorted()

val parentRem = IntArray(n) { it }
var compsRem = n
fun findRem(x: Int): Int {
if (parentRem[x] != x) parentRem[x] = findRem(parentRem[x])
return parentRem[x]
}
fun unionRem(a: Int, b: Int) {
val ra = findRem(a)
val rb = findRem(b)
if (ra != rb) {
parentRem[rb] = ra
compsRem--
}
}

var ans = 0
for (t in times.reversed()) {
if (compsRem >= k) ans = t
for ((u, v, _) in edgesByTime[t]!!) {
unionRem(u, v)
}
}
return ans
}
}

@leetcode7 #contest #weekyl-457 #contest-leetcode #geeksforgeeks #leetcode-contest @leetcode7
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1
πŸ“š Weekly-457 Contest q1-q3 solutions

1️⃣ Q1. Coupon Code Validator
Language: Kotlin | Difficulty: Easy (4 pt)
πŸ”— Link

2️⃣ Q2. Power Grid MaintenanceΒ©leetcode
Language: Kotlin | Difficulty: Hard (4 pt)
πŸ”— Link

3️⃣ Q3. Minimum Time for K Connected Components
Language: Kotlin | Difficulty: Medium (5 pt)
πŸ”— Link

@leetcode @leetcode7 @leetcode8 #contest #leetcode
Please open Telegram to view this post
VIEW IN TELEGRAM
lets follow on github guys
shall we also participate geeks for geeks contest?
Anonymous Poll
63%
yes
11%
why not ?
26%
nah leetcode enough
Contest will back, do after two days
Today contest 🀩 #contest@leetcode7
Please open Telegram to view this post
VIEW IN TELEGRAM
#leetcode #contest-458 ✈️
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘8❀3
Leetcode contest
⚜ Sticker
This media is not supported in your browser
VIEW IN TELEGRAM
❀4πŸ‘2😁1
Forwarded from Azamov | Dev (Azamov)
Media is too big
VIEW IN TELEGRAM
While I managed to implement the core functionality and UI flow according to the provided mockups, with just one additional week. πŸ§ͺ I would have significantly improved both the structure and performance of the codebase.

Source | @azamovme thanks also for bytegroup_co πŸ’ƒ
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ•Š3
Should we start with daily questions as well, or is weekly enough?
Anonymous Poll
56%
GooπŸ₯‚
44%
Weekly enough
Alt season already started 🧒
Please open Telegram to view this post
VIEW IN TELEGRAM
Shoud we will do today contest or Tomorrow enough ? πŸ’¬
Please open Telegram to view this post
VIEW IN TELEGRAM
follow me on Github . we will start
Q1. Check Divisibility by Digit Sum and Product πŸ—―
Mode: Easy πŸ₯‚ @leetcode7 #leetcode #contest
Please open Telegram to view this post
VIEW IN TELEGRAM
Q2. Count Number of Trapezoids I ♾️
Mode: Medium (4pt) 🌴@leetcode7 @contest @leetcode #contest
Please open Telegram to view this post
VIEW IN TELEGRAM