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 C#:
On an `2 x 3` board, there are five tiles labeled from `1` to `5`, and an empty square represented by `0`. A **move** consists of choosing `0` and a 4-directionally adjacent number and swapping it.
The state of the board is solved if and only if the board is `[[1,2,3],[4,5... | dolphin | [
0.012410800904035568,
0.024356985464692116,
-0.029062505811452866,
-0.03457432612776756,
0.04307205602526665,
-0.02828356809914112,
-0.026235396042466164,
0.08270864933729172,
0.03442751243710518,
-0.006829812191426754,
0.013947839848697186,
0.012785231694579124,
-0.02880755439400673,
-0.0... | 0.846585 | 0.791763 | 0.054822 |
Please write the following solution using Elixir:
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 ... | dolphin | [
0.014343497343361378,
0.00807439535856247,
-0.020627308636903763,
-0.03443413972854614,
0.029938720166683197,
-0.033254899084568024,
-0.044743187725543976,
0.051316458731889725,
0.02650248073041439,
-0.018191905692219734,
0.02673811838030815,
0.028313713148236275,
-0.028875648975372314,
-0... | 0.847296 | 0.790672 | 0.056624 |
Please focus on the efficiency of this problem and provide code in Kotlin:
Given an array of integers `nums` and an integer `k`, return _the total number of subarrays whose sum equals to_ `k`.
A subarray is a contiguous **non-empty** sequence of elements within an array.
**Example 1:**
**Input:** nums = \[1,1,1\], k... | dolphin | [
0.013221042230725288,
0.02796892076730728,
-0.032895203679800034,
-0.021664433181285858,
0.038490090519189835,
-0.00033551116939634085,
-0.024798236787319183,
0.04152004420757294,
0.023558182641863823,
-0.0097679877653718,
0.021208902820944786,
0.028332103043794632,
-0.03936045616865158,
-... | 0.841243 | 0.776323 | 0.06492 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
Given a positive integer `num`, split it into two non-negative integers `num1` and `num2` such that:
* The concatenation of `num1` and `num2` is a permutation of `num`.
* In other words, the sum of the number of occurrences ... | dolphin | [
-0.0047359103336930275,
0.028829475864768028,
-0.013784000650048256,
-0.027544183656573296,
0.04027931019663811,
-0.01596316322684288,
-0.028916453942656517,
0.07850822806358337,
0.02744741179049015,
-0.01752392388880253,
0.020695094019174576,
0.03522161394357681,
-0.036020081490278244,
-0... | 0.841809 | 0.77742 | 0.064389 |
Please write the following solution using Scala:
Given an integer array `nums`, return _the **maximum possible sum** of elements of the array such that it is divisible by three_.
**Example 1:**
**Input:** nums = \[3,6,5,1,8\]
**Output:** 18
**Explanation:** Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divi... | dolphin | [
0.02122626081109047,
0.022137094289064407,
-0.022128865122795105,
-0.02998330444097519,
0.06015441566705704,
-0.038957756012678146,
-0.018461737781763077,
0.03444686532020569,
0.016568288207054138,
0.001063883421011269,
0.0347864143550396,
0.043370526283979416,
-0.03258546069264412,
-0.026... | 0.830508 | 0.774558 | 0.05595 |
Please write the following solution using R:
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 **different** lengths, or
* Th... | dolphin | [
0.021266860887408257,
0.03220932185649872,
-0.03164900094270706,
-0.02183150127530098,
0.0334743969142437,
-0.02673199586570263,
-0.03103262558579445,
0.05387205630540848,
0.03816164284944534,
0.01186569407582283,
0.02729426696896553,
0.026534976437687874,
-0.03676164522767067,
-0.00029195... | 0.832276 | 0.771311 | 0.060965 |
Please write the following solution using java:
You are given a list of `preferences` for `n` friends, where `n` is always **even**.
For each person `i`, `preferences[i]` contains a list of friends **sorted** in the **order of preference**. In other words, a friend earlier in the list is more preferred than a friend l... | dolphin | [
0.014377569779753685,
0.014283675700426102,
-0.04350290820002556,
-0.018547510728240013,
0.025840571150183678,
-0.033314451575279236,
-0.014420846477150917,
0.024255137890577316,
0.02724703773856163,
-0.017237354069948196,
0.0347171276807785,
0.029727598652243614,
-0.024129942059516907,
-0... | 0.845152 | 0.789226 | 0.055926 |
Please write the following solution using 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 adjacent box. Box `i` is adjacent to box `j... | dolphin | [
0.014118143357336521,
0.019347423687577248,
-0.03596813604235649,
-0.010722316801548004,
0.02335730381309986,
-0.021999720484018326,
-0.02305704914033413,
0.07857100665569305,
0.035274799913167953,
-0.003974399529397488,
0.013584182597696781,
0.026545405387878418,
-0.02583775483071804,
-0.... | 0.842577 | 0.782174 | 0.060404 |
Please explain the reasoning behind the following solution and provide code in Scheme:
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\]
... | dolphin | [
0.01624114438891411,
0.02075718343257904,
-0.007731000427156687,
-0.019315727055072784,
0.039797957986593246,
-0.01850544475018978,
-0.03597960248589516,
0.05425892770290375,
0.043912023305892944,
-0.012069989927113056,
0.03517933934926987,
0.022699328139424324,
-0.048461318016052246,
-0.0... | 0.836674 | 0.776119 | 0.060555 |
Please focus on the functionality of this problem and provide code in F#:
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:**
**Input:** n... | dolphin | [
0.014133701100945473,
0.024842241778969765,
-0.03142116591334343,
-0.01935284025967121,
0.05633680522441864,
-0.0326019786298275,
-0.011742453090846539,
0.0635293647646904,
0.03395935148000717,
-0.007784516084939241,
0.02423437498509884,
0.01402326300740242,
-0.03829991817474365,
-0.024018... | 0.850758 | 0.794029 | 0.056729 |
Please focus on the efficiency of this problem and provide code in java:
You are given an array of integers `nums` represents the numbers written on a chalkboard.
Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the el... | dolphin | [
0.026588337495923042,
0.03748974949121475,
-0.052934858947992325,
-0.010565550997853279,
0.02089150808751583,
-0.036371972411870956,
-0.012155775912106037,
0.06383425742387772,
0.039883796125650406,
-0.03066168911755085,
0.029422562569379807,
0.011175965890288353,
-0.01548007596284151,
-0.... | 0.846179 | 0.792804 | 0.053375 |
Please explain the following problem in detail and provide code in c++:
You are given an array of strings `arr`. A string `s` is formed by the **concatenation** of a **subsequence** of `arr` that has **unique characters**.
Return _the **maximum** possible length_ of `s`.
A **subsequence** is an array that can be deri... | dolphin | [
0.01190883293747902,
0.018867837265133858,
-0.0055481004528701305,
-0.038987576961517334,
0.042806535959243774,
-0.022137589752674103,
-0.0312960185110569,
0.07217183709144592,
0.04083739221096039,
-0.02465653046965599,
0.03221471607685089,
0.03172898665070534,
-0.02692345529794693,
-0.022... | 0.832722 | 0.778833 | 0.053889 |
Please write the following solution using R:
Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`.
**Example 1:**
**Input:** n = 3
**Output:** 5
**Example 2:**
**Input:** n = 1
**Output:** 1
**Constraints:*... | dolphin | [
0.01627335697412491,
0.024432936683297157,
-0.051501352339982986,
-0.02794063277542591,
0.03783348947763443,
-0.028530986979603767,
-0.01406515296548605,
0.04063478112220764,
0.044156622141599655,
-0.007174417842179537,
0.01605309545993805,
0.030314240604639053,
-0.03630170598626137,
-0.01... | 0.830978 | 0.772724 | 0.058254 |
Please write the following solution using Haskell:
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 can jump to any `nums[i... | dolphin | [
0.017521057277917862,
0.021679455414414406,
-0.006476615555584431,
-0.020983679220080376,
0.05229385197162628,
-0.02261972613632679,
-0.022008482366800308,
0.05355969816446304,
0.04003819823265076,
-0.008971884846687317,
0.01229363027960062,
0.03179469332098961,
-0.02094586007297039,
-0.02... | 0.847527 | 0.788054 | 0.059472 |
Please focus on the algorithm of this problem and provide code in C#:
You are given a **0-indexed** array of non-negative integers `nums`. For each integer in `nums`, you must find its respective **second greater** integer.
The **second greater** integer of `nums[i]` is `nums[j]` such that:
* `j > i`
* `nums[j] >... | dolphin | [
0.026171885430812836,
0.02753923088312149,
-0.023216504603624344,
-0.03188303858041763,
0.01891789212822914,
-0.024580834433436394,
-0.018465640023350716,
0.09813538938760757,
0.04307464137673378,
-0.02018623985350132,
0.030182844027876854,
0.02711513824760914,
-0.05394139513373375,
-0.012... | 0.843252 | 0.785119 | 0.058133 |
Please write the following solution using Swift:
The **Fibonacci numbers**, commonly denoted `F(n)` form a sequence, called the **Fibonacci sequence**, such that each number is the sum of the two preceding ones, starting from `0` and `1`. That is,
F(0) = 0, F(1) = 1
F(n) = F(n - 1) + F(n - 2), for n > 1.
Given `n`, c... | dolphin | [
0.013183697126805782,
0.025248421356081963,
-0.03716990724205971,
-0.03598005324602127,
0.05324126034975052,
-0.020007509738206863,
-0.035792019218206406,
0.06112968176603317,
0.0300239697098732,
-0.0001370713289361447,
0.03305855393409729,
0.02406788431107998,
-0.051158737391233444,
-0.03... | 0.819046 | 0.76326 | 0.055786 |
Please focus on the efficiency of this problem and provide code in c++:
You are given an array `pairs`, where `pairs[i] = [xi, yi]`, and:
* There are no duplicates.
* `xi < yi`
Let `ways` be the number of rooted trees that satisfy the following conditions:
* The tree consists of nodes whose values appeared in ... | dolphin | [
0.015437446534633636,
0.022421685978770256,
-0.02917388826608658,
-0.011695126071572304,
0.014370923861861229,
-0.0078579718247056,
-0.014900547452270985,
0.10904540866613388,
0.03140692040324211,
-0.018986474722623825,
0.028485387563705444,
0.02017037570476532,
-0.01467104721814394,
-0.02... | 0.84706 | 0.789345 | 0.057715 |
Please write the following solution using Lua:
Given an integer array `nums` and an integer `k`, return the maximum sum of a **non-empty** subsequence of that array such that for every two **consecutive** integers in the subsequence, `nums[i]` and `nums[j]`, where `i < j`, the condition `j - i <= k` is satisfied.
A _s... | dolphin | [
0.01662549003958702,
0.03160033002495766,
-0.03826683387160301,
-0.04416131600737572,
0.052024707198143005,
-0.006070167291909456,
-0.03093043528497219,
0.04443339258432388,
0.030530959367752075,
-0.01951993629336357,
0.04153086245059967,
0.04218049719929695,
-0.042854249477386475,
0.02049... | 0.847722 | 0.789563 | 0.058159 |
Please explain the following problem in detail and provide code in PHP:
You are given an integer array `nums`.
In one move, you can choose one element of `nums` and change it to **any value**.
Return _the minimum difference between the largest and smallest value of `nums` **after performing at most three moves**_.
*... | dolphin | [
0.013417504727840424,
0.034568142145872116,
-0.021938208490610123,
-0.022141721099615097,
0.04120619595050812,
-0.022884327918291092,
-0.033195555210113525,
0.07281101495027542,
0.03648369386792183,
-0.016326287761330605,
0.03910687938332558,
0.027804814279079437,
-0.043319933116436005,
-0... | 0.848473 | 0.79141 | 0.057063 |
Please focus on the functionality of this problem and provide code in Visual Basic .NET:
Given a **0-indexed** integer array `nums` of size `n`, find the **maximum difference** between `nums[i]` and `nums[j]` (i.e., `nums[j] - nums[i]`), such that `0 <= i < j < n` and `nums[i] < nums[j]`.
Return _the **maximum differe... | dolphin | [
0.02728106640279293,
0.022916162386536598,
-0.028016120195388794,
-0.0139742037281394,
0.04136066883802414,
-0.03081902489066124,
-0.03128676488995552,
0.07604812830686569,
0.050409384071826935,
-0.026641681790351868,
0.0360090434551239,
0.02852262184023857,
-0.04628123715519905,
-0.002109... | 0.841774 | 0.785993 | 0.055782 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You have `n` bulbs in a row numbered from `1` to `n`. Initially, all the bulbs are turned off. We turn on **exactly one** bulb every day until all bulbs are on after `n` days.
You are given an array `bulbs` of length `n` where `bulbs[i] = x` me... | dolphin | [
0.010372420772910118,
0.04793098568916321,
-0.030761055648326874,
-0.030459394678473473,
0.02097700536251068,
-0.04997111111879349,
-0.032473549246788025,
0.08244899660348892,
0.022608796134591103,
-0.015643024817109108,
0.027023261412978172,
0.03301641345024109,
-0.017293144017457962,
-0.... | 0.850474 | 0.79419 | 0.056283 |
Please focus on the functionality of this problem and provide code in Dart:
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:** nums = \[1... | dolphin | [
0.033194880932569504,
0.025194749236106873,
-0.010261294431984425,
-0.016624486073851585,
0.037033114582300186,
-0.03236928582191467,
-0.010898178443312645,
0.05232255533337593,
0.05061090365052223,
-0.025142556056380272,
0.03540055453777313,
0.019641399383544922,
-0.03937434405088425,
-0.... | 0.844642 | 0.790306 | 0.054337 |
Please write the following solution using Clojure:
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` **(inclus... | dolphin | [
0.02499592863023281,
0.03318989276885986,
-0.02745908498764038,
-0.025603143498301506,
0.034370340406894684,
-0.03312884643673897,
-0.02414442040026188,
0.04675998538732529,
0.05086521431803703,
-0.011077707633376122,
0.025260532274842262,
0.022576402872800827,
-0.016749760136008263,
-0.02... | 0.846655 | 0.790618 | 0.056037 |
Please explain the following problem in detail and provide code in C#:
Given an `n x n` integer matrix `grid`, return _the minimum sum of a **falling path with non-zero shifts**_.
A **falling path with non-zero shifts** is a choice of exactly one element from each row of `grid` such that no two elements chosen in adja... | dolphin | [
-0.012850421480834484,
0.018646394833922386,
-0.023597020655870438,
-0.03432830050587654,
0.05015939846634865,
-0.03434408828616142,
-0.02002302184700966,
0.07344312965869904,
0.04666941985487938,
-0.009437581524252892,
0.020534740760922432,
0.0032810147386044264,
-0.0403125025331974,
-0.0... | 0.84247 | 0.784749 | 0.057721 |
Please write the following solution using PHP:
You are given an integer array `nums` of **even** length `n` and an integer `limit`. In one move, you can replace any integer from `nums` with another integer between `1` and `limit`, inclusive.
The array `nums` is **complementary** if for all indices `i` (**0-indexed**),... | dolphin | [
0.003507683053612709,
0.04493552818894386,
-0.015020666643977165,
-0.013862403109669685,
0.02661680243909359,
-0.021493684500455856,
-0.0316150039434433,
0.07381664216518402,
0.03760776296257973,
-0.030815700069069862,
0.01173295360058546,
0.01588865928351879,
-0.04715593159198761,
-0.0159... | 0.853707 | 0.798999 | 0.054708 |
Please write the following solution using c++:
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 generated so that the answer fit... | dolphin | [
0.010778597556054592,
0.02706546150147915,
-0.008802054449915886,
-0.01838178001344204,
0.03908996284008026,
-0.00658482825383544,
-0.032809365540742874,
0.09600289911031723,
0.0328345000743866,
-0.02836819738149643,
0.03380994126200676,
0.013551305048167706,
-0.02621275559067726,
-0.01821... | 0.846976 | 0.777474 | 0.069502 |
Please explain the following problem in detail and provide code in Objective-C:
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 - 1` wher... | dolphin | [
0.02749103493988514,
0.029663586989045143,
-0.028812509030103683,
-0.02081318013370037,
0.038969736546278,
-0.021408667787909508,
-0.021124575287103653,
0.07514762133359909,
0.027690932154655457,
-0.011644141748547554,
0.027615392580628395,
0.0185715239495039,
-0.0285173412412405,
-0.00811... | 0.847167 | 0.792816 | 0.05435 |
Please explain the following problem in detail and provide code in java:
Given an integer array `nums` and two integers `lower` and `upper`, return _the number of range sums that lie in_ `[lower, upper]` _inclusive_.
Range sum `S(i, j)` is defined as the sum of the elements in `nums` between indices `i` and `j` inclus... | dolphin | [
-0.0051398975774645805,
0.021647533401846886,
-0.0490630604326725,
-0.015993837267160416,
0.04549235478043556,
-0.016860121861100197,
-0.038084477186203,
0.04462548345327377,
0.02786070853471756,
-0.011570889502763748,
0.03761634603142738,
0.04468722268939018,
-0.03341657295823097,
-0.0270... | 0.834542 | 0.769557 | 0.064985 |
Please write the following solution using R:
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 sum of the elements in `mid`, ... | dolphin | [
0.02925138548016548,
0.016205186024308205,
-0.033438790589571,
-0.027631770819425583,
0.0338260754942894,
-0.0006200936040841043,
-0.037392668426036835,
0.05519866570830345,
0.024921657517552376,
-0.003133461344987154,
0.004550983663648367,
0.029194651171565056,
-0.03918988257646561,
-0.04... | 0.835201 | 0.779334 | 0.055867 |
Please write the following solution using Julia:
Given an array of positive integers `arr`, return _the sum of all possible **odd-length subarrays** of_ `arr`.
A **subarray** is a contiguous subsequence of the array.
**Example 1:**
**Input:** arr = \[1,4,2,5,3\]
**Output:** 58
**Explanation:** The odd-length subarra... | dolphin | [
-0.010366014204919338,
0.02564960904419422,
-0.03855690732598305,
-0.04075699299573898,
0.02870786003768444,
-0.013184422627091408,
-0.042709074914455414,
0.05651046335697174,
0.05714067071676254,
-0.005352556239813566,
0.010866211727261543,
-0.00336765986867249,
-0.04299845173954964,
-0.0... | 0.831185 | 0.772358 | 0.058827 |
Please write the following solution using C#:
You are given an `m x n` matrix `M` initialized with all `0`'s and an array of operations `ops`, where `ops[i] = [ai, bi]` means `M[x][y]` should be incremented by one for all `0 <= x < ai` and `0 <= y < bi`.
Count and return _the number of maximum integers in the matrix a... | dolphin | [
0.03597854822874069,
0.015776628628373146,
-0.03353017568588257,
-0.03596693277359009,
0.03704863041639328,
-0.03372715786099434,
-0.04420459643006325,
0.08032897114753723,
0.03663305938243866,
-0.011766248382627964,
0.008133647963404655,
0.025179263204336166,
-0.041813984513282776,
-0.036... | 0.847943 | 0.783103 | 0.06484 |
Please focus on the efficiency of this problem and provide code in ANSI C:
Given an array `nums` sorted in **non-decreasing** order, return _the maximum between the number of positive integers and the number of negative integers._
* In other words, if the number of positive integers in `nums` is `pos` and the number... | dolphin | [
0.01921699196100235,
0.021250059828162193,
-0.03467515856027603,
-0.014798509888350964,
0.008927664719522,
-0.01683465950191021,
-0.055916644632816315,
0.061774298548698425,
0.031606096774339676,
-0.017308562994003296,
0.027631551027297974,
0.03790980204939842,
-0.035700589418411255,
-0.01... | 0.840584 | 0.780706 | 0.059878 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
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`.... | dolphin | [
0.019059032201766968,
0.04630483314394951,
-0.01564808189868927,
-0.019651150330901146,
0.0418512299656868,
-0.04393309727311134,
-0.03308233618736267,
0.07436247915029526,
0.027696575969457626,
-0.025061780586838722,
0.025770632550120354,
0.008935985155403614,
-0.0397079773247242,
-0.0152... | 0.847928 | 0.794295 | 0.053633 |
Please write the following solution using Objective-C:
You are given the `root` of a binary tree and an integer `distance`. A pair of two different **leaf** nodes of a binary tree is said to be good if the length of **the shortest path** between them is less than or equal to `distance`.
Return _the number of good leaf... | dolphin | [
0.018392007797956467,
0.023862522095441818,
-0.04952690005302429,
-0.029714005067944527,
0.03372911363840103,
-0.03555448353290558,
-0.02492556907236576,
0.04885302111506462,
0.02838563174009323,
-0.024731485173106194,
0.03387724608182907,
0.008983287960290909,
-0.02924198843538761,
-0.008... | 0.836299 | 0.782118 | 0.054181 |
Please write the following solution using Objective-C:
You are given an integer array `cards` where `cards[i]` represents the **value** of the `ith` card. A pair of cards are **matching** if the cards have the **same** value.
Return _the **minimum** number of **consecutive** cards you have to pick up to have a pair of... | dolphin | [
0.017019327729940414,
0.026491958647966385,
-0.04839235544204712,
-0.028684381395578384,
0.03652223199605942,
-0.010992865078151226,
-0.030441587790846825,
0.05641131475567818,
0.021776409819722176,
-0.03611863777041435,
0.018794747069478035,
0.010669169016182423,
-0.02568637952208519,
-0.... | 0.840266 | 0.781138 | 0.059128 |
Please focus on the efficiency of this problem and provide code in R:
In a linked list of size `n`, where `n` is **even**, the `ith` node (**0-indexed**) of the linked list is known as the **twin** of the `(n-1-i)th` node, if `0 <= i <= (n / 2) - 1`.
* For example, if `n = 4`, then node `0` is the twin of node `3`, ... | dolphin | [
0.031023681163787842,
0.03901622071862221,
-0.023250404745340347,
-0.03720606863498688,
0.024268142879009247,
-0.010867390781641006,
-0.021352233365178108,
0.06047468259930611,
0.039106521755456924,
-0.006961604114621878,
0.008606291376054287,
0.03714098781347275,
-0.02437247894704342,
-0.... | 0.832684 | 0.777223 | 0.055462 |
Please write the following solution using Objective-C:
Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return _an array of the values of all nodes that have a distance_ `k` _from the target node._
You can return the answer in **any order**.
**Example 1:**
**Input:** root =... | dolphin | [
0.03273177146911621,
0.0453442707657814,
-0.04152936488389969,
-0.032903656363487244,
0.03977741673588753,
-0.0515885166823864,
-0.009784471243619919,
0.04467197507619858,
0.042004864662885666,
-0.019376007840037346,
0.05516095086932182,
0.0048408787697553635,
-0.02897023968398571,
0.00395... | 0.825326 | 0.771304 | 0.054023 |
Please focus on the algorithm of this problem and provide code in java:
Given two positive integers `a` and `b`, return _the number of **common** factors of_ `a` _and_ `b`.
An integer `x` is a **common factor** of `a` and `b` if `x` divides both `a` and `b`.
**Example 1:**
**Input:** a = 12, b = 6
**Output:** 4
**Ex... | dolphin | [
0.025137312710285187,
0.03328182175755501,
-0.04142376035451889,
-0.004811957012861967,
0.033333130180835724,
-0.020530283451080322,
-0.017391586676239967,
0.051172588020563126,
0.013496802188456059,
-0.039223842322826385,
0.011052651330828667,
0.030565310269594193,
-0.017938513308763504,
... | 0.820291 | 0.763665 | 0.056627 |
Please write the following solution using Groovy:
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.026019208133220673,
0.02014569751918316,
-0.02452218346297741,
-0.023630328476428986,
0.03437885642051697,
-0.034729890525341034,
-0.027967263013124466,
0.046077851206064224,
0.047731753438711166,
-0.014046390540897846,
0.023393778130412102,
0.024492919445037842,
-0.018213912844657898,
-... | 0.851584 | 0.792542 | 0.059042 |
Please write the following solution using ANSI C:
Given two integer arrays `nums1` and `nums2` of length `n`, count the pairs of indices `(i, j)` such that `i < j` and `nums1[i] + nums1[j] > nums2[i] + nums2[j]`.
Return _the **number of pairs** satisfying the condition._
**Example 1:**
**Input:** nums1 = \[2,1,2,1\]... | dolphin | [
0.012367167510092258,
0.02567438967525959,
-0.03184743970632553,
-0.030319280922412872,
0.04139985516667366,
-0.008521187119185925,
-0.049264080822467804,
0.0765438973903656,
0.026366718113422394,
-0.017510896548628807,
0.009639396332204342,
0.009565610438585281,
-0.05551392585039139,
-0.0... | 0.842646 | 0.769009 | 0.073637 |
Please focus on the efficiency of this problem and provide code in c++:
Given an integer array `nums`, return _the **maximum possible sum** of elements of the array such that it is divisible by three_.
**Example 1:**
**Input:** nums = \[3,6,5,1,8\]
**Output:** 18
**Explanation:** Pick numbers 3, 6, 1 and 8 their sum ... | dolphin | [
0.025829726830124855,
0.01826493628323078,
-0.024528270587325096,
-0.03121132217347622,
0.05316074192523956,
-0.020406320691108704,
-0.032407041639089584,
0.08357914537191391,
0.02837221883237362,
0.001855063601396978,
0.03700970485806465,
0.04617408663034439,
-0.03623822703957558,
-0.0230... | 0.835516 | 0.775743 | 0.059773 |
Please explain the following problem in detail and provide code in c++:
Given an integer array `nums`, return `0` _if the sum of the digits of the minimum integer in_ `nums` _is odd, or_ `1` _otherwise_.
**Example 1:**
**Input:** nums = \[34,23,1,24,75,33,54,8\]
**Output:** 0
**Explanation:** The minimal element is 1... | dolphin | [
-0.002179729286581278,
0.01574457623064518,
-0.022265074774622917,
-0.041447658091783524,
0.050056859850883484,
-0.006522306241095066,
-0.02056831493973732,
0.09079175442457199,
0.037271950393915176,
-0.0008879419765435159,
0.010163769125938416,
0.01957623101770878,
-0.03240896761417389,
-... | 0.835126 | 0.774261 | 0.060865 |
Please focus on the algorithm of this problem and provide code in R:
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:**
**Input:** n... | dolphin | [
0.010745692066848278,
0.03051299974322319,
-0.03647048771381378,
-0.01474310364574194,
0.03225408494472504,
-0.01082612480968237,
-0.035564471036195755,
0.061499860137701035,
0.043794456869363785,
-0.015216884203255177,
0.015375805087387562,
0.025585588067770004,
-0.0341530367732048,
-0.00... | 0.844772 | 0.782613 | 0.062159 |
Please write the following solution using Haskell:
You are given an integer `n` denoting the number of nodes of a **weighted directed** graph. The nodes are numbered from `0` to `n - 1`.
You are also given a 2D integer array `edges` where `edges[i] = [fromi, toi, weighti]` denotes that there exists a **directed** edge... | dolphin | [
0.0010164177510887384,
0.014671841636300087,
-0.01957767643034458,
-0.03160934895277023,
0.04677432030439377,
-0.017864977940917015,
-0.019489048048853874,
0.037994135171175,
0.04120664298534393,
-0.006799493916332722,
0.0367739163339138,
0.02883622981607914,
-0.018496669828891754,
-0.0300... | 0.846436 | 0.79045 | 0.055986 |
Please write the following solution using Kotlin:
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 has 3 occurrences, 2 has 2 and... | dolphin | [
0.0110100656747818,
0.009684375487267971,
-0.025694511830806732,
-0.02202700637280941,
0.04373966529965401,
-0.027728168293833733,
-0.007843464612960815,
0.06622441112995148,
0.037116069346666336,
-0.024700002744793892,
0.0076569244265556335,
-0.004740212578326464,
-0.008809599094092846,
-... | 0.827687 | 0.768356 | 0.059331 |
Please explain the following problem in detail and provide code in python:
Given an array of positive integers `nums`, return the _maximum possible sum of an **ascending** subarray in_ `nums`.
A subarray is defined as a contiguous sequence of numbers in an array.
A subarray `[numsl, numsl+1, ..., numsr-1, numsr]` is ... | dolphin | [
0.02107209712266922,
0.03573210909962654,
-0.02335631474852562,
-0.027064086869359016,
0.030748752877116203,
-0.0166784655302763,
-0.03435874730348587,
0.05196281149983406,
0.03533386066555977,
-0.0004921612562611699,
0.03407159820199013,
0.02642904222011566,
-0.054685499519109726,
0.01032... | 0.828957 | 0.769465 | 0.059492 |
Please explain the reasoning behind the following solution and provide code in Scala:
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` betw... | dolphin | [
0.023092731833457947,
0.023177247494459152,
-0.0168228168040514,
-0.01799686998128891,
0.04076346382498741,
-0.03567245975136757,
-0.026434103026986122,
0.056359175592660904,
0.03813515231013298,
-0.007763667497783899,
0.019950581714510918,
0.023769982159137726,
-0.012633783742785454,
-0.0... | 0.844564 | 0.788374 | 0.05619 |
Please write the following solution using Go:
Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _such that:_
* `0 <= i < j <= n - 1` _and_
* `nums[i] * nums[j]` _is divisible by_ `k`.
**Example 1:**
**Input:** nums = \[1,2,3,4,5\], k = 2
**Outp... | dolphin | [
0.0159323588013649,
0.04187729209661484,
-0.034636471420526505,
-0.024761145934462547,
0.057975418865680695,
-0.024136006832122803,
-0.029426051303744316,
0.0691199079155922,
0.03279717639088631,
-0.004756948910653591,
0.012744233943521976,
0.01903417333960533,
-0.023148100823163986,
-0.03... | 0.844925 | 0.785181 | 0.059744 |
Please explain the reasoning behind the following solution and provide code in Object Pascal:
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 <... | dolphin | [
0.01315690204501152,
0.042564962059259415,
-0.019244413822889328,
-0.03612842783331871,
0.034842099994421005,
-0.015574314631521702,
-0.015279141254723072,
0.06247222423553467,
0.02715892903506756,
-0.0017165408935397863,
0.029431745409965515,
0.032914865761995316,
-0.027264351025223732,
-... | 0.843743 | 0.788623 | 0.05512 |
Please focus on the functionality of this problem and provide code in javascript:
Given an array of integers, return the maximum sum for a **non-empty** subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there... | dolphin | [
0.024893516674637794,
0.021454572677612305,
-0.033347565680742264,
-0.031340230256319046,
0.043699923902750015,
-0.021866993978619576,
-0.025003187358379364,
0.0492606982588768,
0.039423342794179916,
-0.01818440854549408,
0.026359455659985542,
0.01881691999733448,
-0.027323685586452484,
0.... | 0.836877 | 0.781764 | 0.055112 |
Please focus on the algorithm of this problem and provide code in ANSI C:
You are given a **0-indexed** string `word` of length `n` consisting of digits, and a positive integer `m`.
The **divisibility array** `div` of `word` is an integer array of length `n` such that:
* `div[i] = 1` if the **numeric value** of `wo... | dolphin | [
0.020241443067789078,
0.015613839961588383,
-0.008060349151492119,
-0.04185757413506508,
0.033143509179353714,
-0.060836367309093475,
-0.0346585288643837,
0.08471418917179108,
0.03738461434841156,
-0.01803753338754177,
0.038315899670124054,
0.013790655881166458,
-0.04822969436645508,
-0.02... | 0.837222 | 0.78318 | 0.054042 |
Please write the following solution using python:
Given an array of integers, return the maximum sum for a **non-empty** subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element l... | dolphin | [
0.03430376201868057,
0.022897977381944656,
-0.0322512686252594,
-0.033158011734485626,
0.04126141965389252,
-0.0188240185379982,
-0.03120972216129303,
0.03937092050909996,
0.03363843262195587,
-0.015909548848867416,
0.020935382694005966,
0.019919300451874733,
-0.025322694331407547,
0.00419... | 0.833406 | 0.773075 | 0.060331 |
Please write the following solution using ANSI C:
You are given an integer array `nums` consisting of `2 * n` integers.
You need to divide `nums` into `n` pairs such that:
* Each element belongs to **exactly one** pair.
* The elements present in a pair are **equal**.
Return `true` _if nums can be divided into_ `... | dolphin | [
0.019042937085032463,
0.03521411493420601,
-0.03430968150496483,
-0.026565048843622208,
0.03689482808113098,
-0.020486248657107353,
-0.010708684101700783,
0.07418621331453323,
0.025150848552584648,
-0.02902531810104847,
0.018808575347065926,
0.01734890788793564,
-0.02192034013569355,
-0.02... | 0.844788 | 0.782303 | 0.062485 |
Please focus on the efficiency of this problem and provide code in Scala:
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 tha... | dolphin | [
0.01521958690136671,
0.026518752798438072,
-0.03703663870692253,
-0.003007336053997278,
0.03097797930240631,
-0.04077914357185364,
-0.03847659006714821,
0.04307836666703224,
0.039776187390089035,
-0.01727844402194023,
0.022937849164009094,
0.004096554592251778,
-0.02233591116964817,
-0.014... | 0.842453 | 0.784756 | 0.057697 |
Please write the following solution using Scheme:
You are given a **0-indexed** integer array `nums` of length `n`.
The **average difference** of the index `i` is the **absolute** **difference** between the average of the **first** `i + 1` elements of `nums` and the average of the **last** `n - i - 1` elements. Both a... | dolphin | [
0.01685303822159767,
0.03508908674120903,
-0.02840607240796089,
-0.03314290568232536,
0.04725383222103119,
-0.03550121188163757,
-0.05867692828178406,
0.04905771091580391,
0.03646146506071091,
-0.018869124352931976,
0.02956455759704113,
0.012372735887765884,
-0.04067952185869217,
0.0111598... | 0.829775 | 0.772152 | 0.057622 |
Please focus on the functionality of this problem and provide code in Swift:
You are given an integer array `coins` of length `n` which represents the `n` coins that you own. The value of the `ith` coin is `coins[i]`. You can **make** some value `x` if you can choose some of your `n` coins such that their values sum up... | dolphin | [
0.020945195108652115,
0.030503639951348305,
-0.023692572489380836,
-0.017402758821845055,
0.04506126046180725,
-0.026066618040204048,
-0.04351798817515373,
0.052520573139190674,
0.03567015007138252,
-0.03245088458061218,
0.04108897224068642,
0.02667824737727642,
-0.03629608452320099,
-0.01... | 0.843278 | 0.785512 | 0.057767 |
Please explain the reasoning behind the following solution and provide code in Scheme:
You are given a **0-indexed** integer array `arr` and an integer `k`. The array `arr` is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the previ... | dolphin | [
0.015637993812561035,
0.04319232702255249,
-0.03362581133842468,
-0.04097582399845123,
0.04316624253988266,
-0.02431413158774376,
-0.041592832654714584,
0.06325116753578186,
0.03177668899297714,
-0.009657119400799274,
0.02736499160528183,
0.0025003007613122463,
-0.026156088337302208,
0.006... | 0.859051 | 0.797595 | 0.061456 |
Please explain the following problem in detail and provide code in Mojo:
Given an array of integers `arr`, and three integers `a`, `b` and `c`. You need to find the number of good triplets.
A triplet `(arr[i], arr[j], arr[k])` is **good** if the following conditions are true:
* `0 <= i < j < k < arr.length`
* `|a... | dolphin | [
0.028276579454541206,
0.02666768804192543,
-0.04294561222195625,
-0.02611924149096012,
0.038314562290906906,
-0.030693940818309784,
-0.04190495237708092,
0.037407275289297104,
0.021597513929009438,
-0.01809135265648365,
0.0020368637051433325,
0.019336502999067307,
-0.029901141300797462,
-0... | 0.840218 | 0.784327 | 0.055891 |
Please focus on the functionality of this problem and provide code in python:
You are given a **0-indexed** integer array `nums` of length `n`. You are initially standing at index `0`. You can jump from index `i` to index `j` where `i < j` if:
* `nums[i] <= nums[j]` and `nums[k] < nums[i]` for all indexes `k` in the... | dolphin | [
0.01559133268892765,
0.033746302127838135,
-0.025104936212301254,
-0.008249574340879917,
0.03556814789772034,
-0.014701435342431068,
-0.030986960977315903,
0.05259912833571434,
0.02899795025587082,
-0.001428169896826148,
0.026023225858807564,
0.019997557625174522,
-0.02541421540081501,
-0.... | 0.852399 | 0.797069 | 0.055329 |
Please focus on the algorithm of this problem and provide code in c++:
You are given an integer array `nums` and an integer `k`.
Find the longest subsequence of `nums` that meets the following requirements:
* The subsequence is **strictly increasing** and
* The difference between adjacent elements in the subseque... | dolphin | [
0.023810822516679764,
0.026843057945370674,
-0.013411886058747768,
-0.03189394250512123,
0.0320466011762619,
-0.007440601475536823,
-0.04558029770851135,
0.1031293272972107,
0.038030147552490234,
-0.016917943954467773,
0.029020624235272408,
0.028608696535229683,
-0.02774769626557827,
0.026... | 0.840682 | 0.774003 | 0.066678 |
convert this code to java:
```cpp
#include <deque>
#include <vector>
using namespace std;
int shortestSubarray(vector<int>& nums, int k) {
int n = nums.size();
vector<int> prefix_sum(n + 1, 0);
for (int i = 0; i < n; i++) prefix_sum[i + 1] = prefix_sum[i] + nums[i];
int res = n + 1;
deque<int> dq;... | dolphin | [
0.012794186361134052,
0.03271598368883133,
-0.031183214858174324,
-0.035592153668403625,
0.03529871255159378,
-0.013287641108036041,
-0.025051577016711235,
0.04833562672138214,
0.03438739478588104,
-0.013636770658195019,
0.025367017835378647,
0.01599353365600109,
-0.017056092619895935,
0.0... | 0.838045 | 0.781121 | 0.056924 |
Please focus on the functionality of this problem and provide code in Kotlin:
The **bitwise AND** of an array `nums` is the bitwise AND of all integers in `nums`.
* For example, for `nums = [1, 5, 3]`, the bitwise AND is equal to `1 & 5 & 3 = 1`.
* Also, for `nums = [7]`, the bitwise AND is `7`.
You are given an ... | dolphin | [
0.011937436647713184,
0.02919483184814453,
-0.01909620687365532,
-0.01886497437953949,
0.03928589075803757,
-0.016513807699084282,
-0.027238212525844574,
0.04736015945672989,
0.027952900156378746,
-0.01132776215672493,
0.03262080252170563,
0.04364243894815445,
-0.02835642732679844,
-0.0147... | 0.843309 | 0.782584 | 0.060725 |
Please explain the following problem in detail and provide code in Perl:
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 `a` can be o... | dolphin | [
0.02005789987742901,
0.021639741957187653,
-0.03494647517800331,
-0.0013394429115578532,
0.03514901176095009,
-0.02009981870651245,
-0.023981209844350815,
0.06050189584493637,
0.04454897344112396,
-0.016757065430283546,
0.04040321335196495,
0.03149759769439697,
-0.03198055177927017,
-0.010... | 0.839366 | 0.783073 | 0.056293 |
Please explain the following problem in detail and provide code in python:
Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_.
You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice... | dolphin | [
0.021723108366131783,
0.035651806741952896,
-0.036474671214818954,
-0.0248015858232975,
0.0476737804710865,
-0.004569198004901409,
-0.03697250783443451,
0.037669505923986435,
0.020570870488882065,
-0.0013817563885822892,
0.022542668506503105,
0.0319390706717968,
-0.03198094293475151,
-0.00... | 0.842497 | 0.787699 | 0.054798 |
Please write the following solution using Objective-C:
You are given the `root` of a binary tree with `n` nodes where each `node` in the tree has `node.val` coins. There are `n` coins in total throughout the whole tree.
In one move, we may choose two adjacent nodes and move one coin from one node to another. A move ma... | dolphin | [
0.02117729000747204,
0.03378869220614433,
-0.028359295800328255,
-0.03216938301920891,
0.019361821934580803,
-0.027855031192302704,
-0.013861104846000671,
0.07231491059064865,
0.01007281057536602,
-0.02699216455221176,
0.04532318189740181,
0.010811667889356613,
-0.025211093947291374,
-0.02... | 0.841061 | 0.78187 | 0.059191 |
Please focus on the efficiency of this problem and provide code in Elixir:
Given an integer array `nums` and an integer `k`, return the maximum sum of a **non-empty** subsequence of that array such that for every two **consecutive** integers in the subsequence, `nums[i]` and `nums[j]`, where `i < j`, the condition `j -... | dolphin | [
0.025511818006634712,
0.030244281515479088,
-0.02773923985660076,
-0.03786725178360939,
0.028941916301846504,
-0.008909245952963829,
-0.033356618136167526,
0.046479810029268265,
0.03294021263718605,
-0.013748274184763432,
0.037411995232105255,
0.03952477499842644,
-0.03366495296359062,
0.0... | 0.848645 | 0.791972 | 0.056673 |
Please explain the following problem in detail and provide code in Kotlin:
Given an array of **distinct** integers `arr`, find all pairs of elements with the minimum absolute difference of any two elements.
Return a list of pairs in ascending order(with respect to pairs), each pair `[a, b]` follows
* `a, b` are fro... | dolphin | [
0.026352141052484512,
0.03622148558497429,
-0.014094884507358074,
-0.03825278580188751,
0.04825715720653534,
-0.02374088019132614,
-0.03109000250697136,
0.04671182855963707,
0.0368444100022316,
-0.028950568288564682,
0.022788215428590775,
0.0017105446895584464,
-0.03580966591835022,
0.0170... | 0.832369 | 0.778643 | 0.053726 |
Please focus on the algorithm of this problem and provide code in Erlang:
Given an integer array `nums` and two integers `left` and `right`, return _the number of contiguous non-empty **subarrays** such that the value of the maximum array element in that subarray is in the range_ `[left, right]`.
The test cases are ge... | dolphin | [
0.028382839635014534,
0.01924433931708336,
-0.01749321073293686,
-0.026431700214743614,
0.019794393330812454,
0.0006115320138633251,
-0.02787964604794979,
0.06840066611766815,
0.0315672904253006,
-0.00829886645078659,
0.03628814220428467,
0.05449063703417778,
-0.022248512133955956,
-0.0028... | 0.848465 | 0.794928 | 0.053537 |
Please explain the following problem in detail and provide code in Kotlin:
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.020887240767478943,
0.03819341957569122,
-0.018272725865244865,
-0.026929695159196854,
0.04124467819929123,
-0.0361240953207016,
-0.03003307618200779,
0.03878308832645416,
0.024447685107588768,
-0.019337639212608337,
0.023896588012576103,
0.03562553972005844,
-0.027665408328175545,
-0.00... | 0.836021 | 0.776153 | 0.059868 |
Please write the following solution using R:
You are given two **0-indexed** integer arrays `nums1` and `nums2`, both of length `n`.
You can choose two integers `left` and `right` where `0 <= left <= right < n` and **swap** the subarray `nums1[left...right]` with the subarray `nums2[left...right]`.
* For example, i... | dolphin | [
0.002598542720079422,
0.024088481441140175,
-0.03419204428792,
-0.02582526206970215,
0.026289861649274826,
-0.0003039748116862029,
-0.04314849153161049,
0.04494950547814369,
0.03768716752529144,
-0.00633715046569705,
0.008454139344394207,
0.030444787815213203,
-0.041781190782785416,
-0.021... | 0.837404 | 0.775958 | 0.061446 |
Please write the following solution using Swift:
An array is **squareful** if the sum of every pair of adjacent elements is a **perfect square**.
Given an integer array nums, return _the number of permutations of_ `nums` _that are **squareful**_.
Two permutations `perm1` and `perm2` are different if there is some ind... | dolphin | [
0.011814659461379051,
0.044147130101919174,
-0.02321007288992405,
-0.031713761389255524,
0.05029381066560745,
-0.017904110252857208,
-0.024635493755340576,
0.0631357729434967,
0.027654698118567467,
-0.01592029444873333,
0.019729526713490486,
0.004557473585009575,
-0.03531615063548088,
-0.0... | 0.837066 | 0.776048 | 0.061018 |
Please explain the following problem in detail and provide code in c++:
Given a binary string `s`, you can split `s` into 3 **non-empty** strings `s1`, `s2`, and `s3` where `s1 + s2 + s3 = s`.
Return the number of ways `s` can be split such that the number of ones is the same in `s1`, `s2`, and `s3`. Since the answer ... | dolphin | [
0.022128572687506676,
0.008052335120737553,
-0.028555359691381454,
-0.03028988093137741,
0.04920901730656624,
-0.030802888795733452,
-0.031186498701572418,
0.09028267860412598,
0.01770744100213051,
-0.0035519355442374945,
0.03316647559404373,
0.03164492920041084,
-0.035342026501894,
-0.037... | 0.833021 | 0.776261 | 0.056761 |
Please write the following solution using Kotlin:
You are given a 2D integer `grid` of size `m x n` and an integer `x`. In one operation, you can **add** `x` to or **subtract** `x` from any element in the `grid`.
A **uni-value grid** is a grid where all the elements of it are equal.
Return _the **minimum** number of ... | dolphin | [
0.0010091215372085571,
0.02278997004032135,
-0.014438371174037457,
-0.04739224538207054,
0.043431270867586136,
-0.04473239183425903,
-0.020306698977947235,
0.07111643999814987,
0.03969017043709755,
-0.018802933394908905,
0.013184639625251293,
0.020636824890971184,
-0.016871418803930283,
-0... | 0.851786 | 0.794333 | 0.057453 |
Please explain the following problem in detail and provide code in Elixir:
There is an undirected graph consisting of `n` nodes numbered from `0` to `n - 1`. You are given a **0-indexed** integer array `vals` of length `n` where `vals[i]` denotes the value of the `ith` node.
You are also given a 2D integer array `edge... | dolphin | [
0.008191562257707119,
0.04102833569049835,
-0.017321845516562462,
-0.039635468274354935,
0.029642049223184586,
-0.022908486425876617,
-0.021426334977149963,
0.04670127108693123,
0.029461370781064034,
0.0004081323859281838,
0.046384502202272415,
0.029169440269470215,
-0.006489101331681013,
... | 0.842903 | 0.78933 | 0.053573 |
Please write the following solution using python:
You have `n` coins and you want to build a staircase with these coins. The staircase consists of `k` rows where the `ith` row has exactly `i` coins. The last row of the staircase **may be** incomplete.
Given the integer `n`, return _the number of **complete rows** of t... | dolphin | [
0.04123939201235771,
0.0467618890106678,
-0.0291594285517931,
-0.036481257528066635,
0.0457981713116169,
-0.025019533932209015,
-0.00978327076882124,
0.054449308663606644,
0.02686501480638981,
0.00010180982644669712,
0.04597485810518265,
0.02982022427022457,
-0.03594287484884262,
-0.006044... | 0.840614 | 0.784497 | 0.056118 |
Please explain the following problem in detail and provide code in javascript:
You are given an array `nums` consisting of **positive** integers.
Return _the number of **subarrays** of_ `nums` _that are in **strictly increasing** order._
A **subarray** is a **contiguous** part of an array.
**Example 1:**
**Input:**... | dolphin | [
0.009858626872301102,
0.041789766401052475,
-0.02222607098519802,
-0.01685945689678192,
0.03256506845355034,
-0.0016643430572003126,
-0.03696103394031525,
0.06065051630139351,
0.031189531087875366,
-0.008546493947505951,
0.021289648488163948,
0.002330558840185404,
-0.059959836304187775,
-0... | 0.836387 | 0.780805 | 0.055582 |
Please explain the following problem in detail and provide code in C#:
You are given two **0-indexed** arrays `nums` and `cost` consisting each of `n` **positive** integers.
You can do the following operation **any** number of times:
* Increase or decrease **any** element of the array `nums` by `1`.
The cost of do... | dolphin | [
0.009293272159993649,
0.030463427305221558,
-0.031130192801356316,
-0.02332760952413082,
0.033249326050281525,
-0.029437953606247902,
-0.013536072336137295,
0.09246007353067398,
0.04057301580905914,
-0.015885019674897194,
0.027737706899642944,
0.010267012752592564,
-0.03519682213664055,
-0... | 0.848993 | 0.791744 | 0.057249 |
Please explain the following problem in detail and provide code in ANSI C:
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 sub... | dolphin | [
0.040039099752902985,
0.02622794359922409,
-0.03054770641028881,
-0.015841105952858925,
0.0233237873762846,
-0.028270024806261063,
-0.039575524628162384,
0.053001824766397476,
0.04829418286681175,
-0.026889124885201454,
0.031483277678489685,
0.022404154762625694,
-0.03193161264061928,
-0.0... | 0.834614 | 0.767406 | 0.067208 |
Please explain the following problem in detail and provide code in C#:
Given an integer array `nums` **(0-indexed)** and two integers `target` and `start`, find an index `i` such that `nums[i] == target` and `abs(i - start)` is **minimized**. Note that `abs(x)` is the absolute value of `x`.
Return `abs(i - start)`.
I... | dolphin | [
0.02558462880551815,
0.03043854609131813,
-0.02813100256025791,
-0.018794452771544456,
0.04429847002029419,
-0.03232135996222496,
-0.028270311653614044,
0.08135899156332016,
0.04958866164088249,
-0.018637556582689285,
0.027553871273994446,
0.012391826137900352,
-0.029869263991713524,
-0.02... | 0.843292 | 0.789057 | 0.054235 |
Please write the following solution using Scheme:
You are given `n` balloons, indexed from `0` to `n - 1`. Each balloon is painted with a number on it represented by an array `nums`. You are asked to burst all the balloons.
If you burst the `ith` balloon, you will get `nums[i - 1] * nums[i] * nums[i + 1]` coins. If `i... | dolphin | [
0.03217190504074097,
0.04593108966946602,
-0.017734356224536896,
-0.02139849215745926,
0.034274034202098846,
-0.027183735743165016,
-0.03166678547859192,
0.05266638845205307,
0.03495390713214874,
-0.011507067829370499,
0.02919004298746586,
0.042252298444509506,
-0.03776218369603157,
-0.016... | 0.838454 | 0.779295 | 0.059159 |
Please write the following solution using Ruby:
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 appear **consecutively** in th... | dolphin | [
0.030454108491539955,
0.03153335675597191,
-0.027386415749788284,
-0.024680359289050102,
0.04065724089741707,
-0.01650446653366089,
-0.015026353299617767,
0.049173951148986816,
0.03503113240003586,
-0.0007098077912814915,
0.024230891838669777,
0.017038913443684578,
-0.0148666026070714,
-0.... | 0.834217 | 0.775796 | 0.058421 |
Please focus on the algorithm of this problem and provide code in javascript:
An array `A` is larger than some array `B` if for the first index `i` where `A[i] != B[i]`, `A[i] > B[i]`.
For example, consider `0`\-indexing:
* `[1,3,2,4] > [1,2,2,4]`, since at index `1`, `3 > 2`.
* `[1,4,4,4] < [2,1,1,1]`, since at ... | dolphin | [
0.021700631827116013,
0.0447116494178772,
-0.02351272851228714,
-0.020835550501942635,
0.020860066637396812,
-0.015168732963502407,
-0.02656148187816143,
0.05606290325522423,
0.03353090584278107,
-0.01459172647446394,
0.03212298825383186,
0.01461560744792223,
-0.03960360214114189,
0.013370... | 0.843065 | 0.785722 | 0.057343 |
Please focus on the algorithm of this problem and provide code in Scheme:
There are `m` boys and `n` girls in a class attending an upcoming party.
You are given an `m x n` integer matrix `grid`, where `grid[i][j]` equals `0` or `1`. If `grid[i][j] == 1`, then that means the `ith` boy can invite the `jth` girl to the p... | dolphin | [
-0.003351908875629306,
0.018604639917612076,
-0.02137410268187523,
-0.03614502400159836,
0.035878170281648636,
-0.055528998374938965,
-0.02805698849260807,
0.04095079004764557,
0.03503730893135071,
-0.011818521656095982,
0.028150415048003197,
0.041273050010204315,
-0.021307140588760376,
-0... | 0.847022 | 0.790986 | 0.056036 |
Please explain the following problem in detail and provide code in ANSI C:
You are given an integer array `nums`. The **absolute sum** of a subarray `[numsl, numsl+1, ..., numsr-1, numsr]` is `abs(numsl + numsl+1 + ... + numsr-1 + numsr)`.
Return _the **maximum** absolute sum of any **(possibly empty)** subarray of_ `... | dolphin | [
0.02261780947446823,
0.039158616214990616,
-0.021571677178144455,
-0.02507655881345272,
0.029138972982764244,
-0.022171827033162117,
-0.03502959385514259,
0.05557854473590851,
0.046435143798589706,
-0.011556966230273247,
0.03069286420941353,
0.02139963209629059,
-0.043095141649246216,
-0.0... | 0.830671 | 0.764905 | 0.065766 |
Please write the following solution using Visual Basic .NET:
Given a sorted integer array `nums` and an integer `n`, add/patch elements to the array such that any number in the range `[1, n]` inclusive can be formed by the sum of some elements in the array.
Return _the minimum number of patches required_.
**Example 1... | dolphin | [
0.013367438688874245,
0.029406577348709106,
-0.021465104073286057,
-0.018783623352646828,
0.04552306607365608,
-0.028538677841424942,
-0.012152406387031078,
0.0761604905128479,
0.036973677575588226,
-0.005002387799322605,
0.0037269149906933308,
0.03621075674891472,
-0.045527901500463486,
-... | 0.852564 | 0.795845 | 0.056719 |
Please explain the reasoning behind the following solution and provide code in Go:
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 `... | dolphin | [
0.019172662869095802,
0.03670888394117355,
-0.021262669935822487,
-0.03099076636135578,
0.04992973804473877,
-0.026575813069939613,
-0.016603387892246246,
0.05980709567666054,
0.03902916982769966,
-0.004001110792160034,
0.02029547467827797,
0.021410692483186722,
-0.03182653337717056,
-0.01... | 0.839947 | 0.781318 | 0.058629 |
Please focus on the algorithm of this problem and provide code in Objective-C:
Given an array `nums` of size `n`, return _the majority element_.
The majority element is the element that appears more than `⌊n / 2⌋` times. You may assume that the majority element always exists in the array.
**Example 1:**
**Input:** n... | dolphin | [
0.010829403065145016,
0.026802977547049522,
-0.03599117323756218,
-0.015157116577029228,
0.03884022310376167,
-0.03884031996130943,
-0.03435644879937172,
0.07200632989406586,
0.018804794177412987,
-0.01049474161118269,
0.02961176633834839,
0.01789761334657669,
-0.020549843087792397,
0.0022... | 0.841115 | 0.784241 | 0.056873 |
Please write the following solution using Scala:
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-empty** sequence of elemen... | dolphin | [
0.004773855675011873,
0.029131032526493073,
-0.03691551461815834,
-0.021423522382974625,
0.05860371142625809,
-0.019142426550388336,
-0.03977082669734955,
0.03382633626461029,
0.029690321534872055,
-0.005927924532443285,
0.02979235164821148,
0.04519675299525261,
-0.03890954330563545,
-0.01... | 0.83256 | 0.773764 | 0.058796 |
Please write the following solution using Fortran:
Given an integer array `nums` and an integer `k`, return _the maximum length of a_ _subarray_ _that sums to_ `k`. If there is not one, return `0` instead.
**Example 1:**
**Input:** nums = \[1,-1,5,-2,3\], k = 3
**Output:** 4
**Explanation:** The subarray \[1, -1, 5, ... | dolphin | [
0.018913252279162407,
0.03179827705025673,
-0.02184859663248062,
-0.04147603362798691,
0.04770217090845108,
-0.013919103890657425,
-0.019374992698431015,
0.041914816945791245,
0.031510792672634125,
-0.004745515063405037,
0.025065496563911438,
0.04457349702715874,
-0.029166048392653465,
0.0... | 0.841365 | 0.779123 | 0.062241 |
Please write the following solution using Dart:
You are given an integer array of unique positive integers `nums`. Consider the following graph:
* There are `nums.length` nodes, labeled `nums[0]` to `nums[nums.length - 1]`,
* There is an undirected edge between `nums[i]` and `nums[j]` if `nums[i]` and `nums[j]` sh... | dolphin | [
0.03239252045750618,
0.04412982612848282,
-0.02786264568567276,
-0.03485795855522156,
0.02840629406273365,
-0.0053817471489310265,
-0.03290386125445366,
0.04901706799864769,
0.03185978904366493,
-0.007729157339781523,
0.028825106099247932,
0.03383821249008179,
-0.02517748810350895,
-0.0166... | 0.846823 | 0.778809 | 0.068014 |
Please explain the following problem in detail and provide code in c++:
Given a **sorted** integer array `arr`, two integers `k` and `x`, return the `k` closest integers to `x` in the array. The result should also be sorted in ascending order.
An integer `a` is closer to `x` than an integer `b` if:
* `|a - x| < |b ... | dolphin | [
0.032236505299806595,
0.04286793991923332,
-0.022250093519687653,
-0.027970701456069946,
0.03462905436754227,
-0.02149311639368534,
-0.028338564559817314,
0.07880211621522903,
0.049412794411182404,
-0.007638702169060707,
0.03450921177864075,
0.015774788334965706,
-0.02409307286143303,
0.01... | 0.822303 | 0.764716 | 0.057587 |
Please explain the following problem in detail and provide code in Elixir:
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,1... | dolphin | [
0.02224288322031498,
0.025291435420513153,
-0.009203730151057243,
-0.043749138712882996,
0.024208564311265945,
-0.027170350775122643,
-0.024682333692908287,
0.04505690932273865,
0.02768903225660324,
-0.013864635489881039,
0.024236533790826797,
0.020166106522083282,
-0.02955676056444645,
-0... | 0.844605 | 0.791355 | 0.05325 |
Please explain the following problem in detail and provide code in Scheme:
You are given a **0-indexed** integer array `nums` of length `n`.
A **split** at an index `i` where `0 <= i <= n - 2` is called **valid** if the product of the first `i + 1` elements and the product of the remaining elements are coprime.
* F... | dolphin | [
0.0293479822576046,
0.04665751755237579,
-0.016700049862265587,
-0.026827894151210785,
0.04008278623223305,
-0.03446712717413902,
-0.005631360225379467,
0.07135254144668579,
0.02087067998945713,
-0.010816928930580616,
0.013502992689609528,
0.0019270681077614427,
-0.02663305029273033,
-0.02... | 0.845972 | 0.789961 | 0.056012 |
Please write the following solution using Mojo:
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 - 1` where each `adjacentPairs[i] = [ui, ... | dolphin | [
0.03442060574889183,
0.023838277906179428,
-0.027202196419239044,
-0.026508407667279243,
0.03708088397979736,
-0.017299368977546692,
-0.020172495394945145,
0.06376174092292786,
0.0398908369243145,
-0.010950477793812752,
0.01860850490629673,
0.01926381140947342,
-0.028097663074731827,
-0.02... | 0.85189 | 0.793347 | 0.058544 |
Please focus on the algorithm of this problem and provide code in Kotlin:
You are given a **0-indexed** integer array `nums`.
The **concatenation** of two numbers is the number formed by concatenating their numerals.
* For example, the concatenation of `15`, `49` is `1549`.
The **concatenation value** of `nums` is... | dolphin | [
0.015423589386045933,
0.03724721819162369,
-0.010633724741637707,
-0.02859199419617653,
0.04696183279156685,
-0.027072882279753685,
-0.0206984244287014,
0.07466063648462296,
0.03884578496217728,
-0.016892196610569954,
0.014408325776457787,
0.02504214271903038,
-0.023730318993330002,
0.0003... | 0.843448 | 0.790161 | 0.053287 |
Please focus on the functionality of this problem and provide code in Haskell:
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 **adja... | dolphin | [
0.020755235105752945,
0.012227392755448818,
-0.007327639032155275,
-0.03005729243159294,
0.0366789773106575,
-0.023816287517547607,
-0.027294468134641647,
0.05418413132429123,
0.03176889568567276,
-0.014208677224814892,
0.029857082292437553,
0.02357788383960724,
-0.02738676592707634,
-0.01... | 0.840225 | 0.783292 | 0.056933 |
Please explain the following problem in detail and provide code in Objective-C:
You are given a positive integer array `grades` which represents the grades of students in a university. You would like to enter **all** these students into a competition in **ordered** non-empty groups, such that the ordering meets the fol... | dolphin | [
0.0028110798448324203,
0.022759266197681427,
-0.03853760287165642,
-0.04234440252184868,
0.04306964576244354,
-0.030557673424482346,
-0.042548421770334244,
0.06122623011469841,
0.010829304344952106,
-0.00973836611956358,
0.01522006094455719,
0.02328672632575035,
-0.05185992643237114,
-0.02... | 0.831162 | 0.777335 | 0.053827 |
Please write the following solution using Dart:
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.
_Return the sum of the numbers f... | dolphin | [
0.015593348070979118,
0.03361973538994789,
-0.022425111383199692,
-0.035252150148153305,
0.030395543202757835,
-0.005236482713371515,
-0.033708956092596054,
0.04394249990582466,
0.03188586235046387,
-0.004771384876221418,
0.024563470855355263,
0.027743633836507797,
-0.04704592749476433,
-0... | 0.846728 | 0.786504 | 0.060223 |
Please write the following solution using Lisp:
You are given a 0-indexed integer array `nums`. You are allowed to permute `nums` into a new array `perm` of your choosing.
We define the **greatness** of `nums` be the number of indices `0 <= i < nums.length` for which `perm[i] > nums[i]`.
Return _the **maximum** possi... | dolphin | [
0.015062728896737099,
0.041949182748794556,
-0.0036934870295226574,
-0.03660429269075394,
0.023638073354959488,
-0.022039301693439484,
-0.033676426857709885,
0.04585687816143036,
0.03265250846743584,
-0.004821680951863527,
0.018458735197782516,
0.022907264530658722,
-0.037370603531599045,
... | 0.843485 | 0.78957 | 0.053915 |
Please focus on the efficiency of this problem and provide code in Go:
Given an integer array `nums` and an integer `k`, return _the number of non-empty **subarrays** that have a sum divisible by_ `k`.
A **subarray** is a **contiguous** part of an array.
**Example 1:**
**Input:** nums = \[4,5,0,-2,-3,1\], k = 5
**Ou... | dolphin | [
0.009265695698559284,
0.03027576208114624,
-0.0331343412399292,
-0.01903352700173855,
0.03959532454609871,
-0.021840207278728485,
-0.031197115778923035,
0.059813812375068665,
0.03589463233947754,
0.0037761505227535963,
0.029544614255428314,
0.02386392466723919,
-0.03261126950383186,
-0.015... | 0.841555 | 0.786453 | 0.055102 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.