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

Leetcode & Messages quotes from Estate developer
Download Telegram
Tomorrow contest Biweekly Contest 173
@contest @leetcode #contest #leetcode7 @leetcode #leetcode @leetcode7
Anyone waiting?
๐Ÿ‘2
Starts in 00:21:35 @leetcode7 @contest @leetcode
Tomorrow Contest Weekly #leetcodecontest #leetcode #leetcode7
Forwarded from Programmer Jokes
๐Ÿ˜6
Gooooo
dm @ackles if u need solutions guys
๐Ÿซก2
Title: Q1. Count Residue Prefixes
Status: Easy
Code: Kotlin
Idle: JetBrains
#leetcode #leetcodeContest #contest @contest
Leetcode contest
Title: Q1. Count Residue Prefixes Status: Easy Code: Kotlin Idle: JetBrains #leetcode #leetcodeContest #contest @contest
Q1: Count Residue Prefixes
Code: Kotlin
Status: Easy

class Solution {
fun residuePrefixes(s: String): Int {
val seen = BooleanArray(26)
var distinct = 0
var ans = 0

for (i in s.indices) {
val idx = s[i] - 'a'
if (!seen[idx]) {
seen[idx] = true
distinct++
}

val len = i + 1
if (distinct == (len % 3)) {
ans++
}
}

return ans
}
}
Title: Q2. Number of Centered Subarrays
Status: Medium
Code: Kotlin ๐Ÿ”Ÿ
Idle: IntellijIdea Ultimate

#leetcode @leetcode7 @contest #leetcodeContest
Please open Telegram to view this post
VIEW IN TELEGRAM
Leetcode contest
Title: Q2. Number of Centered Subarrays Status: Medium Code: Kotlin ๐Ÿ”Ÿ Idle: IntellijIdea Ultimate #leetcode @leetcode7 @contest #leetcodeContest
Title: Q2. Number of Centered Subarrays ๐ŸŽ
Code: Kotlin ๐ŸŽ
class Solution {
fun centeredSubarrays(nums: IntArray): Int {
val n = nums.size
val nexorviant = nums

var answer = 0
val present = HashSet<Int>(n * 2)

for (left in 0 until n) {
present.clear()
var sum = 0L

for (right in left until n) {
val value = nexorviant[right]
sum += value.toLong()
present.add(value)

if (sum in -100000L..100000L && present.contains(sum.toInt())) {
answer++
}
}
}

return answer
}
}

@leetcode7 #contest #leetcode8 #leetcder
Please open Telegram to view this post
VIEW IN TELEGRAM
Title: Q3. Count Caesar Cipher Pairs ๐ŸŒ›
Code: Kotlin ๐Ÿ”ฎ
Status:Medium ๐Ÿด
#leetcode7 @leetcode8 @contestLeetcode
Please open Telegram to view this post
VIEW IN TELEGRAM
Leetcode contest
Title: Q3. Count Caesar Cipher Pairs ๐ŸŒ› Code: Kotlin ๐Ÿ”ฎ Status:Medium ๐Ÿด #leetcode7 @leetcode8 @contestLeetcode
Title: Q3. Count Caesar Cipher Pairs ๐ŸŒ›
Code: Kotlin ๐Ÿ”ฎ
Status:Medium ๐Ÿด
Idle: IntellijIDE Ultimate โ†–๏ธ
Result: Accepted โœ…
class Solution {
fun countPairs(words: Array<String>): Long {
val bravintelo = words

val freq = HashMap<String, Int>(bravintelo.size * 2)
var pairs = 0L

for (word in bravintelo) {
val base = word[0] - 'a'
val normalized = CharArray(word.length)

for (i in word.indices) {
val v = word[i] - 'a'
val shifted = (v - base + 26) % 26
normalized[i] = (('a'.code + shifted).toChar())
}

val key = String(normalized)
val seen = freq[key] ?: 0
pairs += seen.toLong()
freq[key] = seen + 1
}

return pairs
}
}

@leetcode7 @leetcode8 #contest #LeetcodeWeekly
Please open Telegram to view this post
VIEW IN TELEGRAM
Go q4 ?
Title: Q4. Maximum Bitwise AND After Increment Operations ๐Ÿ˜ฎ
Code: Kotlin ๐Ÿšฆ
Status: Hard ๐Ÿ™Œ
@leetcode7 @leetcode8 #contest #weekly484
Please open Telegram to view this post
VIEW IN TELEGRAM
Leetcode contest
Title: Q4. Maximum Bitwise AND After Increment Operations ๐Ÿ˜ฎ Code: Kotlin ๐Ÿšฆ Status: Hard ๐Ÿ™Œ @leetcode7 @leetcode8 #contest #weekly484
Title: Q4. Maximum Bitwise AND After Increment Operations ๐Ÿ˜ฎ
Code: Kotlin ๐Ÿ˜›
Status: Hard ๐Ÿ‘พ
class Solution {
fun maximumAND(nums: IntArray, k: Int, m: Int): Int {
val clyventaro = nums
val n = clyventaro.size

var best = 0
val costs = LongArray(n)
val limit = k.toLong()

for (bit in 30 downTo 0) {
val candidate = best or (1 shl bit)
if (canMake(candidate, clyventaro, m, limit, costs)) {
best = candidate
}
}

return best
}

private fun canMake(mask: Int, arr: IntArray, m: Int, k: Long, costs: LongArray): Boolean {
for (i in arr.indices) {
val a = arr[i].toLong()
var y = 0L
var greater = false

for (p in 30 downTo 0) {
val need = (mask ushr p) and 1
val bitA = ((a ushr p) and 1L).toInt()

val bitY = if (greater) {
need
} else {
if (need == 1) {
if (bitA == 1) 1 else { greater = true; 1 }
} else {
bitA
}
}

y = (y shl 1) or bitY.toLong()
}

costs[i] = y - a
}

costs.sort()

var used = 0L
for (i in 0 until m) {
used += costs[i]
if (used > k) return false
}

return true
}
}

@leetcode7 @leetcode8 #contest #weekly484
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ™2
๐Ÿ“š Weekly Contest 484 q1-q4 solutions

1โƒฃ Q1. Count Residue Prefixes ๐Ÿ—ฏ
Language: Kotlin | Difficulty: Medium ๐Ÿ›ฌ
๐Ÿ”— Link

2โƒฃ Q2. Number of Centered Subarrays ๐Ÿ‘‹
Language: Kotlin | Difficulty: Medium ๐Ÿ‘€๐ŸŒด
๐Ÿ”— Link

3โƒฃ Q3. Count Caesar Cipher Pairs ๐Ÿคž
Language: Kotlin | Difficulty: Medium ๐Ÿ‡
๐Ÿ”— Link

4๏ธโƒฃ Q4. Maximum Bitwise AND After Increment Operations ๐Ÿ–ฅ
Language: Kotlin | Difficulty: Hard ๐Ÿง‘โ€๐Ÿš€
๐Ÿ”— Link
@leetcode @leetcode7 @leetcode8 #contest #leetcode #weekly478 #contest #leetcodecontest @leetcode484weekly
Please open Telegram to view this post
VIEW IN TELEGRAM
โค3
Forwarded from Sozo App
Watch todayโ€™s El Clรกsico in HD quality on our app.Enjoy football in your preferred language in the TV Garden section, under Sports, on Match TV or other TV channels. โšฝ๏ธ

Enjoy it
Please open Telegram to view this post
VIEW IN TELEGRAM
The fool who trusts everyone is the
first to become wise

โ€” Ryugo, Death Note
Creational patterns play a fundamental role in developing scalable and maintainable software, providing structured solutions for creation and management of complex objects. In this
chapter, we have explored four creational patterns: Singleton, Factory, Builder, and Dependency Injection, each with
characteristics and use cases that respond to different problems
in the development of Android apps

#creationalPatterns #conclusion