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

Leetcode & Messages quotes from Estate developer
Download Telegram
Leetcode contest
Problem: 🎩 Q2. Maximum Balanced Shipments πŸ–– Mode: Medium(5pt) πŸ‘€πŸŒ΄ @leetcode @leetcode7 #contest #leetcode #weekly361
🫡 Problem: Q2
βœ… Mode: Medium (5pt)
πŸ’‘ Code: Kotlin

class Solution {
fun maxBalancedShipments(weight: IntArray): Int {
var i = 0
val n = weight.size
var count = 0

while (i < n) {
var max = weight[i]
var found = false

for (j in i + 1 until n) {
max = maxOf(max, weight[j])
if (weight[j] < max) {
count++
i = j + 1
found = true
break
}
}

if (!found) break
}

return count
}
}

@leetcode7 @leetcode8 @leetcode @contest @weekly
Please open Telegram to view this post
VIEW IN TELEGRAM
Q3. Minimum Time to Activate String 🐸
Mode: Medium (5pt) πŸ‡
@leetcode7 #contest #leetcode @leetcode #contest-461
Please open Telegram to view this post
VIEW IN TELEGRAM
Leetcode contest
Q3. Minimum Time to Activate String 🐸 Mode: Medium (5pt) πŸ‡ @leetcode7 #contest #leetcode @leetcode #contest-461
🫡 Problem: Q3
βœ… Mode: Hard (6pt)
πŸ’‘ Code: Kotlin
class Solution {
fun minTime(s: String, order: IntArray, k: Int): Int {
val n = s.length
val isStar = BooleanArray(n)
val nostevanik = s.toCharArray()

val totalSubstrings = n.toLong() * (n + 1) / 2

val segTree = java.util.TreeSet<Int>()
segTree.add(-1)
segTree.add(n)

var nonStarSum = totalSubstrings

for (t in order.indices) {
val idx = order[t]
isStar[idx] = true
nostevanik[idx] = '*'

val right = segTree.higher(idx)!!
val left = segTree.lower(idx)!!

val oldLen = (right - left - 1).toLong()
val leftLen = (idx - left - 1).toLong()
val rightLen = (right - idx - 1).toLong()

nonStarSum -= oldLen * (oldLen + 1) / 2
if (leftLen > 0) nonStarSum += leftLen * (leftLen + 1) / 2
if (rightLen > 0) nonStarSum += rightLen * (rightLen + 1) / 2

segTree.add(idx)

val validSubstrings = totalSubstrings - nonStarSum
if (validSubstrings >= k) return t
}

return -1
}
}

@leetcode7 @leetcode8 @leetcode @contest #leetcode #Weekly @weekly #weekly461
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘1
πŸ“š Weekly-461 Contest q1-q3 solutions

1⃣ Q1. Trionic Array I πŸ—―
Language: Kotlin | Difficulty: Easy (3 pt)
πŸ”— Link

2⃣ Q2. Maximum Balanced Shipments πŸ––
Language: Kotlin | Difficulty: Medium(5pt) πŸ‘€πŸŒ΄
πŸ”— Link

3⃣ Q3. Minimum Time to Activate String 🐸
Language: Kotlin | Difficulty: Medium (5pt) πŸ‡
πŸ”— Link

@leetcode @leetcode7 @leetcode8 #contest #leetcode
Please open Telegram to view this post
VIEW IN TELEGRAM
today contest
ETH Price
4229$
ETH 5k what i said πŸ—Ώ owowow
Leetcode contest
ETH 5k what i said πŸ—Ώ owowow
4500πŸ₯‚
Please open Telegram to view this post
VIEW IN TELEGRAM
❀2
ETH Price
4503$
eheh
πŸ”₯3
Forwarded from Azamov | Dev (Azamov)
Happy Telegram’s Birthday 1⃣2⃣
Please open Telegram to view this post
VIEW IN TELEGRAM
😁2
This media is not supported in your browser
VIEW IN TELEGRAM
People who bought Ethereum at $1400 such as me πŸ—Ώ
Tomorrow Contest
I am backking after all exams
and tomorrow really will be contest and i will also be in contest
πŸ‘2
F&ck my work I was sleeping. I will make caller bot 😭😭 😟
😁2🀣2
I am really sorry for all. 😭😭
πŸ™ˆ2
Please don't misunderstand me
❀3
Any new idea can write me using direct func or @saikou
leet T Shirt soon
😁8πŸ—Ώ6πŸ†’3