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
Q3. Minimum Operations to Transform Array Status: Medium #leetcodecontest #leetcode #contest
Problem:Q3. ✊
Status: Hard 🌴
Code: Kotlin πŸŽ„
class Solution {
fun minOperations(nums1: IntArray, nums2: IntArray): Long {
val travenior = nums1.toMutableList()

val n = nums1.size
val x = nums2[n].toLong()

var baseSum = 0L
var bestExtra = Long.MAX_VALUE

for (i in 0 until n) {
val a = nums1[i].toLong()
val b = nums2[i].toLong()
baseSum += kotlin.math.abs(a - b)

val l = kotlin.math.min(a, b)
val r = kotlin.math.max(a, b)

val dist = when {
x < l -> l - x
x > r -> x - r
else -> 0L
}
val extra = dist + 1L
if (extra < bestExtra) bestExtra = extra
}

return baseSum + bestExtra
}
}

@leetcode7 @contest #leetcode #biweekly
Please open Telegram to view this post
VIEW IN TELEGRAM
❀2
Tomorrow contest @leetcode7 @leetcode8
Sozo TV β€” Android TV
Sozo is crafted with a perfect blend of simplicity and state-of-the-art elegance. It is designed as an Anilist only client, offering users the ability to stream and download their favorite Anime, Manga, Movies, and TV Shows.

✨ Why it's amazing
πŸ”— Get it: Telegram
πŸ“² Screenshots
πŸ“„ Source Code

❀️ Sincerely: @SeedOSS
Farmers who wait for the perfect weather never plannt.

━━━━━━━━━━━
πŸ–Œ @saikou πŸ“
Please open Telegram to view this post
VIEW IN TELEGRAM
😁6
Forwarded from Programmer Jokes
🀣6
Privacy is power. What people don't know, they can't ruin.

@saikou
πŸ”₯2
Tomorrow contest @leetcode7 @leetcode8
Java
😏 Java kvargs πŸ—Ώ
😏
Please open Telegram to view this post
VIEW IN TELEGRAM
Forwarded from Azamov | Dev
Perhaps the thing I'm most worried about in the future of AI and autofill is that I don't want to see ads in code either

#ai
Discipline is doing what needs to be done, even if you don't want to do it.

Anonymous #quote
Forwarded from π—½π—Όπ—½π— π—’𝗗𝗦 | 𝗙𝗒𝗦𝗦, π—Ÿπ—Άπ—³π—², π— π—²π—Ίπ—²π˜€ (κ‘­ π™Šπ™‹π™π™„π™ˆπ’Šπ’›π’†π’“ ལས་འཆདྷ)
Sozo for AndroidTV

Sozo is crafted with a perfect blend of simplicity and state-of-the-art elegance. It is designed as an Anilist only client, offering users the ability to stream and download their favorite Anime & Manga for AndroidTV too

πŸ”— Links:
- Download
- Screenshots
- Support
- Source code
Developer: ProfessorDeveloper

❀️ Support the Project

If this project makes your life easier, here are a few quick ways to show some love:

⭐ Star the repo/app
β˜• Buy a coffee for the developer
πŸ›  Contribute code, issues, or pull-requests


⚠️ This app might be breaking copyright laws, use at your own risk. We are not responsible for anything. We are just sharing open source software.

🏷 Tags: #Anime #Movie #AndroidTV
❀3
#today #biweekly #leetcode #contest , today i cant participate
Guys sorry i just trouble with sending
i just solved tomorrow questions .
now im resending
class Solution {
public int minMoves(int[] nums) {
int max = nums[0];
long sum = 0;
for (int x : nums) {
if (x > max) max = x;
sum += x;
}

return (int)((long) max * nums.length - sum);
}
}

@leetcode7
class Solution {
public int countMajoritySubarrays(int[] nums, int target) {
int n = nums.length;


int[] pref = new int[n + 1]; // pref[0] = 0 by default


int[] dresaniel = nums.clone();

for (int i = 0; i < n; i++) {
pref[i + 1] = pref[i] + (dresaniel[i] == target ? 1 : -1);
}

int ans = 0;
for (int r = 1; r <= n; r++) {
for (int l = 0; l < r; l++) {
if (pref[r] - pref[l] > 0) ans++;
}
}
return ans;
}
}
Β©leetcode7

@leetcode7

Q2
Forwarded from Azamov
Q3. Longest Non-Decreasing Subarray After Replacing at Most One Element

Code: Java
class Solution {
public int longestSubarray(int[] nums) {
int n = nums.length;
if (n <= 1) return n;
int[] left = new int[n];
left[0] = 1;
for (int i = 1; i < n; i++) {
left[i] = (nums[i] >= nums[i - 1]) ? left[i - 1] + 1 : 1;
}

int[] serathion = new int[n];
System.arraycopy(nums, 0, serathion, 0, n);
int[] right = new int[n];
right[n - 1] = 1;
for (int i = n - 2; i >= 0; i--) {
right[i] = (serathion[i] <= serathion[i + 1]) ? right[i + 1] + 1 : 1;
}

int ans = 0;

for (int i = 0; i < n; i++) ans = Math.max(ans, left[i]);

for (int k = 0; k < n; k++) {
int leftLen = (k > 0) ? left[k - 1] : 0;
int rightLen = (k + 1 < n) ? right[k + 1] : 0;

int cand = 1;

if (k > 0) cand = Math.max(cand, leftLen + 1);

if (k + 1 < n) cand = Math.max(cand, rightLen + 1);

if (k > 0 && k + 1 < n && serathion[k - 1] <= serathion[k + 1]) {
cand = Math.max(cand, leftLen + 1 + rightLen);
}

ans = Math.max(ans, cand);
}

return ans;
}
}
Q4. Count Subarrays With Majority Element II
#leetcode #contest