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 write the following solution using Scheme: Given a **0-indexed** integer array `nums`, return _the **smallest** index_ `i` _of_ `nums` _such that_ `i mod 10 == nums[i]`_, or_ `-1` _if such index does not exist_. `x mod y` denotes the **remainder** when `x` is divided by `y`. **Example 1:** **Input:** nums = \...
dolphin
[ 0.02797490358352661, 0.04463203623890877, -0.018422191962599754, -0.0176534466445446, 0.04341742396354675, -0.04010879248380661, -0.028174519538879395, 0.050928909331560135, 0.025937741622328758, -0.021662214770913124, 0.021666783839464188, 0.009534892626106739, -0.03292512893676758, -0.01...
0.847555
0.790213
0.057342
Please explain the following problem in detail and provide code in Objective-C: Given an integer array `nums`, return _the largest integer that only occurs once_. If no integer occurs once, return `-1`. **Example 1:** **Input:** nums = \[5,7,3,9,4,9,8,3,1\] **Output:** 8 **Explanation:** The maximum integer in the ar...
dolphin
[ 0.024200493469834328, 0.03593243286013603, -0.029744602739810944, -0.024520056322216988, 0.03349579498171806, -0.03217056021094322, -0.028857937082648277, 0.066656194627285, 0.0188871081918478, -0.017618197947740555, 0.03841768950223923, 0.012348645366728306, -0.03557666391134262, -0.00376...
0.836543
0.776473
0.06007
Please focus on the functionality of this problem and provide code in R: 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 -...
dolphin
[ 0.007523966021835804, 0.027267463505268097, -0.039685286581516266, -0.028705446049571037, 0.048735830932855606, -0.009669017978012562, -0.015201644040644169, 0.07127916812896729, 0.013804922811686993, -0.006857545115053654, 0.004888415802270174, 0.029513485729694366, -0.031907014548778534, ...
0.845413
0.790961
0.054452
Please explain the reasoning behind the following solution and provide code in Kotlin: Given two integers `n` and `k`, return _the_ `kth` _lexicographically smallest integer in the range_ `[1, n]`. **Example 1:** **Input:** n = 13, k = 2 **Output:** 10 **Explanation:** The lexicographical order is \[1, 10, 11, 12, 13...
dolphin
[ 0.02732892520725727, 0.04672043025493622, -0.019746530801057816, -0.04394609108567238, 0.055668797343969345, -0.026671461760997772, -0.017728891223669052, 0.04148990660905838, 0.024812472984194756, -0.012898208573460579, 0.023883961141109467, 0.02962658740580082, -0.0237510297447443, 0.002...
0.83335
0.778594
0.054755
Please explain the reasoning behind the following solution and provide code in javascript: You are given an integer array `nums` and an integer `k`. Append `k` **unique positive** integers that do **not** appear in `nums` to `nums` such that the resulting total sum is **minimum**. Return _the sum of the_ `k` _integers...
dolphin
[ 0.0018796497024595737, 0.028893709182739258, -0.027570772916078568, -0.01673945039510727, 0.05622495338320732, -0.018878066912293434, -0.015110602602362633, 0.04959255829453468, 0.04250246658921242, -0.008815229870378971, 0.024761119857430458, 0.009667301550507545, -0.025916574522852898, 0...
0.843476
0.789303
0.054173
Please explain the reasoning behind the following solution and provide code in PHP: You are given an array `nums` consisting of positive integers. Starting with `score = 0`, apply the following algorithm: * Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the small...
dolphin
[ 0.021703548729419708, 0.04295175522565842, -0.022884005680680275, -0.023975975811481476, 0.043185360729694366, -0.014246325939893723, -0.027370281517505646, 0.06857239454984665, 0.035314276814460754, -0.0010840104660019279, 0.0229306910187006, 0.020886676385998726, -0.02607850357890129, -0...
0.854629
0.795652
0.058976
Please focus on the algorithm of this problem and provide code in ANSI C: Given the `root` of a **complete** binary tree, return the number of the nodes in the tree. According to **[Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees)**, every level, except possibly the last, is completely filled...
dolphin
[ 0.0261069368571043, 0.046454109251499176, -0.03347726911306381, -0.029909847304224968, 0.024522537365555763, -0.05218596011400223, -0.00811447761952877, 0.07425009459257126, 0.0279239509254694, -0.01929200068116188, 0.032474927604198456, 0.02200852334499359, -0.036303531378507614, -0.01573...
0.830373
0.774631
0.055742
Please focus on the functionality of this problem and provide code in Groovy: You are given an integer array `arr`. In one move, you can select a **palindromic** subarray `arr[i], arr[i + 1], ..., arr[j]` where `i <= j`, and remove that subarray from the given array. Note that after removing a subarray, the elements o...
dolphin
[ 0.01730612851679325, 0.02631918340921402, -0.0318836010992527, -0.03149649500846863, 0.037712886929512024, -0.024017756804823875, -0.023742228746414185, 0.04531353339552879, 0.04820217192173004, -0.012164446525275707, 0.027765396982431412, 0.014767182059586048, -0.020142294466495514, -0.01...
0.844085
0.785799
0.058286
Please explain the following problem in detail and provide code in Elixir: You are given an array `nums` of positive integers and a **positive** integer `k`. A subset of `nums` is **beautiful** if it does not contain two integers with an absolute difference equal to `k`. Return _the number of **non-empty beautiful** ...
dolphin
[ 0.012956314720213413, 0.04517647624015808, -0.023064754903316498, -0.03526279702782631, 0.037889838218688965, -0.03010542318224907, -0.032185427844524384, 0.035698745399713516, 0.043856944888830185, -0.0032948062289506197, 0.03147755190730095, 0.028700469061732292, -0.02642408385872841, 0....
0.849203
0.794318
0.054884
Please explain the following problem in detail and provide code in Mojo: Given two integers `n` and `k`, return _the_ `kth` _lexicographically smallest integer in the range_ `[1, n]`. **Example 1:** **Input:** n = 13, k = 2 **Output:** 10 **Explanation:** The lexicographical order is \[1, 10, 11, 12, 13, 2, 3, 4, 5, ...
dolphin
[ 0.03287404775619507, 0.05231055989861488, -0.024254659190773964, -0.04414857178926468, 0.053375404328107834, -0.027155600488185883, -0.017910396680235863, 0.040777385234832764, 0.028699107468128204, -0.007261286489665508, 0.03510325774550438, 0.020012980327010155, -0.027065781876444817, -0...
0.833774
0.776193
0.057581
Please write the following solution using ANSI C: You are given a **0-indexed** string `s` consisting of only lowercase English letters. Return _the number of **substrings** in_ `s` _that begin and end with the **same** character._ A **substring** is a contiguous non-empty sequence of characters within a string. **Ex...
dolphin
[ 0.013895101845264435, 0.019914325326681137, -0.014670217409729958, -0.044152140617370605, 0.045077547430992126, -0.022660283371806145, -0.019564537331461906, 0.07038217782974243, 0.022334257140755653, -0.02016344480216503, 0.03363798186182976, 0.008255323395133018, -0.044453348964452744, -...
0.832159
0.777661
0.054498
Please focus on the efficiency of this problem and provide code in Scheme: 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 su...
dolphin
[ 0.02819715067744255, 0.03861755505204201, -0.021110977977514267, -0.020508965477347374, 0.03492675721645355, -0.01962820068001747, -0.034385643899440765, 0.05385648459196091, 0.028192689642310143, -0.003209462156519294, 0.013365178368985653, 0.010786406695842743, -0.021875472739338875, -0....
0.849481
0.789106
0.060375
Please focus on the efficiency of this problem and provide code in Groovy: You are given an integer array `nums` of length `n` where `nums` is a permutation of the numbers in the range `[0, n - 1]`. You should build a set `s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... }` subjected to the following rule: * ...
dolphin
[ 0.02425185777246952, 0.023929070681333542, -0.028299527242779732, -0.015134889632463455, 0.02668972685933113, -0.03913578763604164, -0.03783043473958969, 0.04627551883459091, 0.039140067994594574, -0.021799882873892784, 0.029754316434264183, 0.02275186777114868, -0.02812635526061058, -0.00...
0.851282
0.792328
0.058954
Please write the following solution using Mojo: You are given two positive integers `n` and `target`. An integer is considered **beautiful** if the sum of its digits is less than or equal to `target`. Return the _minimum **non-negative** integer_ `x` _such that_ `n + x` _is beautiful_. The input will be generated suc...
dolphin
[ 0.024510065093636513, 0.037685178220272064, -0.02843119017779827, -0.048001278191804886, 0.05285158008337021, -0.027750976383686066, -0.03404766693711281, 0.05324761942028999, 0.035089559853076935, -0.003036268288269639, 0.029510874301195145, 0.04597020894289017, -0.040819112211465836, -0....
0.844135
0.790361
0.053774
Please write the following solution using Julia: Given a `m x n` matrix `grid` which is sorted in non-increasing order both row-wise and column-wise, return _the number of **negative** numbers in_ `grid`. **Example 1:** **Input:** grid = \[\[4,3,2,-1\],\[3,2,1,-1\],\[1,1,-1,-2\],\[-1,-1,-2,-3\]\] **Output:** 8 **Expl...
dolphin
[ 0.0011949078179895878, -0.004658881574869156, -0.03448696434497833, -0.042107902467250824, 0.038571156561374664, -0.040745001286268234, -0.0338200181722641, 0.05578499659895897, 0.03670741990208626, -0.006181743927299976, -0.008469685912132263, 0.02224569208920002, -0.04757264256477356, -0...
0.836985
0.777909
0.059075
Please explain the following problem in detail and provide code in Elixir: Given an integer array `nums` and an integer `k`, return `true` if it is possible to divide this array into `k` non-empty subsets whose sums are all equal. **Example 1:** **Input:** nums = \[4,3,2,3,5,2,1\], k = 4 **Output:** true **Explanatio...
dolphin
[ 0.016315806657075882, 0.025235826149582863, -0.027295824140310287, -0.0407925546169281, 0.04490599408745766, -0.02171499840915203, 0.008142256177961826, 0.05738033354282379, 0.01747986301779747, -0.007500010076910257, 0.028342505916953087, 0.01746043935418129, -0.022635221481323242, -0.003...
0.838704
0.780104
0.058601
Please focus on the functionality of this problem and provide code in ANSI C: You are given a **0-indexed** array of positive integers `nums`. A triplet of three **distinct** indices `(i, j, k)` is called a **single divisor triplet** of `nums` if `nums[i] + nums[j] + nums[k]` is divisible by **exactly one** of `nums[i]...
dolphin
[ 0.016572101041674614, 0.03928574174642563, -0.022377844899892807, -0.022990403696894646, 0.04260510951280594, -0.030206769704818726, -0.03992745652794838, 0.07312492281198502, 0.02021506428718567, -0.009182429872453213, 0.028525281697511673, 0.008514700457453728, -0.03147120028734207, -0.0...
0.833788
0.776532
0.057256
Please focus on the functionality of this problem and provide code in PHP: Given an integer array `nums` and an integer `k`, return _the number of **subarrays** of_ `nums` _where the greatest common divisor of the subarray's elements is_ `k`. A **subarray** is a contiguous non-empty sequence of elements within an arra...
dolphin
[ 0.021300097927451134, 0.04148734733462334, -0.043891541659832, -0.01639915257692337, 0.03570637106895447, -0.01131597999483347, -0.03394603356719017, 0.05421025678515434, 0.026735367253422737, -0.015494120307266712, 0.03571336716413498, 0.02393687516450882, -0.025690864771604538, -0.000809...
0.835155
0.777787
0.057367
Please explain the reasoning behind the following solution and provide code in java: A die simulator generates a random number from `1` to `6` for each roll. You introduced a constraint to the generator such that it cannot roll the number `i` more than `rollMax[i]` (**1-indexed**) consecutive times. Given an array of ...
dolphin
[ 0.036894772201776505, 0.020753005519509315, -0.025215813890099525, -0.02225750871002674, 0.04168634116649628, -0.02412157878279686, -0.04046592488884926, 0.054918140172958374, 0.023981118574738503, -0.021202698349952698, 0.04405464231967926, 0.024583851918578148, -0.018144935369491577, 0.0...
0.841293
0.781435
0.059858
Please focus on the algorithm of this problem and provide code in javascript: You are given an `m x n` binary matrix `grid`, where `0` represents a sea cell and `1` represents a land cell. A **move** consists of walking from one land cell to another adjacent (**4-directionally**) land cell or walking off the boundary ...
dolphin
[ -0.006223956122994423, 0.02450437843799591, -0.024350328370928764, -0.030262701213359833, 0.04363115876913071, -0.03577046096324921, -0.03236720338463783, 0.06535089761018753, 0.023749321699142456, -0.009775388985872269, 0.014994919300079346, 0.014684372581541538, -0.03463374823331833, -0....
0.84542
0.79116
0.05426
Please write the following solution using Scheme: Given an array `nums` of **distinct** positive integers, return _the number of tuples_ `(a, b, c, d)` _such that_ `a * b = c * d` _where_ `a`_,_ `b`_,_ `c`_, and_ `d` _are elements of_ `nums`_, and_ `a != b != c != d`_._ **Example 1:** **Input:** nums = \[2,3,4,6\] **...
dolphin
[ 0.03987906500697136, 0.030034564435482025, -0.032803528010845184, -0.01862502656877041, 0.05235069617629051, -0.032202888280153275, -0.018927302211523056, 0.06437931954860687, 0.036680638790130615, -0.018475061282515526, 0.0115541722625494, 0.018819941207766533, -0.03569500520825386, -0.03...
0.845035
0.78138
0.063654
Please focus on the efficiency of this problem and provide code in Groovy: You are given a **0-indexed** array of integers `nums` of length `n`. You are initially positioned at `nums[0]`. Each element `nums[i]` represents the maximum length of a forward jump from index `i`. In other words, if you are at `nums[i]`, you...
dolphin
[ 0.009603798389434814, 0.025966444984078407, -0.016189981251955032, -0.02463209070265293, 0.036113519221544266, -0.02659657411277294, -0.02642628736793995, 0.048272714018821716, 0.03471359983086586, -0.01163978036493063, 0.02346748486161232, 0.03848683834075928, -0.02276475913822651, -0.007...
0.848669
0.795156
0.053513
Please write the following solution using Objective-C: A **ramp** in an integer array `nums` is a pair `(i, j)` for which `i < j` and `nums[i] <= nums[j]`. The **width** of such a ramp is `j - i`. Given an integer array `nums`, return _the maximum width of a **ramp** in_ `nums`. If there is no **ramp** in `nums`, retu...
dolphin
[ 0.022873438894748688, 0.031109511852264404, -0.030547741800546646, -0.017864886671304703, 0.04796799272298813, -0.016694949939846992, -0.05008828267455101, 0.0771508738398552, 0.031282179057598114, -0.03045898675918579, 0.03037632256746292, 0.022754214704036713, -0.032766520977020264, -0.0...
0.839416
0.773525
0.065891
Please write the following solution using Mojo: You are given a string `s` and a **positive** integer `k`. Select a set of **non-overlapping** substrings from the string `s` that satisfy the following conditions: * The **length** of each substring is **at least** `k`. * Each substring is a **palindrome**. Return...
dolphin
[ 0.023012381047010422, 0.019316287711262703, -0.037624020129442215, -0.023285048082470894, 0.038950566202402115, -0.0388401597738266, -0.011199897155165672, 0.04309843108057976, 0.020980175584554672, -0.012007636949419975, 0.03639213740825653, 0.01992146298289299, -0.019861891865730286, -0....
0.844006
0.789325
0.054681
Please write the following solution using python: 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_...
dolphin
[ 0.02924192138016224, 0.04442629963159561, -0.014083991758525372, -0.031531285494565964, 0.032410621643066406, -0.02556571550667286, -0.03341146185994148, 0.03819051757454872, 0.026138553395867348, -0.03901554271578789, 0.02432558871805668, 0.006200691219419241, -0.03101753070950508, -0.012...
0.833065
0.777224
0.055841
Please explain the following problem in detail and provide code in java: Given an array of **distinct** integers `nums` and a target integer `target`, return _the number of possible combinations that add up to_ `target`. The test cases are generated so that the answer can fit in a **32-bit** integer. **Example 1:** ...
dolphin
[ 0.016429340466856956, 0.020080892369151115, -0.02259761653840542, -0.004294239450246096, 0.04904863238334656, -0.025913773104548454, -0.02256450057029724, 0.03588414192199707, 0.033872418105602264, -0.0019274220103397965, 0.028402309864759445, 0.03458510711789131, -0.03452382609248161, -0....
0.839683
0.781523
0.058161
Please explain the following problem in detail and provide code in Kotlin: You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions: * `nums.length == n` * `nums[i]` is a **positive** integer where `0 <= i < n`....
dolphin
[ 0.022920560091733932, 0.022381579503417015, -0.021466592326760292, -0.030713815242052078, 0.04367317259311676, -0.02457784302532673, -0.03861251100897789, 0.04754149913787842, 0.03462569788098335, -0.014658229425549507, 0.03294403851032257, 0.03878755867481232, -0.04164116829633713, -0.013...
0.841961
0.778424
0.063537
Please write the following solution using Scheme: Given an integer `n`, return all the **strobogrammatic numbers** that are of length `n`. You may return the answer in **any order**. A **strobogrammatic number** is a number that looks the same when rotated `180` degrees (looked at upside down). **Example 1:** **Inpu...
dolphin
[ 0.023347310721874237, 0.01983470283448696, -0.02070956490933895, -0.04602918401360512, 0.029151227325201035, -0.037697065621614456, -0.026444030925631523, 0.03187485411763191, 0.019250057637691498, 0.0003065459313802421, 0.031040526926517487, 0.027189478278160095, -0.050145454704761505, -0...
0.820963
0.759219
0.061743
Please explain the reasoning behind the following solution and provide code in c++: You have `n` boxes. You are given a binary string `boxes` of length `n`, where `boxes[i]` is `'0'` if the `ith` box is **empty**, and `'1'` if it contains **one** ball. In one operation, you can move **one** ball from a box to an adjac...
dolphin
[ 0.012854652479290962, 0.013288960792124271, -0.033043257892131805, -0.01331262569874525, 0.03228001669049263, -0.007902158424258232, -0.026247916743159294, 0.08825148642063141, 0.03938771039247513, -0.00912483036518097, 0.020662501454353333, 0.03401907905936241, -0.020285703241825104, -0.0...
0.842858
0.784695
0.058162
Please explain the following problem in detail and provide code in c++: Given an integer array `nums` sorted in **non-decreasing** order, return _an array of **the squares of each number** sorted in non-decreasing order_. **Example 1:** **Input:** nums = \[-4,-1,0,3,10\] **Output:** \[0,1,9,16,100\] **Explanation:** ...
dolphin
[ 0.01901012286543846, 0.037792451679706573, -0.026700252667069435, -0.041035789996385574, 0.03994716703891754, -0.01143580861389637, -0.019320720806717873, 0.08818024396896362, 0.042303696274757385, -0.011520602740347385, 0.036058783531188965, 0.01917724311351776, -0.04923079162836075, -0.0...
0.822683
0.766655
0.056029
Please focus on the efficiency of this problem and provide code in javascript: Given an array of positive integers `nums` and a positive integer `target`, return _the **minimal length** of a_ _subarray_ _whose sum is greater than or equal to_ `target`. If there is no such subarray, return `0` instead. **Example 1:** ...
dolphin
[ 0.013476787135004997, 0.023167381063103676, -0.036428213119506836, -0.021139273419976234, 0.04192414507269859, -0.010345468297600746, -0.031038282439112663, 0.04398413002490997, 0.041251398622989655, -0.011720606125891209, 0.019806845113635063, 0.019254125654697418, -0.03788591921329498, -...
0.851241
0.790241
0.061001
Please explain the following problem in detail and provide code in C#: You are given a 2D integer array `grid` of size `m x n`, where each cell contains a positive integer. A **cornered path** is defined as a set of adjacent cells with **at most** one turn. More specifically, the path should exclusively move either **...
dolphin
[ 0.010416856966912746, 0.033060524612665176, -0.012569885700941086, -0.029650140553712845, 0.03364310786128044, -0.02781170979142189, -0.0328274630010128, 0.0924333930015564, 0.030185680836439133, -0.011341783218085766, 0.02192576602101326, 0.017993640154600143, -0.02993456833064556, -0.038...
0.844142
0.785475
0.058668
Please explain the following problem in detail and provide code in java: Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly `two` or `zero` sub-node. If the node has two sub-nodes, then this node's value is the smaller value among its two sub-...
dolphin
[ 0.02549321949481964, 0.029317760840058327, -0.04190238192677498, -0.023378262296319008, 0.02810974046587944, -0.046083178371191025, -0.004518052563071251, 0.053329285234212875, 0.021844742819666862, -0.026812732219696045, 0.04402786120772362, 0.008232644759118557, -0.028305185958743095, 0....
0.83457
0.775811
0.058758
Please explain the following problem in detail and provide code in Elixir: 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 it satisfi...
dolphin
[ 0.024688079953193665, 0.022687194868922234, -0.025081705302000046, -0.04530125483870506, 0.02951044961810112, -0.02021140791475773, -0.03204387426376343, 0.03987817093729973, 0.021819252520799637, -0.004076696466654539, 0.02733759768307209, 0.032180968672037125, -0.03453509882092476, -0.01...
0.855691
0.800546
0.055144
Please write the following solution using Objective-C: Given an integer array `nums`, find the subarray with the largest sum, and return _its sum_. **Example 1:** **Input:** nums = \[-2,1,-3,4,-1,2,1,-5,4\] **Output:** 6 **Explanation:** The subarray \[4,-1,2,1\] has the largest sum 6. **Example 2:** **Input:** num...
dolphin
[ 0.02211681380867958, 0.033155348151922226, -0.02945469692349434, -0.03279482573270798, 0.03713369742035866, -0.01648152992129326, -0.0314660482108593, 0.04526829719543457, 0.030511001124978065, -0.015200573019683361, 0.03320742025971413, 0.028546994552016258, -0.04862724989652634, -0.00602...
0.829712
0.764671
0.065041
Please explain the reasoning behind the following solution and provide code in c++: You are given two positive integer arrays `nums1` and `nums2`, both of length `n`. The **absolute sum difference** of arrays `nums1` and `nums2` is defined as the **sum** of `|nums1[i] - nums2[i]|` for each `0 <= i < n` (**0-indexed**)...
dolphin
[ 0.00961916334927082, 0.022604582831263542, -0.0162641741335392, -0.031074034050107002, 0.039652418345212936, -0.027309205383062363, -0.03853246942162514, 0.09143448621034622, 0.05657868832349777, -0.020890023559331894, 0.019744278863072395, 0.02591666951775551, -0.03353894129395485, 0.0065...
0.836014
0.782298
0.053715
Please write the following solution using java: You are given an integer array `target`. You have an integer array `initial` of the same size as `target` with all elements initially zeros. In one operation you can choose **any** subarray from `initial` and increment each value by one. Return _the minimum number of op...
dolphin
[ 0.022747693583369255, 0.03941776230931282, -0.020419975742697716, -0.02265455387532711, 0.04420500248670578, -0.021472224965691566, -0.038921061903238297, 0.04523506015539169, 0.03168969228863716, -0.025992754846811295, 0.028970737010240555, 0.004910526797175407, -0.031852155923843384, -0....
0.855286
0.793456
0.061829
Please write the following solution using C#: You are given an array of integers `nums`, there is a sliding window of size `k` which is moving from the very left of the array to the very right. You can only see the `k` numbers in the window. Each time the sliding window moves right by one position. Return _the max sli...
dolphin
[ 0.03035120666027069, 0.03299690783023834, -0.021469514816999435, -0.026955315843224525, 0.042224034667015076, -0.018048299476504326, -0.037299416959285736, 0.08034759014844894, 0.04046541452407837, -0.007684072945266962, 0.0450957790017128, 0.02600783482193947, -0.046903662383556366, 0.001...
0.837431
0.781214
0.056218
Please write the following solution using Fortran: A bus has `n` stops numbered from `0` to `n - 1` that form a circle. We know the distance between all pairs of neighboring stops where `distance[i]` is the distance between the stops number `i` and `(i + 1) % n`. The bus goes along both directions i.e. clockwise and c...
dolphin
[ 0.017569664865732193, 0.02788369357585907, -0.017500046640634537, -0.032616984099149704, 0.040265392512083054, -0.013740018010139465, -0.043316591531038284, 0.038271110504865646, 0.046891648322343826, 0.0028603526297956705, 0.021048733964562416, 0.032170962542295456, -0.003917415626347065, ...
0.840943
0.784806
0.056137
Please explain the following problem in detail and provide code in Kotlin: There are `n` **unique** candies (labeled `1` through `n`) and `k` bags. You are asked to distribute **all** the candies into the bags such that every bag has **at least** one candy. There can be multiple ways to distribute the candies. Two way...
dolphin
[ 0.004536367487162352, 0.02400612272322178, -0.009674197062849998, -0.032805435359478, 0.030191825702786446, -0.021199770271778107, -0.032669391483068466, 0.05224599316716194, 0.017551597207784653, -0.02301383577287197, 0.027090732008218765, 0.034441858530044556, -0.02423441782593727, -0.00...
0.840025
0.785505
0.054519
Please focus on the algorithm of this problem and provide code in c++: Given an integer array `nums` and an integer `k`, find three non-overlapping subarrays of length `k` with maximum sum and return them. Return the result as a list of indices representing the starting position of each interval (**0-indexed**). If th...
dolphin
[ 0.019449474290013313, 0.02457086183130741, -0.03088868409395218, -0.029396748170256615, 0.04387581720948219, 0.003921171650290489, -0.03173290193080902, 0.09320068359375, 0.03259742632508278, -0.020068755373358727, 0.04372823238372803, 0.044453609734773636, -0.038656044751405716, -0.006778...
0.839951
0.77952
0.060431
Please write the following solution using Haskell: On a 2D plane, we place `n` stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either **the same row or the same column** as another stone that has not been removed. Given an array `stones` ...
dolphin
[ 0.040546100586652756, 0.017203157767653465, -0.025621291249990463, -0.03580036386847496, 0.026055118069052696, -0.034261468797922134, -0.024083327502012253, 0.04934476688504219, 0.05055134743452072, -0.01723507232964039, 0.02394123002886772, 0.030642205849289894, -0.02272697351872921, -0.0...
0.844439
0.787416
0.057023
Please write the following solution using Perl: You are given two integer arrays `nums1` and `nums2` of lengths `m` and `n` respectively. `nums1` and `nums2` represent the digits of two numbers. You are also given an integer `k`. Create the maximum number of length `k <= m + n` from digits of the two numbers. The rela...
dolphin
[ 0.02269374392926693, 0.025094466283917427, -0.035522956401109695, -0.05488206073641777, 0.043238554149866104, -0.017334390431642532, -0.023855730891227722, 0.039199091494083405, 0.03827981650829315, -0.01860256865620613, 0.024707239121198654, 0.0408361591398716, -0.03173099830746651, 0.003...
0.83678
0.780619
0.056161
Please explain the reasoning behind the following solution and provide code in Swift: You are given an integer array `nums`. A number `x` is **lonely** when it appears only **once**, and no **adjacent** numbers (i.e. `x + 1` and `x - 1)` appear in the array. Return _**all** lonely numbers in_ `nums`. You may return th...
dolphin
[ 0.01914960891008377, 0.036667872220277786, -0.01640976592898369, -0.024858523160219193, 0.04192997142672539, -0.020795084536075592, -0.020095642656087875, 0.0526617206633091, 0.036158107221126556, -0.013794377446174622, 0.025103332474827766, 0.003871452994644642, -0.033607982099056244, -0....
0.837677
0.783128
0.054549
Please explain the following problem in detail and provide code in Julia: 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 b...
dolphin
[ -0.005509795621037483, 0.018519092351198196, -0.03204745426774025, -0.02670597843825817, 0.05578000843524933, -0.007689186837524176, -0.04825373366475105, 0.046973176300525665, 0.03859127685427666, -0.007772847078740597, 0.03384636715054512, 0.03991205245256424, -0.03752722963690758, -0.00...
0.844417
0.782504
0.061913
Please write the following solution using Dart: You are given a **0-indexed** integer array `tasks`, where `tasks[i]` represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the **same difficulty level**. Return _the **minimum** rounds required to complete all the tasks, or_ `...
dolphin
[ 0.016265565529465675, 0.03729281947016716, -0.022609485313296318, -0.03300442919135094, 0.04340215027332306, -0.000700061209499836, -0.03326650336384773, 0.05191068351268768, 0.02659234218299389, -0.004290711134672165, 0.004725691396743059, 0.020329630002379417, -0.02230340614914894, -0.00...
0.842749
0.788938
0.053811
Please explain the following problem in detail and provide code in C#: A certain bug's home is on the x-axis at position `x`. Help them get there from position `0`. The bug jumps according to the following rules: * It can jump exactly `a` positions **forward** (to the right). * It can jump exactly `b` positions *...
dolphin
[ 0.014783654361963272, 0.02829337865114212, -0.018539048731327057, -0.012789093889296055, 0.03150731325149536, -0.0341310016810894, -0.017607979476451874, 0.0854632630944252, 0.03848590329289436, -0.0019561084918677807, 0.002142483601346612, 0.04994512349367142, -0.0397910475730896, -0.0410...
0.849022
0.793232
0.055791
Please write the following solution using F#: Given an integer array `nums`, find a subarray that has the largest product, and return _the product_. The test cases are generated so that the answer will fit in a **32-bit** integer. **Example 1:** **Input:** nums = \[2,3,-2,4\] **Output:** 6 **Explanation:** \[2,3\] h...
dolphin
[ 0.03660387918353081, 0.04020083323121071, -0.026648854836821556, -0.018440397456288338, 0.05114327743649483, -0.020004136487841606, -0.030649112537503242, 0.06465312093496323, 0.04403364658355713, -0.019681992009282112, 0.027042046189308167, 0.04371005669236183, -0.044408079236745834, -0.0...
0.840563
0.785534
0.055029
Please focus on the algorithm of this problem and provide code in Kotlin: Given an integer `n`, find a sequence that satisfies all of the following: * The integer `1` occurs once in the sequence. * Each integer between `2` and `n` occurs twice in the sequence. * For every integer `i` between `2` and `n`, the **d...
dolphin
[ 0.018771076574921608, 0.027474550530314445, -0.009976296685636044, -0.04218483343720436, 0.02624310553073883, -0.030575351789593697, -0.03999001160264015, 0.06499675661325455, 0.02287641353905201, -0.03068499080836773, 0.023721838369965553, 0.03693394735455513, -0.040011946111917496, -0.00...
0.850457
0.790752
0.059704
Please explain the following problem in detail and provide code in javascript: You are given the array `nums` consisting of `n` positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of `n * (n + 1) / 2` numbers. _...
dolphin
[ 0.02352442964911461, 0.03865499794483185, -0.029238419607281685, -0.025437215343117714, 0.031106488779187202, -0.010937748476862907, -0.021364308893680573, 0.042270075529813766, 0.028598062694072723, -0.004719449672847986, 0.027299825102090836, 0.01708724908530712, -0.05552366375923157, -0...
0.840163
0.780659
0.059504
Please write the following solution using Visual Basic .NET: You are given an integer array `nums` and an integer `k`. You may partition `nums` into one or more **subsequences** such that each element in `nums` appears in **exactly** one of the subsequences. Return _the **minimum** number of subsequences needed such t...
dolphin
[ 0.024741725996136665, 0.021171754226088524, -0.03197102248668671, -0.010795732028782368, 0.03900350630283356, -0.01083640567958355, -0.023353638127446175, 0.07926095277070999, 0.03756221756339073, -0.009078056551516056, 0.03464927524328232, 0.033237166702747345, -0.038588233292102814, -0.0...
0.848171
0.785943
0.062228
Please write the following solution using c++: Given the `root` of a binary tree where every node has **a unique value** and a target integer `k`, return _the value of the **nearest leaf node** to the target_ `k` _in the tree_. **Nearest to a leaf** means the least number of edges traveled on the binary tree to reach ...
dolphin
[ 0.02948487550020218, 0.04640372470021248, -0.03157803788781166, -0.023122502490878105, 0.04079659655690193, -0.04093129560351372, -0.0041528865694999695, 0.07366926968097687, 0.03422883525490761, -0.008373333141207695, 0.0486295260488987, 0.013417785055935383, -0.014720584265887737, 0.0159...
0.830437
0.776556
0.053881
Please explain the reasoning behind the following solution and provide code in Fortran: You are given an integer array `arr`. In one move, you can select a **palindromic** subarray `arr[i], arr[i + 1], ..., arr[j]` where `i <= j`, and remove that subarray from the given array. Note that after removing a subarray, the ...
dolphin
[ 0.021741054952144623, 0.030721941962838173, -0.028569040820002556, -0.03846566751599312, 0.0449795126914978, -0.022685762494802475, -0.02429109998047352, 0.058308620005846024, 0.047621652483940125, -0.005545040592551231, 0.02103189378976822, 0.018408341333270073, -0.027328263968229294, -0....
0.84285
0.786515
0.056334
Please explain the following problem in detail and provide code in c++: The **frequency** of an element is the number of times it occurs in an array. You are given an integer array `nums` and an integer `k`. In one operation, you can choose an index of `nums` and increment the element at that index by `1`. Return _th...
dolphin
[ 0.016904689371585846, 0.03332512080669403, -0.01789790578186512, -0.027570221573114395, 0.03942952677607536, -0.002015033969655633, -0.028260478749871254, 0.10785549879074097, 0.02087637223303318, 0.003949678037315607, 0.028035368770360947, 0.0271257683634758, -0.02850733883678913, 0.00820...
0.83914
0.779127
0.060013
Please write the following solution using java: You are given an integer array `deck` where `deck[i]` represents the number written on the `ith` card. Partition the cards into **one or more groups** such that: * Each group has **exactly** `x` cards where `x > 1`, and * All the cards in one group have the same int...
dolphin
[ 0.03540603443980217, 0.02401885762810707, -0.0406111441552639, -0.028028197586536407, 0.03865655139088631, -0.028126215562224388, -0.0062040165066719055, 0.046272970736026764, 0.03198189660906792, -0.03185919672250748, 0.02009817212820053, 0.008831298910081387, -0.011363042518496513, -0.01...
0.834745
0.77687
0.057874
Please explain the following problem in detail and provide code in PHP: You are given an integer array, `nums`, and an integer `k`. `nums` comprises of only `0`'s and `1`'s. In one move, you can choose two **adjacent** indices and swap their values. Return _the **minimum** number of moves required so that_ `nums` _has...
dolphin
[ 0.0028053109999746084, 0.04877881333231926, -0.010748841799795628, -0.025073915719985962, 0.04894670099020004, -0.011940019205212593, -0.03590102866292, 0.06940421462059021, 0.02750213071703911, -0.01555381715297699, 0.02854330651462078, 0.004402531310915947, -0.033719733357429504, -0.0094...
0.847623
0.786607
0.061015
Please write the following solution using Visual Basic .NET: On a 2D plane, we place `n` stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it shares either **the same row or the same column** as another stone that has not been removed. Given an array...
dolphin
[ 0.03583778813481331, 0.026225069537758827, -0.03478247672319412, -0.03150537610054016, 0.023922352120280266, -0.03758235648274422, -0.019397422671318054, 0.07479607313871384, 0.052111219614744186, -0.01990680955350399, 0.028343142941594124, 0.03307026997208595, -0.03107069432735443, -0.033...
0.847912
0.790767
0.057145
Please explain the following problem in detail and provide code in ANSI C: Given a string `s`, return _the length of the longest substring between two equal characters, excluding the two characters._ If there is no such substring return `-1`. A **substring** is a contiguous sequence of characters within a string. **E...
dolphin
[ 0.013223650865256786, 0.01747339777648449, -0.033364929258823395, -0.040926575660705566, 0.02973274327814579, -0.03386620804667473, -0.022033914923667908, 0.06525365263223648, 0.027545848861336708, -0.025359055027365685, 0.03652148321270943, 0.035823557525873184, -0.024200929328799248, -0....
0.827265
0.773094
0.054171
Please write the following solution using Kotlin: You are given an integer array `nums` and an integer `k`. You can partition the array into **at most** `k` non-empty adjacent subarrays. The **score** of a partition is the sum of the averages of each subarray. Note that the partition must use every integer in `nums`, ...
dolphin
[ 0.010207107290625572, 0.015331021510064602, -0.04087863489985466, -0.017093321308493614, 0.04039259999990463, -0.017537444829940796, -0.029093259945511818, 0.03298507258296013, 0.030967094004154205, -0.010399146005511284, 0.034782204777002335, 0.02994535304605961, -0.029541626572608948, 0....
0.835728
0.771788
0.063941
Please write the following solution using python: You are given a string `s`. An **awesome** substring is a non-empty substring of `s` such that we can make any number of swaps in order to make it a palindrome. Return _the length of the maximum length **awesome substring** of_ `s`. **Example 1:** **Input:** s = "32...
dolphin
[ 0.036562785506248474, 0.017761899158358574, -0.013105113059282303, -0.03378460556268692, 0.02322866953909397, -0.04174079746007919, -0.023423630744218826, 0.02182408608496189, 0.028546305373311043, -0.011818044818937778, 0.029545072466135025, 0.0331205315887928, -0.038124311715364456, -0.0...
0.824183
0.768548
0.055635
Please explain the reasoning behind the following solution and provide code in ANSI C: You are given two positive **0-indexed** integer arrays `nums1` and `nums2`, both of length `n`. The **sum of squared difference** of arrays `nums1` and `nums2` is defined as the **sum** of `(nums1[i] - nums2[i])2` for each `0 <= i ...
dolphin
[ 0.004493430722504854, 0.041775308549404144, -0.023117437958717346, -0.05002698302268982, 0.04594622179865837, -0.02460283227264881, -0.030463265255093575, 0.08969156444072723, 0.051654472947120667, -0.020961591973900795, 0.03236612677574158, 0.018334629014134407, -0.049963995814323425, -0....
0.839247
0.777933
0.061314
Please explain the following problem in detail and provide code in PHP: 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 equal to_ `go...
dolphin
[ 0.0047284578904509544, 0.026104338467121124, -0.017870895564556122, -0.025355936959385872, 0.04944314807653427, -0.020002182573080063, -0.027528226375579834, 0.051924195140600204, 0.04187579080462456, -0.014277582056820393, 0.005396900232881308, 0.027307190001010895, -0.046523887664079666, ...
0.839313
0.784551
0.054761
Please write the following solution using R: Given an integer `n`, count _the total number of digit_ `1` _appearing in all non-negative integers less than or equal to_ `n`. **Example 1:** **Input:** n = 13 **Output:** 6 **Example 2:** **Input:** n = 0 **Output:** 0 **Constraints:** * `0 <= n <= 109`
dolphin
[ 0.01238215621560812, 0.022316448390483856, -0.027456481009721756, -0.04150455445051193, 0.045497868210077286, -0.021216927096247673, -0.030957525596022606, 0.0400519035756588, 0.02102159522473812, 0.011325178667902946, 0.021394209936261177, 0.03169581666588783, -0.03934858739376068, -0.034...
0.820975
0.763711
0.057264
Please focus on the efficiency of this problem and provide code in Objective-C: Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _where_ `0 <= i < j < n`, _such that_ `nums[i] == nums[j]` _and_ `(i * j)` _is divisible by_ `k`. **Example 1:** **Inpu...
dolphin
[ 0.021223606541752815, 0.033047936856746674, -0.043698593974113464, -0.01337664108723402, 0.04750761762261391, -0.030475469306111336, -0.025987185537815094, 0.06670557707548141, 0.02420296147465706, -0.016478972509503365, 0.033233512192964554, 0.01186463888734579, -0.028092121705412865, -0....
0.848911
0.786489
0.062422
Please explain the following problem in detail and provide code in ANSI C: You are given a **0-indexed** integer array `forts` of length `n` representing the positions of several forts. `forts[i]` can be `-1`, `0`, or `1` where: * `-1` represents there is **no fort** at the `ith` position. * `0` indicates there is...
dolphin
[ 0.03238113224506378, 0.04192899540066719, -0.019330859184265137, -0.02608904242515564, 0.012270791456103325, -0.03895115107297897, -0.02033837139606476, 0.08150090277194977, 0.03606349602341652, -0.03049192950129509, 0.024535533040761948, 0.01884307712316513, -0.05480946600437164, -0.03113...
0.843254
0.78682
0.056434
Please explain the following problem in detail and provide code in ANSI C: You are given the `head` of a linked list containing unique integer values and an integer array `nums` that is a subset of the linked list values. Return _the number of connected components in_ `nums` _where two values are connected if they app...
dolphin
[ 0.026467150077223778, 0.034154877066612244, -0.01825558952987194, -0.014773992821574211, 0.03518218547105789, -0.01820676028728485, -0.02356068789958954, 0.06885358691215515, 0.0326988585293293, 0.006093763746321201, 0.02485290728509426, 0.0178239643573761, -0.021468695253133774, -0.014514...
0.835991
0.768395
0.067596
Please explain the following problem in detail and provide code in Perl: We define a harmonious array as an array where the difference between its maximum value and its minimum value is **exactly** `1`. Given an integer array `nums`, return _the length of its longest harmonious subsequence among all its possible subse...
dolphin
[ 0.03851034492254257, 0.01975972391664982, -0.038597628474235535, -0.01758434623479843, 0.030111243948340416, -0.02173275128006935, -0.02628340572118759, 0.0447814017534256, 0.05041904374957085, -0.022558173164725304, 0.032399993389844894, 0.031413767486810684, -0.022484222427010536, -0.008...
0.829794
0.772298
0.057495
Please explain the reasoning behind the following solution and provide code in Object Pascal: You are given an integer array `nums`. In one move, you can pick an index `i` where `0 <= i < nums.length` and increment `nums[i]` by `1`. Return _the minimum number of moves to make every value in_ `nums` _**unique**_. The ...
dolphin
[ 0.0066496883518993855, 0.03126828745007515, -0.0075997342355549335, -0.019119886681437492, 0.04288706183433533, -0.022294312715530396, -0.017283285036683083, 0.06656035035848618, 0.035457734018564224, -0.01796484738588333, 0.03651779890060425, 0.014633629471063614, -0.02475588582456112, -0...
0.848075
0.791767
0.056308
Please explain the reasoning behind the following solution and provide code in python: There is an integer array `nums` that consists of `n` **unique** elements, but you have forgotten it. However, you do remember every pair of adjacent elements in `nums`. You are given a 2D integer array `adjacentPairs` of size `n - ...
dolphin
[ 0.03086104616522789, 0.022342877462506294, -0.034225840121507645, -0.020374886691570282, 0.03625098988413811, -0.018394313752651215, -0.012370403856039047, 0.0601004920899868, 0.02936660870909691, -0.014650761149823666, 0.01508679986000061, 0.025924216955900192, -0.01872330904006958, 0.000...
0.85221
0.798377
0.053833
Please explain the reasoning behind the following solution and provide code in Scala: You may recall that an array `arr` is a **mountain array** if and only if: * `arr.length >= 3` * There exists some index `i` (**0-indexed**) with `0 < i < arr.length - 1` such that: * `arr[0] < arr[1] < ... < arr[i - 1] < a...
dolphin
[ 0.02346276491880417, 0.029684578999876976, -0.03350641578435898, -0.042862724512815475, 0.03093011863529682, -0.032116010785102844, -0.03669837489724159, 0.06092781573534012, 0.024287480860948563, -0.027675006538629532, 0.021636614575982094, 0.012880110181868076, -0.015389426611363888, -0....
0.840068
0.783482
0.056585
Please write the following solution using python: Given an integer array `nums` and an integer `k`, return _the number of **good subarrays** of_ `nums`. A **good array** is an array where the number of different integers in that array is exactly `k`. * For example, `[1,2,3,1,2]` has `3` different integers: `1`, `2`...
dolphin
[ 0.02691313996911049, 0.029379557818174362, -0.04217138513922691, -0.021145261824131012, 0.041876453906297684, -0.01736094430088997, -0.043665170669555664, 0.028771165758371353, 0.026913469657301903, -0.0007473076693713665, 0.02165261097252369, 0.019613873213529587, -0.02210276760160923, 0....
0.836935
0.778908
0.058027
Please explain the following problem in detail and provide code in C#: You are given an array `nums`​​​ and an integer `k`​​​​​. The XOR of a segment `[left, right]` where `left <= right` is the `XOR` of all the elements with indices between `left` and `right`, inclusive: `nums[left] XOR nums[left+1] XOR ... XOR nums[r...
dolphin
[ 0.02331806719303131, 0.040231380611658096, -0.034664496779441833, -0.01478477381169796, 0.0226618479937315, -0.03723309189081192, -0.014544363133609295, 0.08520671725273132, 0.03906926512718201, -0.00501107657328248, 0.016889924183487892, 0.006122437305748463, -0.03481270745396614, -0.0175...
0.848127
0.794906
0.053221
Please write the following solution using Elixir: Given an binary array `nums` and an integer `k`, return `true` _if all_ `1`_'s are at least_ `k` _places away from each other, otherwise return_ `false`. **Example 1:** **Input:** nums = \[1,0,0,0,1,0,0,1\], k = 2 **Output:** true **Explanation:** Each of the 1s are a...
dolphin
[ 0.016485312953591347, 0.038331568241119385, -0.016361942514777184, -0.04244352504611015, 0.0392017625272274, -0.028092561289668083, -0.014035024680197239, 0.06388849020004272, 0.0245540551841259, -0.012945573776960373, 0.021069977432489395, 0.014315090142190456, -0.016738642007112503, -0.0...
0.845755
0.784519
0.061235
Please focus on the functionality of this problem and provide code in c++: You are given a positive integer `n`, that is initially placed on a board. Every day, for `109` days, you perform the following procedure: * For each number `x` present on the board, find all numbers `1 <= i <= n` such that `x % i == 1`. * ...
dolphin
[ 0.029447995126247406, 0.01864146813750267, -0.03753570839762688, -0.024080228060483932, 0.0229807086288929, -0.03349203243851662, -0.016737615689635277, 0.1056043803691864, 0.03952350094914436, -0.007990590296685696, 0.020806588232517242, 0.033014971762895584, -0.02381388284265995, -0.0045...
0.845952
0.782851
0.063101
Please explain the following problem in detail and provide code in Scala: There is an undirected tree with `n` nodes labeled from `0` to `n - 1`. You are given a **0-indexed** integer array `nums` of length `n` where `nums[i]` represents the value of the `ith` node. You are also given a 2D integer array `edges` of len...
dolphin
[ 0.014547876082360744, 0.025931332260370255, -0.018363330513238907, -0.02321927808225155, 0.04242049157619476, -0.03207755461335182, 0.002510538324713707, 0.05067979171872139, 0.02800150029361248, -0.009211825206875801, 0.04057759791612625, 0.015082225203514099, -0.013690086081624031, -0.00...
0.847587
0.793894
0.053693
Please explain the reasoning behind the following solution and provide code in java: You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone. We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weights `x`...
dolphin
[ 0.03225693479180336, 0.0301832128316164, -0.04009329900145531, -0.0313536636531353, 0.036898501217365265, -0.023064179345965385, -0.025658953934907913, 0.050269465893507004, 0.03133179247379303, -0.029007403180003166, 0.04235474765300751, 0.026178767904639244, -0.02829206921160221, -0.0203...
0.846179
0.789048
0.057131
Please write the following solution using python: You are given an array `nums` consisting of **positive** integers. You have to take each integer in the array, **reverse its digits**, and add it to the end of the array. You should apply this operation to the original integers in `nums`. Return _the number of **disti...
dolphin
[ 0.01830357499420643, 0.032515596598386765, -0.02129918336868286, -0.018832575529813766, 0.04261164367198944, -0.01409850548952818, -0.02039332687854767, 0.04298938438296318, 0.03359530121088028, 0.007670783903449774, 0.006407878361642361, 0.013903370127081871, -0.04043343663215637, -0.0017...
0.833393
0.770467
0.062926
Please explain the reasoning behind the following solution and provide code in Objective-C: Given an integer `n`, find a sequence that satisfies all of the following: * The integer `1` occurs once in the sequence. * Each integer between `2` and `n` occurs twice in the sequence. * For every integer `i` between `2...
dolphin
[ 0.029049839824438095, 0.03511738404631615, -0.02492520585656166, -0.045192789286375046, 0.03290937840938568, -0.03578495979309082, -0.05018538236618042, 0.07422087341547012, 0.02453865297138691, -0.02848985232412815, 0.031118430197238922, 0.03483009338378906, -0.046801235526800156, -0.0035...
0.844889
0.789419
0.05547
Please focus on the functionality of this problem and provide code in Fortran: You are given an integer array `nums`. In one move, you can pick an index `i` where `0 <= i < nums.length` and increment `nums[i]` by `1`. Return _the minimum number of moves to make every value in_ `nums` _**unique**_. The test cases are ...
dolphin
[ 0.007820416241884232, 0.0331927165389061, -0.008140460588037968, -0.02182856574654579, 0.03734569996595383, -0.01859416998922825, -0.019122665748000145, 0.06969629973173141, 0.02971002645790577, -0.01944103091955185, 0.030554894357919693, 0.015070351772010326, -0.02481025643646717, -0.0141...
0.851291
0.795581
0.05571
Please write the following solution using python: Given an array `nums` of distinct integers, return _all the possible permutations_. You can return the answer in **any order**. **Example 1:** **Input:** nums = \[1,2,3\] **Output:** \[\[1,2,3\],\[1,3,2\],\[2,1,3\],\[2,3,1\],\[3,1,2\],\[3,2,1\]\] **Example 2:** **In...
dolphin
[ 0.02347726933658123, 0.03726464509963989, -0.004729155451059341, -0.0010181786492466927, 0.04459165036678314, -0.040220558643341064, -0.028544563800096512, 0.03803560882806778, 0.036240167915821075, -0.013689934276044369, 0.02600657194852829, 0.02195783331990242, -0.043827351182699203, -0....
0.820081
0.765237
0.054843
Please write the following solution using ANSI C: Given an integer array `nums`, rotate the array to the right by `k` steps, where `k` is non-negative. **Example 1:** **Input:** nums = \[1,2,3,4,5,6,7\], k = 3 **Output:** \[5,6,7,1,2,3,4\] **Explanation:** rotate 1 steps to the right: \[7,1,2,3,4,5,6\] rotate 2 steps...
dolphin
[ 0.02590247616171837, 0.04824773222208023, -0.0030393097549676895, -0.020209329202771187, 0.019850661978125572, -0.005560101475566626, -0.030152874067425728, 0.06692083179950714, 0.022707361727952957, -0.011777362786233425, 0.01699824072420597, 0.008596496656537056, -0.0459313802421093, -0....
0.830178
0.77017
0.060008
Please explain the following problem in detail and provide code in java: Given a string `s` and an integer `k`, return _the length of the longest_ _substring_ _of_ `s` _that contains at most_ `k` _**distinct** characters_. **Example 1:** **Input:** s = "eceba ", k = 2 **Output:** 3 **Explanation:** The substring is ...
dolphin
[ 0.02369830384850502, 0.03424632176756859, -0.025643667206168175, -0.04573255777359009, 0.034229788929224014, -0.04718029499053955, -0.010508914478123188, 0.03224259614944458, 0.0280770156532526, -0.01647445186972618, 0.03702985867857933, 0.024541061371564865, -0.01834803633391857, 0.014571...
0.829322
0.772093
0.05723
Please focus on the algorithm of this problem and provide code in ANSI C: Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`. Each number in `candidates` may only be used **once** in the combina...
dolphin
[ 0.018818648532032967, 0.03362312912940979, -0.01052246056497097, -0.015298928134143353, 0.03713972866535187, -0.016962997615337372, -0.0281255841255188, 0.059176988899707794, 0.03364616632461548, -0.015422261320054531, 0.022919759154319763, 0.022466877475380898, -0.03316471353173256, -0.01...
0.838314
0.779408
0.058907
Please write the following solution using Julia: Given an array of integers `nums` and an integer `k`, return _the number of **unique** k-diff pairs in the array_. A **k-diff** pair is an integer pair `(nums[i], nums[j])`, where the following are true: * `0 <= i, j < nums.length` * `i != j` * `nums[i] - nums[j]...
dolphin
[ 0.00507380161434412, 0.03245377913117409, -0.03106958046555519, -0.032779838889837265, 0.056373562663793564, -0.010630385018885136, -0.029422752559185028, 0.06605802476406097, 0.050703130662441254, -0.0053349267691373825, 0.019097227603197098, 0.0002854202757589519, -0.021312052384018898, ...
0.840032
0.77615
0.063882
Please explain the reasoning behind the following solution and provide code in Mojo: A magical string `s` consists of only `'1'` and `'2'` and obeys the following rules: * The string s is magical because concatenating the number of contiguous occurrences of characters `'1'` and `'2'` generates the string `s` itself....
dolphin
[ 0.030225636437535286, 0.03724503144621849, -0.01807740330696106, -0.04921504482626915, 0.03936971351504326, -0.03892331197857857, -0.0327087938785553, 0.0650365874171257, 0.02086516097187996, -0.006623837631195784, 0.025494428351521492, 0.017397509887814522, -0.033418890088796616, -0.02235...
0.849455
0.79554
0.053915
Please explain the following problem in detail and provide code in python: You are given an array `nums` consisting of positive integers. Starting with `score = 0`, apply the following algorithm: * Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index...
dolphin
[ 0.02632557787001133, 0.04662148281931877, -0.032269641757011414, -0.026382822543382645, 0.040407102555036545, -0.011876259930431843, -0.025031596422195435, 0.05189080908894539, 0.021847622469067574, 0.0017316070152446628, 0.02398044802248478, 0.020315377041697502, -0.018521646037697792, -0...
0.853382
0.789807
0.063575
Please write the following solution using Kotlin: Given an unsorted array of integers `nums`, return _the length of the longest **continuous increasing subsequence** (i.e. subarray)_. The subsequence must be **strictly** increasing. A **continuous increasing subsequence** is defined by two indices `l` and `r` (`l < r`...
dolphin
[ 0.021512864157557487, 0.03736833855509758, -0.016498932614922523, -0.03188319504261017, 0.03266274183988571, -0.020275594666600227, -0.04295101389288902, 0.06286723911762238, 0.042073074728250504, -0.022282114252448082, 0.020040828734636307, 0.016221273690462112, -0.029740888625383377, 0.0...
0.834783
0.777437
0.057346
Please explain the following problem in detail and provide code in c++: Given an integer array `instructions`, you are asked to create a sorted array from the elements in `instructions`. You start with an empty container `nums`. For each element from **left to right** in `instructions`, insert it into `nums`. The **cos...
dolphin
[ 0.01709543727338314, 0.020807238295674324, -0.03043166734278202, -0.011675875633955002, 0.04470422491431236, -0.008923839777708054, -0.029814597219228745, 0.0958569273352623, 0.04403991624712944, -0.00811953004449606, 0.03207504004240036, 0.02252204157412052, -0.021494174376130104, -0.0192...
0.840566
0.783402
0.057164
Please write the following solution using Julia: An integer has _sequential digits_ if and only if each digit in the number is one more than the previous digit. Return a **sorted** list of all the integers in the range `[low, high]` inclusive that have sequential digits. **Example 1:** **Input:** low = 100, high = 3...
dolphin
[ 0.013419167138636112, 0.02345745824277401, -0.012021802365779877, -0.037886105477809906, 0.018643883988261223, -0.02458687499165535, -0.03157074376940727, 0.05223114416003227, 0.016547642648220062, -0.0048833549953997135, 0.041178178042173386, 0.041210807859897614, -0.04353652149438858, -0...
0.816719
0.761019
0.0557
Please focus on the algorithm of this problem and provide code in python: You are given an integer array `nums`. You need to create a 2D array from `nums` satisfying the following conditions: * The 2D array should contain **only** the elements of the array `nums`. * Each row in the 2D array contains **distinct** i...
dolphin
[ 0.012082131579518318, 0.04018864035606384, -0.01978464610874653, -0.02162822335958481, 0.046173401176929474, -0.03907718509435654, -0.03164214268326759, 0.05661902576684952, 0.030710335820913315, 0.004825012292712927, 0.017453061416745186, 0.02902810461819172, -0.0207032710313797, -0.00601...
0.834202
0.777726
0.056476
Please write the following solution using Scheme: You are given a **0-indexed** integer array `nums` and an integer `value`. In one operation, you can add or subtract `value` from any element of `nums`. * For example, if `nums = [1,2,3]` and `value = 2`, you can choose to subtract `value` from `nums[0]` to make `nu...
dolphin
[ 0.0458512008190155, 0.021029949188232422, -0.029059896245598793, -0.016236647963523865, 0.05364246666431427, -0.014317536726593971, -0.03304304555058479, 0.059326499700546265, 0.04527135193347931, -0.02128085494041443, 0.014748305082321167, 0.0324988029897213, -0.03357510268688202, -0.0125...
0.851839
0.786985
0.064853
Please write the following solution using 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 directed edge from node `i` to node `e...
dolphin
[ 0.01565118134021759, 0.014565573073923588, -0.031303394585847855, -0.03174986690282822, 0.023735286667943, -0.039621129631996155, -0.02431037649512291, 0.0823959931731224, 0.03318088501691818, -0.01998959295451641, 0.029980523511767387, 0.0034534449223428965, -0.02831452153623104, -0.02421...
0.836054
0.77514
0.060914
Please write the following solution using Scala: You are given an integer array `nums` of length `n` where `nums` is a permutation of the integers in the range `[1, n]`. You are also given a 2D integer array `sequences` where `sequences[i]` is a subsequence of `nums`. Check if `nums` is the shortest possible and the o...
dolphin
[ 0.003564421785995364, 0.02882799506187439, -0.012587719596922398, -0.010786444880068302, 0.04596433416008949, -0.018003661185503006, -0.020299667492508888, 0.05945924296975136, 0.032862015068531036, -0.01384831964969635, 0.011186197400093079, 0.019865404814481735, -0.0025548196863383055, -...
0.840848
0.782506
0.058343
Please write the following solution using javascript: You are given a **0-indexed** integer array `nums`. In one step, **remove** all elements `nums[i]` where `nums[i - 1] > nums[i]` for all `0 < i < nums.length`. Return _the number of steps performed until_ `nums` _becomes a **non-decreasing** array_. **Example 1:**...
dolphin
[ 0.015533988364040852, 0.038703858852386475, -0.02175217494368553, -0.04027826711535454, 0.04153759032487869, -0.013703255914151669, -0.027418728917837143, 0.06381263583898544, 0.04218294098973274, -0.0035363968927413225, 0.020154738798737526, -0.00006114146526670083, -0.0592322051525116, -...
0.842718
0.786048
0.05667
Please focus on the algorithm of this problem and provide code in ANSI C: You are given an integer `n`. You roll a fair 6-sided dice `n` times. Determine the total number of **distinct** sequences of rolls possible such that the following conditions are satisfied: 1. The **greatest common divisor** of any **adjacent*...
dolphin
[ 0.020876135677099228, 0.02477363497018814, -0.01071630697697401, -0.03069685958325863, 0.026104720309376717, -0.02862243540585041, -0.041569363325834274, 0.0848492756485939, 0.01805141381919384, -0.017418617382645607, 0.037697695195674896, 0.024844659492373466, -0.038737520575523376, -0.01...
0.839275
0.774376
0.064898
Please write the following solution using Mojo: Given an integer array `nums`, return _the **third distinct maximum** number in this array. If the third maximum does not exist, return the **maximum** number_. **Example 1:** **Input:** nums = \[3,2,1\] **Output:** 1 **Explanation:** The first distinct maximum is 3. Th...
dolphin
[ 0.03620939701795578, 0.025604136288166046, -0.026423558592796326, -0.01778119057416916, 0.037963200360536575, -0.023865055292844772, -0.0359814278781414, 0.0508514866232872, 0.022323841229081154, -0.011152839288115501, 0.03351505100727081, 0.02040630206465721, -0.04625697433948517, -0.0162...
0.834488
0.776833
0.057655
Please explain the following problem in detail and provide code in Scheme: Given a 2D integer array `nums`, return _all elements of_ `nums` _in diagonal order as shown in the below images_. **Example 1:** **Input:** nums = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\] **Output:** \[1,4,2,7,5,3,8,6,9\] **Example 2:** **Input:**...
dolphin
[ 0.012616027146577835, 0.027964292094111443, -0.025091134011745453, -0.044457800686359406, 0.0390467531979084, -0.025070756673812866, -0.024780604988336563, 0.04212886467576027, 0.03535488247871399, -0.00012730200251098722, 0.032010700553655624, 0.02782108075916767, -0.04592844471335411, -0...
0.838611
0.776644
0.061968
Please write the following solution using Visual Basic .NET: 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 and `O(1)` s...
dolphin
[ 0.01479764562100172, 0.029949788004159927, -0.018318889662623405, -0.021619930863380432, 0.02832884155213833, -0.024183260276913643, -0.025015410035848618, 0.07981277257204056, 0.035130005329847336, -0.011096376925706863, 0.023952947929501534, 0.0016101987566798925, -0.0353597067296505, -0...
0.83932
0.784385
0.054935
Please write the following solution using java: There are `n` soldiers standing in a line. Each soldier is assigned a **unique** `rating` value. You have to form a team of 3 soldiers amongst them under the following rules: * Choose 3 soldiers with index (`i`, `j`, `k`) with rating (`rating[i]`, `rating[j]`, `rating...
dolphin
[ 0.01660977117717266, 0.018115023151040077, -0.040543608367443085, -0.023803094401955605, 0.049030497670173645, -0.03160196542739868, -0.019207358360290527, 0.04832011088728905, 0.02365022525191307, -0.020085418596863747, 0.023469265550374985, 0.017980827018618584, -0.04481840506196022, -0....
0.853329
0.797175
0.056153
Please write the following solution using Scheme: Given an array `nums` that represents a permutation of integers from `1` to `n`. We are going to construct a binary search tree (BST) by inserting the elements of `nums` in order into an initially empty BST. Find the number of different ways to reorder `nums` so that th...
dolphin
[ 0.028428196907043457, 0.023265482857823372, -0.032648541033267975, -0.012432295829057693, 0.03181960806250572, -0.0313916839659214, -0.017015470191836357, 0.04750438034534454, 0.025895871222019196, -0.01060470286756754, 0.019971825182437897, 0.01562635600566864, -0.03894799202680588, 0.003...
0.853938
0.797215
0.056723