Skip to content

Instantly share code, notes, and snippets.

@igavrysh
igavrysh / leetcode_1792.java
Created December 16, 2024 00:05
1792. Maximum Average Pass Ratio
/**
1792. Maximum Average Pass Ratio
https://leetcode.com/problems/maximum-average-pass-ratio
Medium
There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [passi, totali]. You know beforehand that in the ith class, there are totali total students, but only passi number of students will pass the exam.
You are also given an integer extraStudents. There are another extraStudents brilliant students that are guaranteed to pass the exam of any class they are assigned to. You want to assign each of the extraStudents students to a class in a way that maximizes the average pass ratio across all the classes.
The pass ratio of a class is equal to the number of students of the class that will pass the exam divided by the total number of students of the class. The average pass ratio is the sum of pass ratios of all the classes divided by the number of the classes.
@igavrysh
igavrysh / leetcode_3264.java
Created December 17, 2024 00:04
3264. Final Array State After K Multiplication Operations I
/**
3264. Final Array State After K Multiplication Operations I
https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i
Easy
You are given an integer array nums, an integer k, and an integer multiplier.
You need to perform k operations on nums. In each operation:
@igavrysh
igavrysh / leetcode_2182.java
Created December 17, 2024 16:07
2182. Construct String With Repeat Limit
/**
2182. Construct String With Repeat Limit
https://leetcode.com/problems/construct-string-with-repeat-limit
Medium
Hint
You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s.
Return the lexicographically largest repeatLimitedString possible.
@igavrysh
igavrysh / leetcode_1475.java
Created December 18, 2024 13:16
1475. Final Prices With a Special Discount in a Shop
/**
1475. Final Prices With a Special Discount in a Shop
https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop
Easy
You are given an integer array prices where prices[i] is the price of the ith item in a shop.
There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will not receive any discount at all.
Return an integer array answer where answer[i] is the final price you will pay for the ith item of the shop, considering the special discount.
@igavrysh
igavrysh / leetcode_916.java
Created January 10, 2025 05:55
916. Word Subsets
/*
916. Word Subsets
Medium
Companies
You are given two string arrays words1 and words2.
A string b is a subset of string a if every letter in b occurs in a including multiplicity.