TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 3331,3 "name": "minimum_operations_to_exceed_threshold_value_i",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-i/",6 "date": "2024-02-17 00:00:00",7 "task_description": "You are given a **0-indexed** integer array `nums`, and an integer `k`. In one operation, you can remove one occurrence of the smallest element of `nums`. Return _the **minimum** number of operations needed so that all elements of the array are greater than or equal to_ `k`. **Example 1:** ``` **Input:** nums = [2,11,10,1,3], k = 10 **Output:** 3 **Explanation:** After one operation, nums becomes equal to [2, 11, 10, 3]. After two operations, nums becomes equal to [11, 10, 3]. After three operations, nums becomes equal to [11, 10]. At this stage, all the elements of nums are greater than or equal to 10 so we can stop. It can be shown that 3 is the minimum number of operations needed so that all elements of the array are greater than or equal to 10. ``` **Example 2:** ``` **Input:** nums = [1,1,2,4,9], k = 1 **Output:** 0 **Explanation:** All elements of the array are greater than or equal to 1 so we do not need to apply any operations on nums. ``` **Example 3:** ``` **Input:** nums = [1,1,2,4,9], k = 9 **Output:** 4 **Explanation:** only a single element of nums is greater than or equal to 9 so we need to apply the operations 4 times on nums. ``` **Constraints:** `1 <= nums.length <= 50` `1 <= nums[i] <= 109` `1 <= k <= 109` The input is generated such that there is at least one index `i` such that `nums[i] >= k`.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [2,11,10,1,3], k = 10",12 "output": "3 "13 },14 {15 "label": "Example 2",16 "input": "nums = [1,1,2,4,9], k = 1",17 "output": "0 "18 },19 {20 "label": "Example 3",21 "input": "nums = [1,1,2,4,9], k = 9",22 "output": "4 "23 }24 ],25 "private_test_cases": [26 {27 "input": [28 [29 837680895,30 853858337,31 24598603,32 145776187,33 102048932,34 275696906,35 263784197,36 259528597,37 783359124,38 350268406,39 900373180,40 309852815,41 445507305,42 429960240,43 230653560,44 426226417,45 699105194,46 326176309,47 677374300,48 139662764,49 108043712,50 54789364,51 832593730,52 429236026,53 406505827,54 623103757,55 256703084,56 83243550,57 18161168,58 189733518,59 568132758,60 29959090,61 867405713,62 411418480,63 700692292,64 22780480265 ],66 62690393867 ],68 "output": 2769 },70 {71 "input": [72 [73 200160358,74 767998187,75 566852913,76 18083777,77 9978221,78 637466308,79 36639519,80 355127397,81 57023173,82 430035734,83 725453411,84 435939304,85 742706058,86 714533739,87 186274592,88 897908212,89 503840255,90 894177475,91 218593673,92 625534889,93 610519718,94 100804013,95 162700115,96 485027309,97 562081129,98 86056958,99 676074708,100 169098576,101 408307021,102 466842607,103 428106855,104 640671335,105 429073519,106 316929766,107 831062524,108 854836279,109 39363427,110 359717378,111 894780196,112 91723992,113 632488380,114 132326404,115 494088872,116 750285776,117 184620703,118 622023780,119 861690586120 ],121 126557389122 ],123 "output": 8124 },125 {126 "input": [127 [128 359495375,129 353377823,130 927475595131 ],132 877252882133 ],134 "output": 2135 },136 {137 "input": [138 [139 759371410,140 481585300,141 318750444,142 490011963,143 167716655,144 615185637,145 104322452,146 554039032,147 731763208,148 341062499,149 951495453150 ],151 400875435152 ],153 "output": 4154 },155 {156 "input": [157 [158 584460137,159 498030234,160 144472554,161 372086138,162 720354826,163 51537949,164 817215367,165 83380865,166 636538356,167 965638986,168 297014741,169 589201137,170 214359905,171 829284537,172 529311659,173 445859529,174 198704898,175 755106120,176 226987064,177 985497093,178 120863718,179 643067673,180 486094118181 ],182 791727781183 ],184 "output": 19185 },186 {187 "input": [188 [189 274832127,190 742408131,191 645209228,192 687271474,193 907228481,194 133366239,195 766714103,196 605343034,197 158748000,198 350597623,199 218942890,200 886521030,201 543925191,202 473759503,203 469067416,204 771591040,205 539822413,206 68728437,207 912528563,208 169379180,209 76632144,210 786831884,211 285450676,212 732347105,213 644479179,214 963268297,215 520402980,216 922491460217 ],218 178087213219 ],220 "output": 5221 },222 {223 "input": [224 [225 685988449,226 70774325,227 589649250,228 688096551,229 425395718,230 490987172,231 508508915,232 484551152,233 583684910,234 765629330,235 836384600,236 802786833,237 982717249,238 158394047,239 550800,240 390279843,241 722126689,242 571660265,243 625429634,244 143765854,245 595404055,246 925443824,247 401104468,248 367751084,249 889268965,250 699607588,251 575961238,252 314115643,253 697716829,254 536517870,255 559191951,256 920388547,257 200594134,258 387732353,259 568361709,260 811971022,261 982350855,262 973448213,263 519766706,264 996556281265 ],266 303785602267 ],268 "output": 5269 },270 {271 "input": [272 [273 556460243,274 454719521,275 828215584,276 33540960,277 833776484,278 796307469,279 737891462,280 243789849,281 151678067,282 586096234,283 461228612,284 129783312,285 657321204,286 615831465,287 415883607,288 818047112,289 471480526,290 247423190,291 750873137,292 137593416,293 714440208,294 662351159,295 82989268,296 391459012,297 324980563,298 884542561,299 22503900,300 998310152,301 236665603,302 234733974,303 571520764,304 870425439,305 763694333,306 4643610,307 539860036,308 539637809,309 892620164,310 342365865,311 977008460,312 929919177,313 604674854,314 241824819,315 175868156316 ],317 436584773318 ],319 "output": 17320 },321 {322 "input": [323 [324 319451956,325 246054504,326 528841648,327 420095541,328 659942124,329 441270378,330 435772224,331 471135457,332 540945551,333 760013398,334 469145880,335 614924412,336 77495934,337 999573938,338 743399544,339 236824453,340 297093621,341 54361659,342 367243721,343 452141930,344 234880895,345 886799017,346 919852949,347 966513579,348 654346931,349 912264360,350 687981661,351 406583976,352 12788247,353 985661724,354 342622824,355 216418835,356 884123565,357 602278143,358 339030492,359 303819825,360 529515549,361 883347388,362 693055512,363 674634802,364 700740714,365 446148772,366 130917452,367 136082072368 ],369 374277091370 ],371 "output": 15372 },373 {374 "input": [375 [376 924395901,377 154495792,378 272244912,379 957324389,380 446005655,381 624861815,382 889629528,383 105094206384 ],385 843440952386 ],387 "output": 5388 }389 ],390 "haskell_template": "minOperations :: [Int] -> Int -> Int\nminOperations nums k ",391 "ocaml_template": "let minOperations (nums: int list) (k: int) : int = ",392 "scala_template": "def minOperations(nums: List[Int],k: Int): Int = { \n \n}",393 "java_template": "class Solution {\n public int minOperations(int[] nums, int k) {\n \n }\n}",394 "python_template": "class Solution(object):\n def minOperations(self, nums, k):\n \"\"\"\n :type nums: List[int]\n :type k: int\n :rtype: int\n \"\"\"\n "395}