instruction_seed
stringlengths
308
3.48k
source
stringclasses
1 value
embeddings
listlengths
1.02k
1.02k
mean_positive_score
float64
0.8
0.86
mean_negative_score
float64
0.74
0.8
difference_score
float64
0.05
0.07
Please explain the reasoning behind the following solution and provide code in ANSI C: You have two types of tiles: a `2 x 1` domino shape and a tromino shape. You may rotate these shapes. Given an integer n, return _the number of ways to tile an_ `2 x n` _board_. Since the answer may be very large, return it **modulo...
dolphin
[ 0.031335726380348206, 0.026222866028547287, -0.02152021788060665, -0.023667609319090843, 0.021048789843916893, -0.02614978700876236, -0.030821481719613075, 0.07995607703924179, 0.008693170733749866, -0.00818319246172905, 0.04386039450764656, 0.05058792233467102, -0.04270166531205177, -0.02...
0.834242
0.774445
0.059797
Please explain the following problem in detail and provide code in java: You are given an array of integers `nums` **(0-indexed)** and an integer `k`. The **score** of a subarray `(i, j)` is defined as `min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)`. A **good** subarray is a subarray where `i <= k <= j`. Return...
dolphin
[ 0.007979952730238438, 0.032172199338674545, -0.036688432097435, -0.02918051928281784, 0.043290868401527405, -0.03429155424237251, -0.037149880081415176, 0.02848491258919239, 0.027512716129422188, -0.0024999903980642557, 0.022188540548086166, 0.015955476090312004, -0.024572229012846947, 0.0...
0.845736
0.778196
0.067539
Please explain the reasoning behind the following solution and provide code in PHP: You are given an array `nums` that consists of non-negative integers. Let us define `rev(x)` as the reverse of the non-negative integer `x`. For example, `rev(123) = 321`, and `rev(120) = 21`. A pair of indices `(i, j)` is **nice** if i...
dolphin
[ 0.019835973158478737, 0.025349218398332596, -0.031244663521647453, -0.031780000776052475, 0.04518609493970871, -0.01627710647881031, -0.03600340336561203, 0.060180556029081345, 0.029248496517539024, -0.00239536608569324, 0.021490614861249924, 0.03321018069982529, -0.04602028429508209, -0.0...
0.850633
0.796011
0.054623
Please explain the following problem in detail and provide code in C#: You are given an array of integers `nums` and an integer `target`. Return _the number of **non-empty** subsequences of_ `nums` _such that the sum of the minimum and maximum element on it is less or equal to_ `target`. Since the answer may be too la...
dolphin
[ 0.010883566923439503, 0.007801620755344629, -0.03103424422442913, -0.02772960625588894, 0.05158872529864311, -0.01247129961848259, -0.03503916785120964, 0.06930707395076752, 0.025189999490976334, -0.003982071299105883, 0.019794974476099014, 0.03340497612953186, -0.05116793140769005, -0.025...
0.847769
0.784254
0.063514
Please write the following solution using python: You are given a binary string `s`, and two integers `num1` and `num2`. `num1` and `num2` are coprime numbers. A **ratio substring** is a substring of s where the ratio between the number of `0`'s and the number of `1`'s in the substring is exactly `num1 : num2`. * F...
dolphin
[ 0.017783626914024353, 0.021007392555475235, -0.022918391972780228, -0.029788997024297714, 0.03431415930390358, -0.03025619313120842, -0.002515696221962571, 0.07138913124799728, 0.020460035651922226, -0.008915955200791359, 0.026392046362161636, 0.009255955927073956, -0.02731604129076004, -0...
0.848247
0.792836
0.055411
Please explain the following problem in detail and provide code in Object Pascal: You have an array `arr` of length `n` where `arr[i] = (2 * i) + 1` for all valid values of `i` (i.e., `0 <= i < n`). In one operation, you can select two indices `x` and `y` where `0 <= x, y < n` and subtract `1` from `arr[x]` and add `1...
dolphin
[ 0.02721206471323967, 0.027471551671624184, -0.026601318269968033, -0.04577957093715668, 0.03445443883538246, -0.030007023364305496, -0.010824528522789478, 0.06987937539815903, 0.040586404502391815, -0.010414584539830685, 0.024045826867222786, 0.022610342130064964, -0.01987050287425518, -0....
0.846129
0.787283
0.058846
Please focus on the efficiency of this problem and provide code in ANSI C: You are given a **0-indexed** string `s` and are tasked with finding two **non-intersecting palindromic** substrings of **odd** length such that the product of their lengths is maximized. More formally, you want to choose four integers `i`, `j`...
dolphin
[ 0.01840745098888874, 0.026319535449147224, -0.019830364733934402, -0.026221442967653275, 0.02473578229546547, -0.02824724093079567, -0.031232565641403198, 0.06774293631315231, 0.03683296963572502, -0.016264092177152634, 0.02524759992957115, 0.021384267136454582, -0.0359775647521019, -0.037...
0.841617
0.788276
0.053341
Please write the following solution using F#: A **wiggle sequence** is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elem...
dolphin
[ 0.011307214386761189, 0.008004055358469486, -0.014989282935857773, -0.0338483527302742, 0.04309353604912758, -0.03421276807785034, -0.03594744950532913, 0.06410674005746841, 0.03480324149131775, -0.018340177834033966, 0.0229596346616745, 0.02830820530653, -0.042768340557813644, -0.02417621...
0.846581
0.788559
0.058022
Please write the following solution using Objective-C: Given two integer arrays `nums1` and `nums2`, return _an array of their intersection_. Each element in the result must appear as many times as it shows in both arrays and you may return the result in **any order**. **Example 1:** **Input:** nums1 = \[1,2,2,1\], n...
dolphin
[ 0.02978917956352234, 0.019964762032032013, -0.022435173392295837, -0.018536211922764778, 0.022010676562786102, -0.02296373061835766, -0.042055997997522354, 0.05305837467312813, 0.04591115191578865, -0.01895030401647091, 0.03564898297190666, -0.003899634350091219, -0.01741558499634266, -0.0...
0.822456
0.768733
0.053723
Please focus on the algorithm of this problem and provide code in c++: You are given a **0-indexed** integer array `books` of length `n` where `books[i]` denotes the number of books on the `ith` shelf of a bookshelf. You are going to take books from a **contiguous** section of the bookshelf spanning from `l` to `r` wh...
dolphin
[ 0.035632599145174026, 0.01100529171526432, -0.029280126094818115, -0.030865326523780823, 0.03213893994688988, -0.017895285040140152, -0.029607582837343216, 0.08501075208187103, 0.03475871682167053, -0.021091872826218605, 0.018102770671248436, 0.030613478273153305, -0.04624020680785179, -0....
0.83911
0.781109
0.058001
Please write the following solution using java: You are given two **0-indexed** integer arrays `nums1` and `nums2`, of equal length `n`. In one operation, you can swap the values of any two indices of `nums1`. The **cost** of this operation is the **sum** of the indices. Find the **minimum** total cost of performing ...
dolphin
[ 0.0008095302036963403, 0.02792133018374443, -0.040376171469688416, -0.004874730948358774, 0.035388994961977005, -0.018582182005047798, -0.03180874139070511, 0.04837924987077713, 0.03823312371969223, -0.030456753447651863, 0.02176208235323429, -0.0018661606591194868, -0.026591280475258827, ...
0.846138
0.78716
0.058978
Please write the following solution using Scheme: You are given a **0-indexed** binary array `nums` of length `n`. `nums` can be divided at index `i` (where `0 <= i <= n)` into two arrays (possibly empty) `numsleft` and `numsright`: * `numsleft` has all the elements of `nums` between index `0` and `i - 1` **(inclusi...
dolphin
[ 0.0385921485722065, 0.022358201444149017, -0.02762231044471264, -0.0187725517898798, 0.03618454188108444, -0.03370298072695732, -0.03751637414097786, 0.06048725172877312, 0.047681596130132675, -0.007191346026957035, 0.021457234397530556, 0.023052025586366653, -0.022778939455747604, -0.0106...
0.854395
0.785534
0.06886
Please write the following solution using Scala: You are given two **0-indexed** integer arrays `nums1` and `nums2`, each of size `n`, and an integer `diff`. Find the number of **pairs** `(i, j)` such that: * `0 <= i < j <= n - 1` **and** * `nums1[i] - nums1[j] <= nums2[i] - nums2[j] + diff`. Return _the **number...
dolphin
[ 0.011778115294873714, 0.016240669414401054, -0.027888696640729904, -0.029606902971863747, 0.05760995298624039, -0.011369782499969006, -0.02906312607228756, 0.05420021340250969, 0.032462481409311295, -0.01664656214416027, 0.016686372458934784, 0.03094702586531639, -0.03149808943271637, -0.0...
0.855414
0.796315
0.059099
Please focus on the functionality of this problem and provide code in C#: You are given a **0-indexed** integer array `nums` consisting of `3 * n` elements. You are allowed to remove any **subsequence** of elements of size **exactly** `n` from `nums`. The remaining `2 * n` elements will be divided into two **equal** p...
dolphin
[ 0.01722119189798832, 0.0195297934114933, -0.03618040308356285, -0.024506986141204834, 0.03540473058819771, -0.035506471991539, -0.027366135269403458, 0.09377316385507584, 0.045646797865629196, -0.02210180275142193, 0.021864086389541626, 0.023355040699243546, -0.03924144431948662, -0.017406...
0.85163
0.790487
0.061143
Please explain the following problem in detail and provide code in ANSI C: You are given a **0-indexed** array `nums` of **distinct** integers. You want to rearrange the elements in the array such that every element in the rearranged array is **not** equal to the **average** of its neighbors. More formally, the rearra...
dolphin
[ 0.01425637025386095, 0.043145596981048584, -0.02778538502752781, -0.023138679563999176, 0.03011130914092064, -0.0193997360765934, -0.034446511417627335, 0.06388647854328156, 0.023363374173641205, -0.01504544634371996, 0.02845069393515587, 0.0016601203242316842, -0.04786156117916107, -0.010...
0.828818
0.774844
0.053974
Please explain the following problem in detail and provide code in Dart: The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`. * For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`. Given an integer array `nums`, choose four *...
dolphin
[ 0.022275352850556374, 0.028990162536501884, -0.015325680375099182, -0.02457045391201973, 0.05149531736969948, -0.008385537192225456, -0.05296241119503975, 0.055809199810028076, 0.045532166957855225, -0.010030128061771393, 0.017395885661244392, 0.040467992424964905, -0.027625689283013344, -...
0.844686
0.789814
0.054872
Please write the following solution using Kotlin: Given an integer array `nums` and an integer `k`, return _the number of **good** subarrays of_ `nums`. A subarray `arr` is **good** if it there are **at least** `k` pairs of indices `(i, j)` such that `i < j` and `arr[i] == arr[j]`. A **subarray** is a contiguous **no...
dolphin
[ 0.017668183892965317, 0.021878890693187714, -0.036593835800886154, -0.026234889402985573, 0.0433240681886673, -0.01560575794428587, -0.0365460142493248, 0.03486005216836929, 0.03068394586443901, -0.008400773629546165, 0.012735258787870407, 0.0234086774289608, -0.019132478162646294, -0.0016...
0.840389
0.779322
0.061067
Please explain the reasoning behind the following solution and provide code in c++: Return the number of permutations of 1 to `n` so that prime numbers are at prime indices (1-indexed.) _(Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers bo...
dolphin
[ 0.03717875853180885, 0.023125769570469856, -0.0004935017204843462, -0.04037362337112427, 0.03793245926499367, -0.03156120330095291, -0.02199741080403328, 0.07316625863313675, 0.027485251426696777, -0.02338249608874321, 0.03448798507452011, 0.038574643433094025, -0.036322835832834244, -0.01...
0.836895
0.776524
0.060371
Please focus on the functionality of this problem and provide code in F#: You are given two **0-indexed** integer arrays `nums1` and `nums2`, each of size `n`, and an integer `diff`. Find the number of **pairs** `(i, j)` such that: * `0 <= i < j <= n - 1` **and** * `nums1[i] - nums1[j] <= nums2[i] - nums2[j] + dif...
dolphin
[ 0.005921058356761932, 0.015037812292575836, -0.02386210672557354, -0.03422532230615616, 0.05180264264345169, -0.011688850820064545, -0.028643706813454628, 0.07132506370544434, 0.04581395536661148, -0.006406477652490139, 0.01395841222256422, 0.027756834402680397, -0.05272088944911957, -0.02...
0.855033
0.801408
0.053626
Please write the following solution using Kotlin: Write an efficient algorithm that searches for a value `target` in an `m x n` integer matrix `matrix`. This matrix has the following properties: * Integers in each row are sorted in ascending from left to right. * Integers in each column are sorted in ascending fro...
dolphin
[ 0.015153643675148487, 0.01201438158750534, -0.024588115513324738, -0.0428369864821434, 0.05470627546310425, -0.031277116388082504, -0.027354374527931213, 0.04844237118959427, 0.029898786917328835, -0.017280086874961853, 0.011143247596919537, 0.024276362732052803, -0.03135302662849426, -0.0...
0.838557
0.784677
0.05388
Please write the following solution using Kotlin: You are given two arrays of positive integers, `boxes` and `warehouse`, representing the heights of some boxes of unit width and the heights of `n` rooms in a warehouse respectively. The warehouse's rooms are labeled from `0` to `n - 1` from left to right where `warehou...
dolphin
[ 0.02524939365684986, 0.015865253284573555, -0.020871225744485855, -0.014183399267494678, 0.02808508276939392, -0.008018256165087223, -0.025195512920618057, 0.061183203011751175, 0.03446060046553612, -0.010506669990718365, 0.01850488968193531, 0.04192452132701874, -0.023677008226513863, -0....
0.842145
0.787713
0.054432
Please explain the following problem in detail and provide code in Visual Basic .NET: You are given a **0-indexed** integer array `nums`. **Swaps** of **adjacent** elements are able to be performed on `nums`. A **valid** array meets the following conditions: * The largest element (any of the largest elements if th...
dolphin
[ 0.02401103638112545, 0.039314333349466324, -0.02329736016690731, -0.01863739639520645, 0.04042426869273186, -0.02460790053009987, -0.019337715581059456, 0.06235168129205704, 0.03185814619064331, -0.01416945829987526, 0.02170669287443161, 0.021791312843561172, -0.038763437420129776, -0.0303...
0.847969
0.794714
0.053255
Please explain the following problem in detail and provide code in F#: Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[4,6,7,7\] **Output:** \[\[...
dolphin
[ 0.008296359330415726, 0.018666144460439682, -0.0009587106760591269, -0.028347717598080635, 0.04659288004040718, -0.020968925207853317, -0.020546240732073784, 0.060038622468709946, 0.04970791935920715, -0.00678868917748332, 0.033451683819293976, 0.02460656501352787, -0.057458654046058655, -...
0.839388
0.782803
0.056586
Please focus on the efficiency of this problem and provide code in F#: For an integer array `nums`, an **inverse pair** is a pair of integers `[i, j]` where `0 <= i < j < nums.length` and `nums[i] > nums[j]`. Given two integers n and k, return the number of different arrays consist of numbers from `1` to `n` such that...
dolphin
[ 0.02320913039147854, 0.03893014416098595, -0.02209208346903324, -0.027056081220507622, 0.04674189165234566, -0.023642033338546753, -0.014088311232626438, 0.06504388153553009, 0.038393475115299225, -0.00818433053791523, 0.019423196092247963, 0.023033617064356804, -0.03618208318948746, -0.02...
0.84816
0.786328
0.061832
Please write the following solution using python: You are given a **0-indexed** 2D integer array of `events` where `events[i] = [startTimei, endTimei, valuei]`. The `ith` event starts at `startTimei` and ends at `endTimei`, and if you attend this event, you will receive a value of `valuei`. You can choose **at most** *...
dolphin
[ 0.024133386090397835, 0.015640581026673317, -0.03780084475874901, -0.030846726149320602, 0.021962834522128105, -0.019304007291793823, -0.054085589945316315, 0.051359277218580246, 0.04961508512496948, 0.000861817505210638, 0.0408838726580143, 0.029671164229512215, -0.02049037627875805, 0.00...
0.837608
0.78368
0.053929
Please write the following solution using ANSI C: Given a `triangle` array, return _the minimum path sum from top to bottom_. For each step, you may move to an adjacent number of the row below. More formally, if you are on index `i` on the current row, you may move to either index `i` or index `i + 1` on the next row....
dolphin
[ 0.014984034933149815, 0.02521182782948017, -0.02604866586625576, -0.031265389174222946, 0.04452535882592201, -0.03153550624847412, -0.04164270684123039, 0.07217110693454742, 0.03631563484668732, -0.010188112035393715, 0.027035947889089584, 0.0153480414301157, -0.027491208165884018, -0.0225...
0.84031
0.776127
0.064183
Please focus on the algorithm of this problem and provide code in Kotlin: You are given a positive integer `n`. Each digit of `n` has a sign according to the following rules: * The **most significant digit** is assigned a **positive** sign. * Each other digit has an opposite sign to its adjacent digits. Return _t...
dolphin
[ 0.018802031874656677, 0.012040981091558933, -0.029725704342126846, -0.039726536720991135, 0.031511422246694565, -0.04358670487999916, -0.019940804690122604, 0.05451592803001404, 0.028367212042212486, -0.01014419924467802, 0.020714540034532547, 0.05165915563702583, -0.04232003912329674, -0....
0.844846
0.789787
0.055058
Please explain the reasoning behind the following solution and provide code in Scala: You are given two **non-increasing 0-indexed** integer arrays `nums1`​​​​​​ and `nums2`​​​​​​. A pair of indices `(i, j)`, where `0 <= i < nums1.length` and `0 <= j < nums2.length`, is **valid** if both `i <= j` and `nums1[i] <= nums...
dolphin
[ 0.014076112769544125, 0.02871014177799225, -0.01793677546083927, -0.024467257782816887, 0.04405772686004639, -0.021585645154118538, -0.030719468370079994, 0.05444760248064995, 0.029730485752224922, -0.024802347645163536, 0.02646305039525032, 0.026290083304047585, -0.021701203659176826, 0.0...
0.847394
0.793455
0.05394
Please write the following solution using Fortran: Given an integer array `nums` of size `n`, return _the minimum number of moves required to make all array elements equal_. In one move, you can increment or decrement an element of the array by `1`. Test cases are designed so that the answer will fit in a **32-bit** ...
dolphin
[ 0.020187972113490105, 0.010845114476978779, -0.03167378529906273, -0.04252336174249649, 0.04331428185105324, -0.025975171476602554, -0.012620321474969387, 0.062473732978105545, 0.028569860383868217, -0.030826393514871597, 0.038731060922145844, 0.01971200853586197, -0.04209541529417038, -0....
0.85356
0.792955
0.060605
Please write the following solution using Object Pascal: You are given an integer array `values` where values\[i\] represents the value of the `ith` sightseeing spot. Two sightseeing spots `i` and `j` have a **distance** `j - i` between them. The score of a pair (`i < j`) of sightseeing spots is `values[i] + values[j]...
dolphin
[ 0.019360866397619247, 0.019854851067066193, -0.029479779303073883, -0.02196948416531086, 0.056340087205171585, -0.019347507506608963, -0.043101757764816284, 0.03500465676188469, 0.05623367428779602, -0.009584246203303337, 0.039272647351026535, 0.04914533719420433, -0.031147759407758713, 0....
0.837613
0.778339
0.059275
Please explain the following problem in detail and provide code in javascript: Given an integer array `nums`, return _the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle_. **Example 1:** **Input:** nums = \[2,2,3,4\] **Output:** 3 **Explanation:** Valid c...
dolphin
[ 0.012425253167748451, 0.02897234447300434, -0.019000662490725517, -0.012824204750359058, 0.036262668669223785, -0.01399320550262928, -0.02470816858112812, 0.05391364172101021, 0.025752080604434013, 0.011371448636054993, 0.040227700024843216, 0.031143251806497574, -0.03314525634050369, -0.0...
0.830073
0.774435
0.055638
Please focus on the algorithm of this problem and provide code in Julia: Given an array `nums` of integers, a _move_ consists of choosing any element and **decreasing it by 1**. An array `A` is a _zigzag array_ if either: * Every even-indexed element is greater than adjacent elements, ie. `A[0] > A[1] < A[2] > A[3]...
dolphin
[ 0.006080523133277893, 0.028844153508543968, -0.025328421965241432, -0.024629075080156326, 0.04409031569957733, -0.012842083349823952, -0.045096296817064285, 0.044978998601436615, 0.01720329560339451, 0.0004230390186421573, 0.02130850777029991, 0.020121414214372635, -0.03642929717898369, -0...
0.844454
0.783822
0.060632
Please explain the following problem in detail and provide code in Objective-C: Given an array of integers `arr`, return `true` _if the number of occurrences of each value in the array is **unique** or_ `false` _otherwise_. **Example 1:** **Input:** arr = \[1,2,2,1,1,3\] **Output:** true **Explanation:** The value 1 ...
dolphin
[ 0.00870597641915083, 0.015852762386202812, -0.03239980340003967, -0.019653107970952988, 0.04802441596984863, -0.03155696764588356, -0.013439001515507698, 0.07617182284593582, 0.03142952919006348, -0.02447815239429474, 0.02100139856338501, -0.011884083040058613, -0.01474812999367714, -0.013...
0.830159
0.773
0.05716
Please explain the following problem in detail and provide code in Julia: You are given an integer array `nums` of length `n`, and an integer array `queries` of length `m`. Return _an array_ `answer` _of length_ `m` _where_ `answer[i]` _is the **maximum** size of a **subsequence** that you can take from_ `nums` _such ...
dolphin
[ 0.00495826406404376, 0.016606828197836876, -0.03531481698155403, -0.033424705266952515, 0.045680150389671326, -0.0017973140347748995, -0.019102543592453003, 0.06567976623773575, 0.03122985176742077, -0.006184086669236422, 0.021217109635472298, 0.02993570826947689, -0.030074145644903183, 0....
0.851587
0.793579
0.058008
Please write the following solution using c++: You are given a list of songs where the `ith` song has a duration of `time[i]` seconds. Return _the number of pairs of songs for which their total duration in seconds is divisible by_ `60`. Formally, we want the number of indices `i`, `j` such that `i < j` with `(time[i] ...
dolphin
[ 0.03133721649646759, 0.018804974853992462, -0.03711476922035217, -0.009059022180736065, 0.046857938170433044, -0.020801283419132233, -0.042486585676670074, 0.09182285517454147, 0.026285752654075623, -0.024348188191652298, 0.023873241618275642, 0.018291272222995758, -0.04557297006249428, -0...
0.829681
0.77555
0.054131
Please focus on the algorithm of this problem and provide code in c++: You are given a string `s` of length `n` where `s[i]` is either: * `'D'` means decreasing, or * `'I'` means increasing. A permutation `perm` of `n + 1` integers of all the integers in the range `[0, n]` is called a **valid permutation** if for...
dolphin
[ 0.002480246825143695, 0.008287030272185802, -0.01474714931100607, -0.03290499374270439, 0.03010449931025505, -0.027851471677422523, -0.02523602917790413, 0.10087350010871887, 0.031185347586870193, -0.011895237490534782, 0.03060411848127842, 0.036161962896585464, -0.03210055083036423, -0.01...
0.851244
0.789032
0.062211
Please write the following solution using C#: Given an `m x n` integers `matrix`, return _the length of the longest increasing path in_ `matrix`. From each cell, you can either move in four directions: left, right, up, or down. You **may not** move **diagonally** or move **outside the boundary** (i.e., wrap-around is ...
dolphin
[ 0.0189288929104805, 0.019204098731279373, -0.028930380940437317, -0.04113652557134628, 0.027765514329075813, -0.04721684381365776, -0.039910707622766495, 0.08014007657766342, 0.0456465482711792, -0.018655305728316307, 0.02563939057290554, 0.018074946478009224, -0.026348777115345, -0.035167...
0.832623
0.7766
0.056023
Please focus on the efficiency of this problem and provide code in python: Given an integer array `nums` and two integers `k` and `p`, return _the number of **distinct subarrays** which have **at most**_ `k` _elements divisible by_ `p`. Two arrays `nums1` and `nums2` are said to be **distinct** if: * They are of **...
dolphin
[ 0.0259504746645689, 0.030869612470269203, -0.038538865745067596, -0.013782390393316746, 0.02784501388669014, -0.02538956329226494, -0.030981188639998436, 0.0498313307762146, 0.025636667385697365, 0.0066787973046302795, 0.03567091375589371, 0.0224718376994133, -0.02873644232749939, 0.010227...
0.83966
0.779642
0.060018
Please focus on the functionality of this problem and provide code in Dart: You are given an array `nums` consisting of **positive** integers and an integer `k`. **Partition** the array into two ordered **groups** such that each element is in exactly **one** group. A partition is called great if the **sum** of element...
dolphin
[ 0.023613477125763893, 0.024822238832712173, -0.03196032717823982, -0.026757298037409782, 0.02760278806090355, -0.023728154599666595, -0.02491787262260914, 0.045809056609869, 0.029422162100672722, -0.010872195474803448, 0.025037776678800583, 0.014369823969900608, -0.027137845754623413, 0.00...
0.848322
0.793529
0.054793
Please explain the following problem in detail and provide code in Fortran: Given an integer array `nums` and an integer `k`, return _the number of pairs_ `(i, j)` _where_ `i < j` _such that_ `|nums[i] - nums[j]| == k`. The value of `|x|` is defined as: * `x` if `x >= 0`. * `-x` if `x < 0`. **Example 1:** **Inp...
dolphin
[ 0.016409242525696754, 0.03472999110817909, -0.03515516594052315, -0.021613486111164093, 0.03900675103068352, -0.014111303724348545, -0.02345644310116768, 0.06054799258708954, 0.04360620304942131, -0.01195948664098978, 0.025141041725873947, 0.027851520106196404, -0.03406962379813194, -0.005...
0.848995
0.790076
0.058919
Please focus on the efficiency of this problem and provide code in c++: You are given a **0-indexed** integer array `nums`. An index `i` is part of a **hill** in `nums` if the closest non-equal neighbors of `i` are smaller than `nums[i]`. Similarly, an index `i` is part of a **valley** in `nums` if the closest non-equa...
dolphin
[ 0.009361696429550648, 0.02965821884572506, -0.030710313469171524, -0.00912636797875166, 0.03271002322435379, -0.011221866123378277, -0.03623772785067558, 0.09775923192501068, 0.0327330082654953, -0.027520088478922844, 0.027777768671512604, 0.028103258460760117, -0.01782870478928089, -0.021...
0.850479
0.788118
0.062361
Please focus on the functionality of this problem and provide code in ANSI C: Given an `m x n` `matrix`, return _a new matrix_ `answer` _where_ `answer[row][col]` _is the_ _**rank** of_ `matrix[row][col]`. The **rank** is an **integer** that represents how large an element is compared to other elements. It is calculat...
dolphin
[ 0.0321531780064106, 0.02958042360842228, -0.029269276186823845, -0.045965153723955154, 0.04038558900356293, -0.027343010529875755, -0.021811803802847862, 0.07852084934711456, 0.0452444925904274, -0.020069103688001633, 0.013008837588131428, 0.016202375292778015, -0.04190266877412796, -0.013...
0.840682
0.782413
0.058269
Please write the following solution using Erlang: The **width** of a sequence is the difference between the maximum and minimum elements in the sequence. Given an array of integers `nums`, return _the sum of the **widths** of all the non-empty **subsequences** of_ `nums`. Since the answer may be very large, return it ...
dolphin
[ 0.009803663939237595, 0.01958674006164074, -0.01794959232211113, -0.03846022114157677, 0.049316126853227615, -0.006283430382609367, -0.04304252192378044, 0.04667174071073532, 0.0334114208817482, -0.014275598339736462, 0.039251647889614105, 0.04529997706413269, -0.038475606590509415, -0.005...
0.841546
0.785445
0.056101
Please write the following solution using Object Pascal: Given an array of positive integers `arr`, find a pattern of length `m` that is repeated `k` or more times. A **pattern** is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times **consecutively** without overlapping....
dolphin
[ 0.020164083689451218, 0.018845703452825546, -0.012419767677783966, -0.03766435757279396, 0.04814125597476959, -0.02963344380259514, -0.019497182220220566, 0.061862554401159286, 0.03650159761309624, -0.008244291879236698, 0.025607749819755554, 0.0013900358462706208, -0.019884934648871422, -...
0.84096
0.785783
0.055177
Please explain the following problem in detail and provide code in ANSI C: Given a string `s`, return _the length of the longest repeating substrings_. If no repeating substring exists, return `0`. **Example 1:** **Input:** s = "abcd " **Output:** 0 **Explanation:** There is no repeating substring. **Example 2:** ...
dolphin
[ 0.009314363822340965, 0.01832970790565014, -0.024870457127690315, -0.02887662500143051, 0.025496402755379677, -0.030671630054712296, -0.018763255327939987, 0.07286146283149719, 0.02224106341600418, -0.02036169171333313, 0.03649643063545227, 0.022315988317131996, -0.03134659677743912, -0.02...
0.82534
0.768319
0.057021
Please explain the following problem in detail and provide code in Objective-C: Given a digit string `s`, return _the number of **unique substrings** of_ `s` _where every digit appears the same number of times._ **Example 1:** **Input:** s = "1212 " **Output:** 5 **Explanation:** The substrings that meet the require...
dolphin
[ 0.005622927099466324, 0.01417766883969307, -0.03978864848613739, -0.026393752545118332, 0.03367922827601433, -0.042303651571273804, -0.01887274533510208, 0.06058802083134651, 0.011608458124101162, 0.007748571690171957, 0.030396632850170135, 0.013496983796358109, -0.03540864586830139, 0.001...
0.833814
0.780398
0.053416
Please explain the following problem in detail and provide code in ANSI C: The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`. * For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`. Given an integer array `nums`, choose four...
dolphin
[ 0.030317584052681923, 0.03806256875395775, -0.0175764337182045, -0.01950572244822979, 0.050592806190252304, -0.014299615286290646, -0.05608893930912018, 0.07087492942810059, 0.04065682366490364, -0.011380588635802269, 0.023302415385842323, 0.03813372552394867, -0.043319325894117355, -0.026...
0.846452
0.780219
0.066232
Please write the following solution using R: The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`. * For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`. Given an integer array `nums`, choose four **distinct** indices `w`, `x`...
dolphin
[ 0.02981879562139511, 0.037442948669195175, -0.02319282665848732, -0.021286502480506897, 0.05759711191058159, -0.006258848123252392, -0.06082526594400406, 0.05703179910778999, 0.04907248541712761, -0.00396775733679533, 0.011313529685139656, 0.03664079308509827, -0.03869670256972313, -0.0314...
0.839881
0.778481
0.0614
Please explain the reasoning behind the following solution and provide code in Scala: Given an integer array `nums`, find the **maximum** possible **bitwise OR** of a subset of `nums` and return _the **number of different non-empty subsets** with the maximum bitwise OR_. An array `a` is a **subset** of an array `b` if...
dolphin
[ 0.023479687049984932, 0.02638866938650608, -0.025199973955750465, 0.0004050015995744616, 0.03902885317802429, -0.03090367093682289, -0.02798694372177124, 0.04818548262119293, 0.03366357833147049, -0.02498464100062847, 0.034410715103149414, 0.028641676530241966, -0.027018172666430473, -0.00...
0.843562
0.787751
0.055811
Please focus on the functionality of this problem and provide code in PHP: Given an integer array `nums` of size `n`, return _the number with the value **closest** to_ `0` _in_ `nums`. If there are multiple answers, return _the number with the **largest** value_. **Example 1:** **Input:** nums = \[-4,-2,1,4,8\] **Out...
dolphin
[ 0.024178994819521904, 0.051512736827135086, -0.02472444623708725, -0.0168292373418808, 0.03779042512178421, -0.03822677955031395, -0.035498324781656265, 0.050748180598020554, 0.02990609221160412, -0.011887116357684135, 0.026415295898914337, 0.03118249960243702, -0.03283235803246498, -0.009...
0.832867
0.772422
0.060445
Please explain the reasoning behind the following solution and provide code in c++: Given a 2D integer array `circles` where `circles[i] = [xi, yi, ri]` represents the center `(xi, yi)` and radius `ri` of the `ith` circle drawn on a grid, return _the **number of lattice points**_ _that are present inside **at least one...
dolphin
[ -0.004630709066987038, 0.037007395178079605, -0.014151127077639103, -0.02978747896850109, 0.055476702749729156, -0.003659101901575923, -0.03996717184782028, 0.06885939836502075, 0.02250611037015915, -0.0004668349283747375, 0.024227438494563103, 0.03335132822394371, -0.01084692869335413, -0...
0.82578
0.771654
0.054126
Please explain the following problem in detail and provide code in R: Given a positive integer `n`, find the **pivot integer** `x` such that: * The sum of all elements between `1` and `x` inclusively equals the sum of all elements between `x` and `n` inclusively. Return _the pivot integer_ `x`. If no such integer e...
dolphin
[ 0.014794476330280304, 0.03270440548658371, -0.023047789931297302, -0.024726849049329758, 0.026098815724253654, -0.023312505334615707, -0.009485938586294651, 0.06043590232729912, 0.029238872230052948, -0.003376010339707136, 0.025941889733076096, 0.036617107689380646, -0.032805100083351135, ...
0.832537
0.777203
0.055334
Please explain the following problem in detail and provide code in Go: Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**. **Example 1:** **Input:** nums = \[4,6,7,7\] **Output:** \[\[...
dolphin
[ 0.0027764805126935244, 0.018178271129727364, -0.0013412252301350236, -0.025478066876530647, 0.040237076580524445, -0.017181970179080963, -0.03089446946978569, 0.0605727843940258, 0.05149804800748825, -0.004317521583288908, 0.03194829449057579, 0.02174360491335392, -0.048560138791799545, -0...
0.835602
0.780281
0.055321
Please focus on the efficiency of this problem and provide code in Perl: You are given a **0-indexed** integer array `nums` and a positive integer `k`. We call an index `i` **k-big** if the following conditions are satisfied: * There exist at least `k` different indices `idx1` such that `idx1 < i` and `nums[idx1] <...
dolphin
[ 0.01382410153746605, 0.04040473327040672, -0.031301356852054596, -0.03648851811885834, 0.02229928970336914, -0.0047382754273712635, -0.023919573053717613, 0.06524946540594101, 0.023769494146108627, -0.012112417258322239, 0.033820606768131256, 0.03599653020501137, -0.02784768119454384, -0.0...
0.843758
0.788863
0.054895
Please write the following solution using F#: You are given an array `nums` that consists of positive integers. The **GCD** of a sequence of numbers is defined as the greatest integer that divides **all** the numbers in the sequence evenly. * For example, the GCD of the sequence `[4,6,16]` is `2`. A **subsequence*...
dolphin
[ 0.02218465693295002, 0.022024070844054222, -0.008834091946482658, -0.04040328785777092, 0.039337340742349625, -0.029731960967183113, -0.024605385959148407, 0.05638548359274864, 0.03347861021757126, -0.020082376897335052, 0.020116573199629784, 0.01941322162747383, -0.04820766672492027, -0.0...
0.844337
0.786503
0.057835
Please focus on the efficiency of this problem and provide code in java: There is an undirected weighted connected graph. You are given a positive integer `n` which denotes that the graph has `n` nodes labeled from `1` to `n`, and an array `edges` where each `edges[i] = [ui, vi, weighti]` denotes that there is an edge ...
dolphin
[ 0.004377599805593491, 0.04110259190201759, -0.026364943012595177, -0.023689908906817436, 0.03174790367484093, -0.02731141448020935, -0.03341544792056084, 0.037383005023002625, 0.030098820105195045, -0.009176085703074932, 0.043042320758104324, 0.028753984719514847, -0.009587462991476059, -0...
0.846484
0.786562
0.059922
Please explain the following problem in detail and provide code in Scheme: You are given an `m x n` binary matrix `mat` of `1`'s (representing soldiers) and `0`'s (representing civilians). The soldiers are positioned **in front** of the civilians. That is, all the `1`'s will appear to the **left** of all the `0`'s in e...
dolphin
[ 0.04892459884285927, 0.03359990939497948, -0.03725595399737358, -0.04732680320739746, 0.05213984102010727, -0.04969392344355583, -0.01037910021841526, 0.06376232206821442, 0.04145966097712517, -0.004099234938621521, 0.015050157904624939, 0.009971960447728634, -0.050007324665784836, -0.0107...
0.837414
0.783404
0.054009
Please explain the reasoning behind the following solution and provide code in c++: You are given a **directed** graph of `n` nodes numbered from `0` to `n - 1`, where each node has **at most one** outgoing edge. The graph is represented with a given **0-indexed** array `edges` of size `n`, indicating that there is a ...
dolphin
[ 0.007772301789373159, 0.0305368360131979, -0.01666594296693802, -0.02835843339562416, 0.03208577260375023, -0.018183182924985886, -0.024134472012519836, 0.08460596203804016, 0.0385453999042511, -0.019639521837234497, 0.03194686025381088, 0.03409239649772644, -0.013631127774715424, -0.00418...
0.845128
0.789837
0.055292
Please write the following solution using Elixir: You are given an array of `n` pairs `pairs` where `pairs[i] = [lefti, righti]` and `lefti < righti`. A pair `p2 = [c, d]` **follows** a pair `p1 = [a, b]` if `b < c`. A **chain** of pairs can be formed in this fashion. Return _the length longest chain which can be for...
dolphin
[ 0.045209743082523346, 0.02834172546863556, -0.03664488345384598, -0.032391637563705444, 0.018079955130815506, -0.01268888358026743, -0.029661476612091064, 0.04835209250450134, 0.025462698191404343, -0.02487841621041298, 0.006850636098533869, 0.031075267121195793, -0.0182252898812294, -0.01...
0.843205
0.782613
0.060592
Please write the following solution using Dart: You are given a **directed** graph of `n` nodes numbered from `0` to `n - 1`, where each node has **at most one** outgoing edge. The graph is represented with a given **0-indexed** array `edges` of size `n`, indicating that there is a directed edge from node `i` to node ...
dolphin
[ 0.012632579542696476, 0.01351588312536478, -0.022735925391316414, -0.03699802979826927, 0.023906944319605827, -0.026045873761177063, -0.03316274285316467, 0.05745817720890045, 0.033334407955408096, -0.022225670516490936, 0.03166442736983299, 0.007562463637441397, -0.02094593271613121, -0.0...
0.838025
0.783102
0.054923
Please explain the following problem in detail and provide code in java: You are given an array `target` that consists of **distinct** integers and another integer array `arr` that **can** have duplicates. In one operation, you can insert any integer at any position in `arr`. For example, if `arr = [1,4,1,2]`, you can...
dolphin
[ 0.02399442531168461, 0.024217398837208748, -0.02970304898917675, -0.01599719002842903, 0.042370185256004333, 0.0006590878474526107, -0.0319325290620327, 0.05604013055562973, 0.03824600949883461, -0.021460168063640594, 0.020801350474357605, 0.007673116400837898, -0.025218650698661804, -0.02...
0.844958
0.787516
0.057443
Please explain the following problem in detail and provide code in Dart: Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_. **Example 1:** **Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\] **Output:**...
dolphin
[ -0.005044059827923775, 0.015671879053115845, -0.01767742447555065, -0.04704699292778969, 0.030708083882927895, -0.009591595269739628, -0.038160379976034164, 0.04015934094786644, 0.0504239983856678, -0.007161349058151245, 0.0002936485398095101, 0.029468515887856483, -0.004607904236763716, -...
0.834323
0.78054
0.053783
Please explain the reasoning behind the following solution and provide code in c++: You are given a **0-indexed** array of positive integers `nums`. Find the number of triplets `(i, j, k)` that meet the following conditions: * `0 <= i < j < k < nums.length` * `nums[i]`, `nums[j]`, and `nums[k]` are **pairwise dist...
dolphin
[ 0.004870305303484201, 0.014939981512725353, -0.018956463783979416, -0.02200683392584324, 0.05237049236893654, -0.0105940205976367, -0.033942822366952896, 0.0932522788643837, 0.024895334616303444, -0.0036404551938176155, 0.015292213298380375, 0.014317185617983341, -0.02998754195868969, -0.0...
0.839021
0.779784
0.059237
Please explain the following problem in detail and provide code in Object Pascal: You are given an integer array `nums` and two integers `limit` and `goal`. The array `nums` has an interesting property that `abs(nums[i]) <= limit`. Return _the minimum number of elements you need to add to make the sum of the array equ...
dolphin
[ 0.004992386791855097, 0.021078219637274742, -0.014930116944015026, -0.029498741030693054, 0.051270492374897, -0.018601829186081886, -0.01662338152527809, 0.04118693992495537, 0.045040782541036606, -0.010302790440618992, 0.00955383013933897, 0.03225545957684517, -0.03764454647898674, -0.015...
0.841651
0.787977
0.053674
Please write the following solution using Haskell: You are given an integer array `banned` and two integers `n` and `maxSum`. You are choosing some number of integers following the below rules: * The chosen integers have to be in the range `[1, n]`. * Each integer can be chosen **at most once**. * The chosen int...
dolphin
[ 0.04311893507838249, 0.02773074060678482, -0.023965250700712204, -0.026096614077687263, 0.04300814867019653, -0.034624312072992325, -0.03594498708844185, 0.03439747542142868, 0.03306654840707779, -0.008352995850145817, 0.012798931449651718, 0.03667271509766579, -0.036740947514772415, -0.02...
0.83782
0.783029
0.054791
Please focus on the algorithm of this problem and provide code in java: There is an undirected tree with `n` nodes labeled from `0` to `n - 1`. You are given the integer `n` and a 2D integer array `edges` of length `n - 1`, where `edges[i] = [ai, bi]` indicates that there is an edge between nodes `ai` and `bi` in the t...
dolphin
[ -0.002617359859868884, 0.022423049435019493, -0.03169988468289375, -0.01368145551532507, 0.019463302567601204, -0.02867867238819599, -0.00770933274179697, 0.04738287627696991, 0.02115970104932785, -0.009230085648596287, 0.0512702576816082, 0.013431034050881863, -0.02053697593510151, -0.009...
0.845267
0.784176
0.061091
Please write the following solution using Visual Basic .NET: You are given an integer `n` and an integer `start`. Define an array `nums` where `nums[i] = start + 2 * i` (**0-indexed**) and `n == nums.length`. Return _the bitwise XOR of all elements of_ `nums`. **Example 1:** **Input:** n = 5, start = 0 **Output:** ...
dolphin
[ 0.02866898849606514, 0.030360855162143707, -0.04108770564198494, -0.017794346436858177, 0.023888498544692993, -0.03805648162961006, -0.012342155911028385, 0.08578810840845108, 0.04335862025618553, -0.015441457740962505, 0.026179928332567215, 0.0246948953717947, -0.060424044728279114, -0.03...
0.837428
0.782114
0.055314
Please write the following solution using Haskell: You have two types of tiles: a `2 x 1` domino shape and a tromino shape. You may rotate these shapes. Given an integer n, return _the number of ways to tile an_ `2 x n` _board_. Since the answer may be very large, return it **modulo** `109 + 7`. In a tiling, every sq...
dolphin
[ 0.03229452669620514, 0.01773916371166706, -0.01603814586997032, -0.02595367655158043, 0.025256158784031868, -0.019075894728302956, -0.014324909076094627, 0.046766068786382675, 0.014287512749433517, -0.006489940453320742, 0.03639766946434975, 0.051185060292482376, -0.03411916270852089, -0.0...
0.83052
0.776672
0.053848
Please write the following solution using Objective-C: Given an integer array `nums`, return _the largest perimeter of a triangle with a non-zero area, formed from three of these lengths_. If it is impossible to form any triangle of a non-zero area, return `0`. **Example 1:** **Input:** nums = \[2,1,2\] **Output:** 5...
dolphin
[ 0.022181136533617973, 0.04439658671617508, -0.02728307619690895, -0.02771802991628647, 0.0345437191426754, -0.011001252569258213, -0.030264249071478844, 0.072292760014534, 0.022616028785705566, -0.007710145320743322, 0.0406220443546772, 0.047820162028074265, -0.032301563769578934, -0.03149...
0.829218
0.774663
0.054555
Please explain the following problem in detail and provide code in Swift: You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Return _the single element that appears only once_. Your solution must run in `O(log n)` time...
dolphin
[ 0.012220240198075771, 0.03206606209278107, -0.019694197922945023, -0.022953826934099197, 0.03202096000313759, -0.02288874424993992, -0.03799375146627426, 0.06517235934734344, 0.03388897329568863, -0.006456142291426659, 0.025801362469792366, -0.005948707927018404, -0.024969222024083138, -0....
0.843586
0.789795
0.053791
Please write the following solution using Dart: You are given an array `nums` consisting of positive integers. Split the array into **one or more** disjoint subarrays such that: * Each element of the array belongs to **exactly one** subarray, and * The **GCD** of the elements of each subarray is strictly greater ...
dolphin
[ 0.01811322197318077, 0.0339108444750309, -0.013294834643602371, -0.02917311154305935, 0.039178285747766495, -0.015528960153460503, -0.032653938978910446, 0.05763766169548035, 0.030688513070344925, -0.0031170672737061977, 0.010925836861133575, 0.014651927165687084, -0.01755104400217533, -0....
0.848828
0.792559
0.056269
Please write the following solution using Mojo: Given an array of `n` integers `nums`, a **132 pattern** is a subsequence of three integers `nums[i]`, `nums[j]` and `nums[k]` such that `i < j < k` and `nums[i] < nums[k] < nums[j]`. Return `true` _if there is a **132 pattern** in_ `nums`_, otherwise, return_ `false`_._...
dolphin
[ 0.018001040443778038, 0.015824217349290848, -0.025161396712064743, -0.02356901578605175, 0.038798145949840546, -0.012279415503144264, -0.01787922903895378, 0.06122361123561859, 0.02199569158256054, 0.013184281066060066, 0.011998437345027924, 0.02342243492603302, -0.019014019519090652, -0.0...
0.841222
0.785542
0.05568
Please write the following solution using Dart: Given an integer array `nums` of length `n`, return `true` if there is a triplet `(i, j, k)` which satisfies the following conditions: * `0 < i, i + 1 < j, j + 1 < k < n - 1` * The sum of subarrays `(0, i - 1)`, `(i + 1, j - 1)`, `(j + 1, k - 1)` and `(k + 1, n - 1)`...
dolphin
[ 0.006190776359289885, 0.01962898299098015, -0.024290116503834724, -0.036398131400346756, 0.04978443309664726, -0.0123831108212471, -0.015075086615979671, 0.06678178906440735, 0.018950708210468292, -0.012245341204106808, 0.011777843348681927, 0.025164494290947914, -0.029643388465046883, -0....
0.851431
0.796006
0.055425
Please explain the reasoning behind the following solution and provide code in Scheme: Given an integer array `nums` that may contain duplicates, return _all possible_ _subsets_ _(the power set)_. The solution set **must not** contain duplicate subsets. Return the solution in **any order**. **Example 1:** **Input:**...
dolphin
[ 0.04360972344875336, 0.027053292840719223, -0.014916433952748775, -0.01691211573779583, 0.04480231925845146, -0.04402852803468704, -0.012112826108932495, 0.04722872003912926, 0.0520482212305069, -0.026824742555618286, 0.03500421717762947, 0.022180180996656418, -0.04523583501577377, -0.0272...
0.840588
0.783506
0.057081
Please focus on the functionality of this problem and provide code in ANSI C: A digit string is **good** if the digits **(0-indexed)** at **even** indices are **even** and the digits at **odd** indices are **prime** (`2`, `3`, `5`, or `7`). * For example, `"2582 "` is good because the digits (`2` and `8`) at even po...
dolphin
[ 0.009542984887957573, 0.006572761572897434, -0.02759576216340065, -0.04321394860744476, 0.01745748147368431, -0.04725740849971771, -0.02849629893898964, 0.057430628687143326, 0.014738939702510834, -0.011205032467842102, 0.013008082285523415, 0.02283857949078083, -0.04270119220018387, -0.03...
0.838294
0.779956
0.058338
Please write the following solution using Haskell: Given an integer array `nums` of length `n`, return `true` if there is a triplet `(i, j, k)` which satisfies the following conditions: * `0 < i, i + 1 < j, j + 1 < k < n - 1` * The sum of subarrays `(0, i - 1)`, `(i + 1, j - 1)`, `(j + 1, k - 1)` and `(k + 1, n - ...
dolphin
[ 0.013429030776023865, 0.017384065315127373, -0.022915270179510117, -0.03436413034796715, 0.059616636484861374, -0.019936449825763702, -0.003836468094959855, 0.06131111830472946, 0.018118737265467644, -0.012161972932517529, 0.012762485072016716, 0.027309028431773186, -0.02903643064200878, -...
0.84859
0.792572
0.056018
Please explain the following problem in detail and provide code in Groovy: Given an array of integers `arr` and an integer `k`. Find the _least number of unique integers_ after removing **exactly** `k` elements**.** **Example 1:** **Input:** arr = \[5,5,4\], k = 1 **Output:** 1 **Explanation**: Remove the single 4, o...
dolphin
[ 0.021930459886789322, 0.0429936908185482, -0.02122555486857891, -0.0411844439804554, 0.05165623128414154, -0.042628202587366104, -0.014466390945017338, 0.04260770231485367, 0.0517956018447876, -0.018304472789168358, 0.026110362261533737, -0.003051769221201539, -0.001151358475908637, 0.0062...
0.843662
0.788971
0.05469
Please focus on the functionality of this problem and provide code in java: Alice and Bob continue their games with piles of stones. There are a number of piles **arranged in a row**, and each pile has a positive integer number of stones `piles[i]`. The objective of the game is to end with the most stones. Alice and B...
dolphin
[ 0.04654131457209587, 0.01583687774837017, -0.035925596952438354, -0.023277562111616135, 0.013033697381615639, -0.04402772709727287, -0.02135017327964306, 0.034556496888399124, 0.028981925919651985, -0.029296964406967163, 0.03296281024813652, 0.03266023099422455, -0.032277725636959076, -0.0...
0.839087
0.777308
0.061779
Please explain the following problem in detail and provide code in Go: You are given an integer array `nums`. The **range** of a subarray of `nums` is the difference between the largest and smallest element in the subarray. Return _the **sum of all** subarray ranges of_ `nums`_._ A subarray is a contiguous **non-empt...
dolphin
[ -0.0008378237835131586, 0.030520085245370865, -0.03093620389699936, -0.028391074389219284, 0.05064636468887329, -0.021439291536808014, -0.04641982540488243, 0.04315135255455971, 0.042367517948150635, 0.0038330673705786467, 0.025642016902565956, 0.04074803367257118, -0.05040804296731949, -0...
0.830757
0.777333
0.053424
Please focus on the functionality of this problem and provide code in ANSI C: Given an integer array `nums` and an integer `k`, return _the number of pairs_ `(i, j)` _where_ `i < j` _such that_ `|nums[i] - nums[j]| == k`. The value of `|x|` is defined as: * `x` if `x >= 0`. * `-x` if `x < 0`. **Example 1:** **I...
dolphin
[ 0.018965700641274452, 0.033147700130939484, -0.034388378262519836, -0.012349063530564308, 0.030190465971827507, -0.01790902204811573, -0.03623593598604202, 0.06992378830909729, 0.04286406189203262, -0.02241593785583973, 0.02809797413647175, 0.016259394586086273, -0.04191303625702858, -0.00...
0.852187
0.782955
0.069231
Please write the following solution using Scheme: You are given two **0-indexed** integer arrays `nums1` and `nums2` of length `n`. A range `[l, r]` (**inclusive**) where `0 <= l <= r < n` is **balanced** if: * For every `i` in the range `[l, r]`, you pick either `nums1[i]` or `nums2[i]`. * The sum of the numbers...
dolphin
[ 0.02695383131504059, 0.01819184049963951, -0.04052154719829559, -0.027341695502400398, 0.04802589491009712, -0.01628064550459385, -0.03225577622652054, 0.05597303435206413, 0.03668816387653351, -0.023975204676389694, 0.017984401434659958, 0.03683464229106903, -0.038210850208997726, -0.0192...
0.850415
0.783838
0.066577
Please write the following solution using Perl: Given an integer array `nums` of size `n`, return _the minimum number of moves required to make all array elements equal_. In one move, you can increment `n - 1` elements of the array by `1`. **Example 1:** **Input:** nums = \[1,2,3\] **Output:** 3 **Explanation:** Onl...
dolphin
[ 0.021394360810518265, 0.010930349119007587, -0.031215423718094826, -0.03855493292212486, 0.03521411120891571, -0.018424557521939278, -0.010379013605415821, 0.0660495012998581, 0.03023848496377468, -0.032054491341114044, 0.036124344915151596, 0.026529930531978607, -0.03986137732863426, -0.0...
0.854549
0.798828
0.055721
Please focus on the algorithm of this problem and provide code in R: You are given an integer array `nums` and an integer `k`. Find the **largest even sum** of any subsequence of `nums` that has a length of `k`. Return _this sum, or_ `-1` _if such a sum does not exist_. A **subsequence** is an array that can be deriv...
dolphin
[ 0.014624660834670067, 0.03240594267845154, -0.022139208391308784, -0.046006299555301666, 0.026882354170084, -0.011358003132045269, -0.029467832297086716, 0.06407041847705841, 0.03233621269464493, -0.010614415630698204, 0.01375296525657177, 0.036293357610702515, -0.03754400834441185, 0.0038...
0.829008
0.773912
0.055096
Please focus on the algorithm of this problem and provide code in Visual Basic .NET: There are two mice and `n` different types of cheese, each type of cheese should be eaten by exactly one mouse. A point of the cheese with index `i` (**0-indexed**) is: * `reward1[i]` if the first mouse eats it. * `reward2[i]` if...
dolphin
[ 0.007740858010947704, 0.02815888449549675, -0.01311348658055067, -0.02228406071662903, 0.01783313788473606, -0.014319188892841339, -0.019242389127612114, 0.07440169900655746, 0.03034101240336895, -0.024308517575263977, 0.03287523239850998, 0.03556272014975548, -0.04070420563220978, -0.0145...
0.847453
0.793579
0.053874
Please write the following solution using Mojo: Given an array of positive integers `arr` (not necessarily distinct), return _the_ _lexicographically_ _largest permutation that is smaller than_ `arr`, that can be **made with exactly one swap**. If it cannot be done, then return the same array. **Note** that a _swap_ e...
dolphin
[ 0.028330327942967415, 0.04324977472424507, -0.012331537902355194, -0.0319596491754055, 0.034992434084415436, -0.02859044447541237, -0.0390506349503994, 0.04346266761422157, 0.03717843070626259, -0.04083690792322159, 0.02686627022922039, 0.005080720875412226, -0.03434792533516884, -0.023909...
0.833698
0.776381
0.057317
Please write the following solution using python: You are given a **positive** integer `n`. We call an integer `k` fair if the number of **even** digits in `k` is equal to the number of **odd** digits in it. Return _the **smallest** fair integer that is **greater than or equal** to_ `n`. **Example 1:** **Input:** n...
dolphin
[ 0.007576751988381147, 0.03043861873447895, -0.020426522940397263, -0.04769013822078705, 0.022509047761559486, -0.024773212149739265, -0.02757132612168789, 0.0489666573703289, 0.036090187728405, -0.011931873857975006, 0.03078683465719223, 0.030078314244747162, -0.03895309194922447, -0.02661...
0.827924
0.771097
0.056827
Please focus on the functionality of this problem and provide code in javascript: There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down ...
dolphin
[ 0.007493844721466303, 0.026506677269935608, -0.018536236137151718, -0.02264556847512722, 0.026616018265485764, -0.012877227738499641, -0.025231337174773216, 0.053299326449632645, 0.03691441938281059, -0.01699919067323208, 0.0223807655274868, 0.04227164015173912, -0.02315727435052395, -0.03...
0.846491
0.792836
0.053655
Please write the following solution using python: Given an integer array `arr`, return _the number of distinct bitwise ORs of all the non-empty subarrays of_ `arr`. The bitwise OR of a subarray is the bitwise OR of each integer in the subarray. The bitwise OR of a subarray of one integer is that integer. A **subarray...
dolphin
[ 0.023472048342227936, 0.027659034356474876, -0.03935423493385315, -0.0007279408746398985, 0.029767107218503952, -0.0378694012761116, -0.041947368532419205, 0.043198112398386, 0.04076206311583519, -0.011389566585421562, 0.02350323460996151, -0.0052779670804739, -0.03270424157381058, -0.0128...
0.833328
0.771031
0.062297
Please explain the following problem in detail and provide code in c++: You are given a **0-indexed** `m x n` **binary** matrix `grid`. In one operation, you can choose any `i` and `j` that meet the following conditions: * `0 <= i < m` * `0 <= j < n` * `grid[i][j] == 1` and change the values of **all** cells i...
dolphin
[ -0.001727269496768713, 0.028651129454374313, -0.010251836851239204, -0.043413255363702774, 0.05960846692323685, -0.03629371151328087, -0.03287096694111824, 0.09881512075662613, 0.04075658321380615, -0.018834717571735382, 0.00010207679588347673, 0.004640970844775438, -0.017209406942129135, ...
0.833568
0.780335
0.053233
Please write the following solution using javascript: You are given an integer array `nums`. We call a subset of `nums` **good** if its product can be represented as a product of one or more **distinct prime** numbers. * For example, if `nums = [1, 2, 3, 4]`: * `[2, 3]`, `[1, 2, 3]`, and `[1, 3]` are **good** ...
dolphin
[ 0.03381437435746193, 0.013079955242574215, -0.03625358268618584, -0.028370581567287445, 0.037500325590372086, -0.029311437159776688, -0.02477365732192993, 0.046054258942604065, 0.04396248236298561, -0.012338039465248585, 0.02903725579380989, 0.015575869008898735, -0.03628618270158768, -0.0...
0.843937
0.789624
0.054314
Please focus on the algorithm of this problem and provide code in Kotlin: Given an integer array `nums` and a positive integer `k`, return _the most **competitive** subsequence of_ `nums` _of size_ `k`. An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array. We...
dolphin
[ 0.005411802791059017, 0.03676283732056618, -0.007070498075336218, -0.018413415178656578, 0.03642827272415161, -0.018429160118103027, -0.02609946019947529, 0.05426941066980362, 0.03831496089696884, -0.02291928604245186, 0.019512921571731567, 0.03036274015903473, -0.03627395257353783, -0.000...
0.843821
0.786344
0.057476
Please write the following solution using Objective-C: You are given an **even** number of people `numPeople` that stand around a circle and each person shakes hands with someone else so that there are `numPeople / 2` handshakes total. Return _the number of ways these handshakes could occur such that none of the hands...
dolphin
[ 0.03522961214184761, 0.022357042878866196, -0.03248671442270279, -0.02500680834054947, 0.03398873656988144, -0.0212126262485981, -0.03078557178378105, 0.034804947674274445, 0.0219355970621109, -0.03688229247927666, 0.03644938766956329, 0.0364408865571022, -0.024569811299443245, -0.03847654...
0.830779
0.772484
0.058295
Please write the following solution using javascript: You are given an integer array `arr` of length `n` that represents a permutation of the integers in the range `[0, n - 1]`. We split `arr` into some number of **chunks** (i.e., partitions), and individually sort each chunk. After concatenating them, the result shou...
dolphin
[ 0.05298188328742981, 0.029631244018673897, -0.015542255714535713, -0.012288292869925499, 0.028856249526143074, -0.0144027229398489, -0.035675033926963806, 0.03555545210838318, 0.01921684294939041, -0.014359144493937492, 0.01746838167309761, 0.012220906093716621, -0.03610377758741379, -0.00...
0.847253
0.783168
0.064085
Please write the following solution using Visual Basic .NET: Given an integer array `arr`, return _the length of a maximum size turbulent subarray of_ `arr`. A subarray is **turbulent** if the comparison sign flips between each adjacent pair of elements in the subarray. More formally, a subarray `[arr[i], arr[i + 1],...
dolphin
[ 0.014913477934896946, 0.03141989931464195, -0.027999229729175568, -0.025982320308685303, 0.03168965131044388, -0.03000052273273468, -0.03778865933418274, 0.06911872327327728, 0.03321800380945206, -0.013079022988677025, 0.027186047285795212, 0.015692297369241714, -0.039359115064144135, -0.0...
0.847035
0.79177
0.055265
Please write the following solution using Scheme: For a string `sequence`, a string `word` is **`k`\-repeating** if `word` concatenated `k` times is a substring of `sequence`. The `word`'s **maximum `k`\-repeating value** is the highest value `k` where `word` is `k`\-repeating in `sequence`. If `word` is not a substrin...
dolphin
[ 0.03174201771616936, 0.007922779768705368, -0.008341873064637184, -0.01994369737803936, 0.028557274490594864, -0.02281058207154274, -0.016776813194155693, 0.05368701368570328, 0.026157602667808533, -0.02181590348482132, 0.026235150173306465, 0.0193940456956625, -0.026224300265312195, 0.003...
0.837605
0.779714
0.057891
Please focus on the functionality of this problem and provide code in Groovy: You are given a **0-indexed** integer array `nums` consisting of `3 * n` elements. You are allowed to remove any **subsequence** of elements of size **exactly** `n` from `nums`. The remaining `2 * n` elements will be divided into two **equal...
dolphin
[ 0.013625171035528183, 0.01965411566197872, -0.03313388675451279, -0.03214167058467865, 0.04179082438349724, -0.033461373299360275, -0.02467276342213154, 0.05585671216249466, 0.04225190356373787, -0.025775887072086334, 0.02818944863975048, 0.02822015807032585, -0.030708109959959984, -0.0013...
0.850893
0.795854
0.055039
Please focus on the functionality of this problem and provide code in java: Given two non-negative integers `low` and `high`. Return the _count of odd numbers between_ `low` _and_ `high` _(inclusive)_. **Example 1:** **Input:** low = 3, high = 7 **Output:** 3 **Explanation:** The odd numbers between 3 and 7 are \[3,5...
dolphin
[ 0.01099561620503664, 0.01778334751725197, -0.03394518047571182, -0.0234025027602911, 0.02723710983991623, -0.004138500429689884, -0.03606376424431801, 0.05179775878787041, 0.022579018026590347, -0.01863813027739525, 0.022708943113684654, 0.020937616005539894, -0.01883772201836109, -0.01654...
0.83041
0.773687
0.056723
Please explain the following problem in detail and provide code in ANSI C: A split of an integer array is **good** if: * The array is split into three **non-empty** contiguous subarrays - named `left`, `mid`, `right` respectively from left to right. * The sum of the elements in `left` is less than or equal to the ...
dolphin
[ 0.02620459534227848, 0.020456736907362938, -0.03523089736700058, -0.02609572373330593, 0.03400971367955208, -0.012242435477674007, -0.03820464015007019, 0.07241242378950119, 0.022904960438609123, -0.009570970200002193, 0.020534681156277657, 0.028094854205846786, -0.04645562544465065, -0.03...
0.844005
0.781181
0.062823
Please explain the following problem in detail and provide code in Groovy: You are given an integer array `nums` of size `n`. Consider a **non-empty** subarray from `nums` that has the **maximum** possible **bitwise AND**. * In other words, let `k` be the maximum value of the bitwise AND of **any** subarray of `num...
dolphin
[ 0.013447649776935577, 0.018388090655207634, -0.02555645816028118, -0.020945163443684578, 0.02991284616291523, -0.03527811914682388, -0.03443080186843872, 0.033254023641347885, 0.03497111052274704, -0.01803571730852127, 0.037490908056497574, 0.04845837131142616, -0.031789977103471756, 0.012...
0.835692
0.78098
0.054711
Please explain the following problem in detail and provide code in c++: Given a binary tree `root`, a node _X_ in the tree is named **good** if in the path from root to _X_ there are no nodes with a value _greater than_ X. Return the number of **good** nodes in the binary tree. **Example 1:** **Input:** root = \[3,1...
dolphin
[ 0.03126903995871544, 0.0051517304964363575, -0.028477562591433525, -0.03121800720691681, 0.02993035688996315, -0.03575335815548897, -0.024110695347189903, 0.08824074268341064, 0.03706261143088341, -0.018189791589975357, 0.026962053030729294, 0.02720450609922409, -0.0327899195253849, -0.011...
0.837146
0.779783
0.057363