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 javascript:
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 to `x`.
Return the _m... | dolphin | [
0.02725829929113388,
0.03634539246559143,
-0.023473365232348442,
-0.016817521303892136,
0.03654761239886284,
-0.022568752989172935,
-0.0401405431330204,
0.04535222426056862,
0.03640737384557724,
-0.03137708455324173,
0.03656548261642456,
0.026695266366004944,
-0.038101743906736374,
-0.0218... | 0.841506 | 0.777795 | 0.063711 |
Please write the following solution using java:
You are given a binary string `s`. You are allowed to perform two types of operations on the string in any sequence:
* **Type-1: Remove** the character at the start of the string `s` and **append** it to the end of the string.
* **Type-2: Pick** any character in `s` ... | dolphin | [
0.02532849833369255,
0.030281195417046547,
-0.007879319600760937,
-0.021871598437428474,
0.03186042234301567,
-0.05613447725772858,
-0.014831415377557278,
0.05907832086086273,
0.024738553911447525,
-0.025804871693253517,
0.018122423440217972,
0.0031008117366582155,
-0.026404401287436485,
-... | 0.841664 | 0.787583 | 0.054081 |
Please focus on the algorithm of this problem and provide code in c++:
Given a 2D `grid` consists of `0s` (land) and `1s` (water). An _island_ is a maximal 4-directionally connected group of `0s` and a _closed island_ is an island **totally** (all left, top, right, bottom) surrounded by `1s.`
Return the number of _clo... | dolphin | [
0.011875608004629612,
0.03235901892185211,
-0.02448837086558342,
-0.03622894734144211,
0.05141870677471161,
-0.03659360110759735,
-0.0380990207195282,
0.08307569473981857,
0.02285025827586651,
-0.007265809923410416,
0.018563957884907722,
0.024140696972608566,
-0.027267592027783394,
-0.0114... | 0.838004 | 0.783 | 0.055005 |
Please write the following solution using ANSI C:
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
**... | dolphin | [
0.024775328114628792,
0.04753658547997475,
-0.03835372254252434,
-0.02221265621483326,
0.0548192635178566,
-0.020855583250522614,
-0.030327126383781433,
0.08062440901994705,
0.022796323522925377,
-0.012136124074459076,
0.01886138506233692,
0.016655484214425087,
-0.028533639386296272,
-0.02... | 0.844147 | 0.77299 | 0.071158 |
Please focus on the functionality of this problem and provide code in Visual Basic .NET:
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:** tru... | dolphin | [
0.011834043078124523,
0.021016130223870277,
-0.0357169434428215,
-0.029589124023914337,
0.04598385840654373,
-0.021005578339099884,
0.012170468457043171,
0.08127228170633316,
0.017473457381129265,
-0.013740716502070427,
0.027643458917737007,
0.017139099538326263,
-0.03383747860789299,
-0.0... | 0.839249 | 0.780298 | 0.058951 |
Please write the following solution using ANSI C:
You are given two arrays of positive integers, `boxes` and `warehouse`, representing the heights of some boxes of unit width and the heights of `n` rooms in a warehouse respectively. The warehouse's rooms are labeled from `0` to `n - 1` from left to right where `warehou... | dolphin | [
0.03196553513407707,
0.02426745370030403,
-0.023393666371703148,
-0.01437099277973175,
0.01897396892309189,
-0.009374452754855156,
-0.03643180429935455,
0.08138281852006912,
0.03174934163689613,
-0.010234333574771881,
0.028569236397743225,
0.04088713973760605,
-0.03443184494972229,
-0.0244... | 0.841424 | 0.779473 | 0.061951 |
Please write the following solution using Julia:
Given a binary array `nums`, return _the maximum number of consecutive_ `1`_'s in the array_.
**Example 1:**
**Input:** nums = \[1,1,0,1,1,1\]
**Output:** 3
**Explanation:** The first two digits or the last three digits are consecutive 1s. The maximum number of consecu... | dolphin | [
0.013920157216489315,
0.041211433708667755,
-0.01791345700621605,
-0.04079827293753624,
0.043681371957063675,
-0.025036534294486046,
-0.04709968343377113,
0.05103415623307228,
0.036491021513938904,
-0.022309785708785057,
0.03305015712976456,
0.017704207450151443,
-0.028687819838523865,
-0.... | 0.833696 | 0.76944 | 0.064256 |
Please explain the reasoning behind the following solution and provide code in java:
You are given an integer array `nums` of length `n` which represents a permutation of all the integers in the range `[0, n - 1]`.
The number of **global inversions** is the number of the different pairs `(i, j)` where:
* `0 <= i < ... | dolphin | [
0.004660150036215782,
0.03331851586699486,
-0.02057349681854248,
-0.014777547679841518,
0.043760284781455994,
-0.0312996506690979,
-0.015611676499247551,
0.07287046313285828,
0.019488858059048653,
-0.01569519378244877,
0.019708115607500076,
0.028316861018538475,
-0.03486896678805351,
-0.00... | 0.846077 | 0.788232 | 0.057845 |
Please write the following solution using Swift:
Suppose an array of length `n` sorted in ascending order is **rotated** between `1` and `n` times. For example, the array `nums = [0,1,2,4,5,6,7]` might become:
* `[4,5,6,7,0,1,2]` if it was rotated `4` times.
* `[0,1,2,4,5,6,7]` if it was rotated `7` times.
Notice... | dolphin | [
0.0051805321127176285,
0.03729460388422012,
-0.017309918999671936,
-0.01659267209470272,
0.04591820016503334,
-0.019470326602458954,
-0.033732328563928604,
0.055014390498399734,
0.024851098656654358,
-0.008797203190624714,
0.026692111045122147,
-0.00017665659834165126,
-0.03034038282930851,
... | 0.839982 | 0.784576 | 0.055406 |
Please focus on the efficiency of this problem and provide code in python:
Given an integer array `arr`, partition the array into (contiguous) subarrays of length **at most** `k`. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
Return _the largest sum of the giv... | dolphin | [
0.041890569031238556,
0.04082322493195534,
-0.03651590645313263,
-0.028738608583807945,
0.026128452271223068,
-0.021275240927934647,
-0.0323922373354435,
0.041891876608133316,
0.026192866265773773,
-0.018867606297135353,
0.0444500669836998,
0.014361227862536907,
-0.029589632526040077,
0.00... | 0.840427 | 0.785102 | 0.055325 |
Please explain the following problem in detail and provide code in ANSI C:
Given an integer `n`, return _the number of ways you can write_ `n` _as the sum of consecutive positive integers._
**Example 1:**
**Input:** n = 5
**Output:** 2
**Explanation:** 5 = 2 + 3
**Example 2:**
**Input:** n = 9
**Output:** 3
**Expla... | dolphin | [
0.022817686200141907,
0.022450879216194153,
-0.005084522534161806,
-0.03993434086441994,
0.028300229460000992,
-0.029275527223944664,
-0.05724450573325157,
0.0694131925702095,
0.050762467086315155,
-0.010975043289363384,
0.03724951669573784,
0.04175717011094093,
-0.05781661346554756,
-0.04... | 0.829804 | 0.764165 | 0.065639 |
Please write the following solution using Rust:
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`, an... | dolphin | [
0.015575245022773743,
0.019881663843989372,
-0.03982338681817055,
-0.02063967101275921,
0.031988974660634995,
-0.01588706485927105,
-0.02833137847483158,
0.04217234253883362,
0.044419337064027786,
-0.0037516693118959665,
0.03806503862142563,
0.030652841553092003,
-0.025724755600094795,
0.0... | 0.834725 | 0.778049 | 0.056676 |
Please write the following solution using c++:
You are given two arrays of integers `nums1` and `nums2`, possibly of different lengths. The values in the arrays are between `1` and `6`, inclusive.
In one operation, you can change any integer's value in **any** of the arrays to **any** value between `1` and `6`, inclus... | dolphin | [
0.016067445278167725,
0.018386822193861008,
-0.024574000388383865,
-0.03266894817352295,
0.04623214155435562,
-0.0029079962987452745,
-0.029082119464874268,
0.09371501952409744,
0.03431963175535202,
-0.03307003155350685,
0.014757189899682999,
0.02346314862370491,
-0.017258621752262115,
-0.... | 0.848696 | 0.785614 | 0.063083 |
Please explain the reasoning behind the following solution and provide code in C#:
You are given an array of integers `nums` **(0-indexed)** and an integer `k`.
The **score** of a subarray `(i, j)` is defined as `min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)`. A **good** subarray is a subarray where `i <= k <= j... | dolphin | [
0.007826867513358593,
0.02758042700588703,
-0.03427679464221001,
-0.03216101601719856,
0.04332993924617767,
-0.03799547627568245,
-0.034559108316898346,
0.06399493664503098,
0.037137262523174286,
0.0005008849548175931,
0.017328355461359024,
0.019053945317864418,
-0.03072790801525116,
0.006... | 0.843944 | 0.784827 | 0.059116 |
Please write the following solution using python:
Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`.
**Example 1:**
**Input:** arr = \[3,1,2,4\]
**Output:** 17
**Explanation:**
Su... | dolphin | [
0.021505262702703476,
0.015739087015390396,
-0.033023279160261154,
-0.04760807752609253,
0.05053534358739853,
-0.01812303252518177,
-0.048804763704538345,
0.023814158514142036,
0.04393796995282173,
-0.0022528867702931166,
0.029007162898778915,
0.02471654862165451,
-0.03216223418712616,
0.0... | 0.844831 | 0.777179 | 0.067651 |
Please focus on the efficiency of this problem and provide code in Object Pascal:
Given a string `n` representing an integer, return _the closest integer (not including itself), which is a palindrome_. If there is a tie, return _**the smaller one**_.
The closest is defined as the absolute difference minimized between ... | dolphin | [
0.031230511143803596,
0.03610888496041298,
-0.012817000038921833,
-0.0366220586001873,
0.024698011577129364,
-0.03234453126788139,
-0.0017660807352513075,
0.042922403663396835,
0.04161616787314415,
0.001551607740111649,
0.03498600423336029,
0.029117802157998085,
-0.031168077141046524,
-0.0... | 0.83341 | 0.779858 | 0.053551 |
Please write the following solution using ANSI C:
You are given a **positive** integer `num` consisting of exactly four digits. Split `num` into two new integers `new1` and `new2` by using the **digits** found in `num`. **Leading zeros** are allowed in `new1` and `new2`, and **all** the digits found in `num` must be us... | dolphin | [
0.008740775287151337,
0.026216717436909676,
-0.018860695883631706,
-0.032449375838041306,
0.04045145586133003,
-0.012934261001646519,
-0.040723491460084915,
0.06650622189044952,
0.043852463364601135,
-0.009357217699289322,
0.02854349836707115,
0.037524908781051636,
-0.03072665072977543,
-0... | 0.837209 | 0.770038 | 0.067171 |
Please write the following solution using Mojo:
The **alternating sum** of a **0-indexed** array is defined as the **sum** of the elements at **even** indices **minus** the **sum** of the elements at **odd** indices.
* For example, the alternating sum of `[4,2,5,3]` is `(4 + 5) - (2 + 3) = 4`.
Given an array `nums`... | dolphin | [
0.01435717660933733,
0.022823970764875412,
-0.01706797070801258,
-0.01989978924393654,
0.02535407431423664,
-0.022754084318876266,
-0.040128402411937714,
0.045550912618637085,
0.044840700924396515,
-0.014224077574908733,
0.014384033158421516,
0.008665027096867561,
-0.05557020753622055,
0.0... | 0.837322 | 0.771138 | 0.066184 |
Please write the following solution using java:
Given a string s, return _the number of **distinct non-empty subsequences** of_ `s`. Since the answer may be very large, return it **modulo** `109 + 7`.
A **subsequence** of a string is a new string that is formed from the original string by deleting some (can be none) o... | dolphin | [
0.02352380007505417,
0.012741927988827229,
-0.030520418658852577,
-0.03085378184914589,
0.042515698820352554,
-0.03949001803994179,
-0.018368298187851906,
0.03798548877239227,
0.03998939320445061,
-0.016567056998610497,
0.028480349108576775,
0.02121732570230961,
-0.04754000902175903,
-0.01... | 0.834019 | 0.776447 | 0.057573 |
Please explain the reasoning behind the following solution and provide code in Kotlin:
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.... | dolphin | [
0.01801232621073723,
0.029829896986484528,
-0.020640652626752853,
-0.036567818373441696,
0.03934120759367943,
-0.019088173285126686,
-0.02448759600520134,
0.03772937133908272,
0.029124321416020393,
-0.011523866094648838,
0.022608302533626556,
0.03789028897881508,
-0.040420159697532654,
0.0... | 0.83542 | 0.778037 | 0.057382 |
Please write the following solution using Fortran:
You are given two integers `m` and `n`. Consider an `m x n` grid where each cell is initially white. You can paint each cell **red**, **green**, or **blue**. All cells **must** be painted.
Return _the number of ways to color the grid with **no two adjacent cells havin... | dolphin | [
0.025004880502820015,
0.02158850058913231,
-0.022505780681967735,
-0.04247090592980385,
0.022768931463360786,
-0.02887129783630371,
-0.03379084914922714,
0.06204262375831604,
0.03285422921180725,
-0.03310428559780121,
0.028369424864649773,
0.035912398248910904,
-0.006668591871857643,
-0.03... | 0.840182 | 0.782553 | 0.057629 |
Please explain the reasoning behind the following solution and provide code in java:
You are given an integer `n` representing the length of an unknown array that you are trying to recover. You are also given an array `sums` containing the values of all `2n` **subset sums** of the unknown array (in no particular order)... | dolphin | [
0.007779615931212902,
0.023577803745865822,
-0.04344666004180908,
-0.03127399832010269,
0.04256800189614296,
-0.03941654786467552,
-0.016348259523510933,
0.039332300424575806,
0.01710197515785694,
-0.017628924921154976,
0.025326648727059364,
0.03666813671588898,
-0.030595580115914345,
-0.0... | 0.844164 | 0.782787 | 0.061377 |
Please write the following solution using java:
The **score** of an array is defined as the **product** of its sum and its length.
* For example, the score of `[1, 2, 3, 4, 5]` is `(1 + 2 + 3 + 4 + 5) * 5 = 75`.
Given a positive integer array `nums` and an integer `k`, return _the **number of non-empty subarrays** ... | dolphin | [
-0.004260477609932423,
0.029713906347751617,
-0.03085228055715561,
-0.020378535613417625,
0.05398304760456085,
-0.021549565717577934,
-0.036066554486751556,
0.037039171904325485,
0.013633953407406807,
-0.00009831257921177894,
0.025972506031394005,
0.01465725526213646,
-0.040525421500205994,
... | 0.83821 | 0.772476 | 0.065734 |
Please focus on the algorithm of this problem and provide code in java:
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** int... | dolphin | [
0.007009454537183046,
0.03794871270656586,
-0.02145497128367424,
-0.017516324296593666,
0.04756443575024605,
-0.04370073974132538,
-0.03029286116361618,
0.05067327991127968,
0.03186924755573273,
-0.0029856942128390074,
0.021581972017884254,
0.03099861368536949,
-0.02217654325067997,
-0.011... | 0.834097 | 0.772248 | 0.061849 |
Please explain the reasoning behind the following solution and provide code in java:
An integer array is called arithmetic if it consists of **at least three elements** and if the difference between any two consecutive elements is the same.
* For example, `[1,3,5,7,9]`, `[7,7,7,7]`, and `[3,-1,-5,-9]` are arithmetic... | dolphin | [
0.03170004114508629,
0.020349767059087753,
-0.04273606836795807,
-0.01563471369445324,
0.04791973531246185,
-0.006647629663348198,
-0.034229576587677,
0.05596783384680748,
0.030837973579764366,
-0.012191623449325562,
0.021796511486172676,
0.01592215709388256,
-0.03378644213080406,
-0.01494... | 0.837363 | 0.775204 | 0.062159 |
Please explain the following problem in detail and provide code in python:
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`.
You may return the answer in **any order**.
**Example 1:**
**Input:** n = 4, k = 2
**Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3... | dolphin | [
0.04071027785539627,
0.0491037517786026,
-0.028561752289533615,
-0.03033367730677128,
0.053330034017562866,
-0.03604509308934212,
-0.00860573910176754,
0.03090296871960163,
0.028913745656609535,
0.012440542690455914,
0.04581710323691368,
0.03765659034252167,
-0.03216658905148506,
0.0159312... | 0.823074 | 0.767941 | 0.055134 |
Please write the following solution using Fortran:
A **square triple** `(a,b,c)` is a triple where `a`, `b`, and `c` are **integers** and `a2 + b2 = c2`.
Given an integer `n`, return _the number of **square triples** such that_ `1 <= a, b, c <= n`.
**Example 1:**
**Input:** n = 5
**Output:** 2
**Explanation**: The s... | dolphin | [
0.02169119380414486,
0.03293079137802124,
-0.02957422472536564,
-0.048424944281578064,
0.037084147334098816,
-0.006581306457519531,
-0.01747278682887554,
0.061073970049619675,
0.01202660147100687,
0.00806980300694704,
0.018979152664542198,
0.03930021449923515,
-0.05826941877603531,
-0.0420... | 0.830194 | 0.775702 | 0.054492 |
Please focus on the efficiency of this problem and provide code in java:
Given an integer array `nums` and an integer `k`, return _the number of **good** subarrays of_ `nums`.
A subarray `arr` is **good** if it there are **at least** `k` pairs of indices `(i, j)` such that `i < j` and `arr[i] == arr[j]`.
A **subarray... | dolphin | [
0.017851563170552254,
0.028712086379528046,
-0.05054531618952751,
-0.0159943625330925,
0.03097664564847946,
-0.0179219301789999,
-0.044212792068719864,
0.03512227162718773,
0.025218982249498367,
-0.010537796653807163,
0.0225333534181118,
0.016925333067774773,
-0.0228615440428257,
-0.002668... | 0.840997 | 0.777439 | 0.063558 |
Please focus on the functionality of this problem and provide code in R:
Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`.
**Example 1:**
**Input:** arr = \[3,1,2,4\]
**Output:** ... | dolphin | [
0.017176803201436996,
0.02337704971432686,
-0.02725229039788246,
-0.045757975429296494,
0.051619093865156174,
-0.01999540440738201,
-0.04617580026388168,
0.03611345961689949,
0.04851144552230835,
-0.002426628489047289,
0.020991729572415352,
0.02710448019206524,
-0.03073636069893837,
-0.005... | 0.839781 | 0.778761 | 0.06102 |
Please focus on the efficiency of this problem and provide code in Swift:
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 of each digit... | dolphin | [
-0.007607945241034031,
0.02246670611202717,
-0.015424982644617558,
-0.025286082178354263,
0.04791615158319473,
-0.01151153352111578,
-0.024834008887410164,
0.05898667126893997,
0.03598638251423836,
-0.016067001968622208,
0.01925494335591793,
0.028523573651909828,
-0.025677494704723358,
-0.... | 0.841984 | 0.785245 | 0.05674 |
Please explain the following problem in detail and provide code in java:
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 array is ... | dolphin | [
0.02343885600566864,
0.03331547603011131,
-0.034961458295583725,
-0.02249813824892044,
0.02929832600057125,
-0.02908816933631897,
-0.024734267964959145,
0.046780314296483994,
0.018791960552334785,
-0.018386537209153175,
0.036308497190475464,
0.014074558392167091,
-0.03416333720088005,
-0.0... | 0.838585 | 0.772131 | 0.066454 |
Please explain the reasoning behind the following solution and provide code in Scheme:
Given an `n x n` array of integers `matrix`, return _the **minimum sum** of any **falling path** through_ `matrix`.
A **falling path** starts at any element in the first row and chooses the element in the next row that is either dir... | dolphin | [
0.003266145009547472,
0.011031422764062881,
-0.027901696041226387,
-0.03541180491447449,
0.06162343546748161,
-0.026892855763435364,
-0.02049405127763748,
0.05328599363565445,
0.04133829474449158,
-0.017515631392598152,
0.023269373923540115,
0.004760365467518568,
-0.029752496629953384,
-0.... | 0.836931 | 0.782442 | 0.054488 |
Please explain the following problem in detail and provide code in C#:
A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not.
Given a string `n` that represents a positive decima... | dolphin | [
-0.013510052114725113,
0.012237343937158585,
-0.03222472593188286,
-0.036707229912281036,
0.04161834716796875,
-0.050822317600250244,
-0.02006535232067108,
0.051139961928129196,
0.027153195813298225,
0.00237616547383368,
0.01667143777012825,
0.023647937923669815,
-0.04278223216533661,
-0.0... | 0.82442 | 0.763409 | 0.06101 |
Please focus on the algorithm of this problem and provide code in Julia:
You are given four integers `minLength`, `maxLength`, `oneGroup` and `zeroGroup`.
A binary string is **good** if it satisfies the following conditions:
* The length of the string is in the range `[minLength, maxLength]`.
* The size of each b... | dolphin | [
-0.004629552364349365,
0.021587984636425972,
-0.030185775831341743,
-0.04037417843937874,
0.056307826191186905,
-0.04383474215865135,
-0.045305706560611725,
0.06705549359321594,
0.02787506766617298,
-0.018199343234300613,
0.006249573547393084,
0.02026870846748352,
-0.02289852872490883,
-0.... | 0.856053 | 0.800228 | 0.055825 |
Please write the following solution using ANSI C:
You start at the cell `(rStart, cStart)` of an `rows x cols` grid facing east. The northwest corner is at the first row and column in the grid, and the southeast corner is at the last row and column.
You will walk in a clockwise spiral shape to visit every position in ... | dolphin | [
0.0012959701707586646,
0.038350965827703476,
-0.013450516387820244,
-0.03623437136411667,
0.023125965148210526,
-0.03813047707080841,
-0.04260243847966194,
0.05643792077898979,
0.042654816061258316,
-0.017894254997372627,
0.02507324330508709,
0.016348129138350487,
-0.039980873465538025,
-0... | 0.837236 | 0.782923 | 0.054313 |
Please write the following solution using Go:
You are given an integer array `nums` and a **positive** integer `k`.
The **frequency score** of an array is the sum of the **distinct** values in the array raised to the power of their **frequencies**, taking the sum **modulo** `109 + 7`.
* For example, the frequency s... | dolphin | [
0.009807725436985493,
0.029949648305773735,
-0.029368896037340164,
-0.03398071229457855,
0.04060510918498039,
-0.035416144877672195,
-0.029245348647236824,
0.037980664521455765,
0.030963731929659843,
0.0028589810244739056,
0.02686997503042221,
0.026718012988567352,
-0.03638600930571556,
0.... | 0.834518 | 0.776147 | 0.058371 |
Please write the following solution using Scheme:
Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`.
**Example 1:**
**Input:** arr = \[3,1,2,4\]
**Output:** 17
**Explanation:**
Su... | dolphin | [
0.020799072459340096,
0.009958762675523758,
-0.029689835384488106,
-0.0497605986893177,
0.05350063368678093,
-0.01992310956120491,
-0.05316254496574402,
0.02447902224957943,
0.05052056908607483,
-0.005998666398227215,
0.027926739305257797,
0.026430698111653328,
-0.03210892900824547,
-0.002... | 0.843525 | 0.770656 | 0.072869 |
Please write the following solution using C#:
You are given an integer array `nums` and an integer `k`.
For each index `i` where `0 <= i < nums.length`, change `nums[i]` to be either `nums[i] + k` or `nums[i] - k`.
The **score** of `nums` is the difference between the maximum and minimum elements in `nums`.
Return _... | dolphin | [
0.011761307716369629,
0.02511153370141983,
-0.023860031738877296,
-0.030222952365875244,
0.04758790507912636,
-0.04122999310493469,
-0.03565116226673126,
0.07731585949659348,
0.040772732347249985,
-0.009576649405062199,
0.02353035844862461,
0.02587733417749405,
-0.04080592840909958,
-0.002... | 0.840332 | 0.781795 | 0.058537 |
Please focus on the algorithm of this problem and provide code in Objective-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`
* `... | dolphin | [
0.02823719009757042,
0.03208974376320839,
-0.023273363709449768,
-0.03310929238796234,
0.02434973232448101,
-0.021747112274169922,
-0.026208406314253807,
0.08412263542413712,
0.031850747764110565,
-0.024002134799957275,
0.0371294729411602,
0.021444719284772873,
-0.05073221027851105,
-0.004... | 0.840607 | 0.78511 | 0.055497 |
Please explain the following problem in detail and provide code in Objective-C:
Alice and Bob continue their games with piles of stones. There are a number of piles **arranged in a row**, and each pile has a positive integer number of stones `piles[i]`. The objective of the game is to end with the most stones.
Alice a... | dolphin | [
0.04297678545117378,
0.018666157498955727,
-0.02747815102338791,
-0.02791464515030384,
0.019965019077062607,
-0.04506351426243782,
-0.027123993262648582,
0.056452374905347824,
0.030309507623314857,
-0.026029270142316818,
0.03690110892057419,
0.029775060713291168,
-0.03880007192492485,
-0.0... | 0.831791 | 0.778223 | 0.053568 |
Please focus on the functionality of this problem and provide code in java:
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:**
**I... | dolphin | [
0.01695421151816845,
0.02575082890689373,
-0.0211293026804924,
-0.03231301158666611,
0.020841442048549652,
-0.027557222172617912,
-0.03314395248889923,
0.0522347055375576,
0.006402204278856516,
-0.015915853902697563,
0.03764704242348671,
0.03256145492196083,
-0.03955371677875519,
-0.003632... | 0.829263 | 0.774663 | 0.054601 |
Please explain the reasoning behind the following solution and provide code in Julia:
You are given a **0-indexed** integer array `nums` of length `n`.
The **sum** **score** of `nums` at an index `i` where `0 <= i < n` is the **maximum** of:
* The sum of the **first** `i + 1` elements of `nums`.
* The sum of the ... | dolphin | [
0.0001711818331386894,
0.01603139564394951,
-0.027501193806529045,
-0.03323117643594742,
0.043684620410203934,
-0.029624301940202713,
-0.03893032297492027,
0.04317107051610947,
0.03377627581357956,
0.0018987306393682957,
0.022796791046857834,
0.03828134760260582,
-0.04425586014986038,
0.00... | 0.839765 | 0.785745 | 0.05402 |
Please explain the reasoning behind the following solution and provide code in Object Pascal:
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 `nu... | dolphin | [
0.023243768140673637,
0.02589193731546402,
-0.018092282116413116,
-0.021041015163064003,
0.037568457424640656,
-0.02954021282494068,
-0.019027048721909523,
0.06527509540319443,
0.053950339555740356,
0.005242658779025078,
0.024676110595464706,
0.029063425958156586,
-0.01952614076435566,
-0.... | 0.848779 | 0.790733 | 0.058046 |
Please focus on the functionality of this problem and provide code in Scala:
There is an **undirected** graph with `n` nodes, numbered from `0` to `n - 1`.
You are given a **0-indexed** integer array `scores` of length `n` where `scores[i]` denotes the score of node `i`. You are also given a 2D integer array `edges` w... | dolphin | [
-0.0036510792560875416,
0.020738670602440834,
-0.009951084852218628,
-0.01904744654893875,
0.03362981602549553,
-0.03912210837006569,
-0.020115800201892853,
0.049553282558918,
0.0162561796605587,
-0.006942229811102152,
0.024464299902319908,
0.020314764231443405,
0.0017372233560308814,
-0.0... | 0.849277 | 0.795396 | 0.05388 |
Please write the following solution using R:
Given an integer array `nums` and an integer `k`, return _the number of **subarrays** of_ `nums` _where the least common multiple of the subarray's elements is_ `k`.
A **subarray** is a contiguous non-empty sequence of elements within an array.
The **least common multiple ... | dolphin | [
0.012404290959239006,
0.048713505268096924,
-0.041766051203012466,
-0.02620440535247326,
0.05490788072347641,
-0.012497007846832275,
-0.03674977645277977,
0.04406612366437912,
0.019294528290629387,
-0.012667265720665455,
0.020897474139928818,
0.019760537892580032,
-0.01604212448000908,
-0.... | 0.82766 | 0.763199 | 0.064461 |
Please write the following solution using Object Pascal:
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 integers `rollMax` and an in... | dolphin | [
0.036241885274648666,
0.02577294409275055,
-0.015295824036002159,
-0.026231741532683372,
0.04302307590842247,
-0.020116960629820824,
-0.028551829978823662,
0.06114539876580238,
0.03249397128820419,
-0.008630680851638317,
0.04453269764780998,
0.027595484629273415,
-0.015539601445198059,
-0.... | 0.837923 | 0.781179 | 0.056744 |
Please explain the following problem in detail and provide code in C#:
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` a... | dolphin | [
0.024373730644583702,
0.021509546786546707,
-0.02716423198580742,
-0.01623298041522503,
0.02779209613800049,
-0.035797011107206345,
-0.02879653126001358,
0.08501492440700531,
0.05117420852184296,
-0.003118409076705575,
0.02063489891588688,
0.017492998391389847,
-0.027537064626812935,
-0.01... | 0.848026 | 0.783373 | 0.064653 |
Please explain the following problem in detail 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 the **heaviest two stones** and smash them together. Suppose the heaviest two stones ha... | dolphin | [
0.044099800288677216,
0.04009442403912544,
-0.03651978448033333,
-0.033628009259700775,
0.03347710892558098,
-0.02861340157687664,
-0.023679472506046295,
0.049244385212659836,
0.028450440615415573,
-0.028363600373268127,
0.04140128940343857,
0.02346743270754814,
-0.033308498561382294,
-0.0... | 0.844067 | 0.785575 | 0.058491 |
Please explain the following problem in detail and provide code in R:
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 ... | dolphin | [
0.03565690666437149,
0.023086629807949066,
-0.03143274039030075,
-0.03756352514028549,
0.04276493936777115,
-0.021442320197820663,
-0.051831506192684174,
0.0655759871006012,
0.03136822208762169,
-0.005493606440722942,
-0.002830385696142912,
0.02776716835796833,
-0.039701081812381744,
-0.03... | 0.83721 | 0.776943 | 0.060267 |
Please write the following solution using java:
Given an array of integers `arr`, return _the number of subarrays with an **odd** sum_.
Since the answer can be very large, return it modulo `109 + 7`.
**Example 1:**
**Input:** arr = \[1,3,5\]
**Output:** 4
**Explanation:** All subarrays are \[\[1\],\[1,3\],\[1,3,5\],... | dolphin | [
0.010586246848106384,
0.022790560498833656,
-0.03447799012064934,
-0.03334076702594757,
0.04148481413722038,
-0.015223675407469273,
-0.039616238325834274,
0.03403734043240547,
0.047416627407073975,
-0.01789284497499466,
0.019924761727452278,
0.006897481624037027,
-0.04944858327507973,
-0.0... | 0.832332 | 0.768875 | 0.063457 |
Please explain the reasoning behind the following solution and provide code in c++:
Given a **positive** integer `n`, return _the smallest positive integer that is a multiple of **both**_ `2` _and_ `n`.
**Example 1:**
**Input:** n = 5
**Output:** 10
**Explanation:** The smallest multiple of both 5 and 2 is 10.
**Exa... | dolphin | [
0.010193982161581516,
0.03497917950153351,
-0.01930048316717148,
-0.032654546201229095,
0.04949066787958145,
-0.014982519671320915,
-0.03125784546136856,
0.08592820912599564,
0.035935234278440475,
-0.01625795289874077,
0.020314320921897888,
0.05324860289692879,
-0.0202648788690567,
-0.0183... | 0.834507 | 0.779849 | 0.054658 |
Please focus on the functionality of this problem and provide code in ANSI C:
Given an array of strings `words`, find the **longest** string in `words` such that **every prefix** of it is also in `words`.
* For example, let `words = [ "a ", "app ", "ap "]`. The string `"app "` has prefixes `"ap "` and `"a "`, all of... | dolphin | [
0.016977353021502495,
0.017422683537006378,
-0.006209800485521555,
-0.037982042878866196,
0.012343838810920715,
-0.043058205395936966,
-0.028263045474886894,
0.0635620579123497,
0.025188734754920006,
-0.028965456411242485,
0.023079490289092064,
0.017772996798157692,
-0.03588112071156502,
-... | 0.837082 | 0.783068 | 0.054014 |
Please explain the following problem in detail and provide code in Swift:
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 sub... | dolphin | [
0.020680688321590424,
0.03551063314080238,
-0.017635583877563477,
-0.02363734506070614,
0.048994313925504684,
-0.019766710698604584,
-0.03078688494861126,
0.05783545598387718,
0.03133619949221611,
-0.005129772704094648,
0.01839383691549301,
0.006765000056475401,
-0.020952366292476654,
-0.0... | 0.843614 | 0.786704 | 0.05691 |
Please explain the following problem in detail and provide code in ANSI 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 ... | dolphin | [
0.020393138751387596,
0.03838689252734184,
-0.022374020889401436,
-0.033065371215343475,
0.03013169951736927,
-0.01949424296617508,
-0.030364390462636948,
0.053505826741456985,
0.029937192797660828,
-0.009120701812207699,
0.030108259990811348,
0.035181205719709396,
-0.053732987493276596,
-... | 0.832921 | 0.766026 | 0.066895 |
Please write the following solution using Mojo:
A **path** in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence **at most once**. Note that the path does not need to pass through the root.
The **path sum** of a pat... | dolphin | [
0.02285853773355484,
0.020092608407139778,
-0.038301050662994385,
-0.02756320871412754,
0.02722354605793953,
-0.038118574768304825,
-0.006670739036053419,
0.03353210538625717,
0.038711126893758774,
-0.02105119451880455,
0.041160307824611664,
0.030859654769301414,
-0.023598644882440567,
-0.... | 0.837885 | 0.777019 | 0.060866 |
Please explain the reasoning behind the following solution and provide code in Scheme:
You are given a **0-indexed** array of `n` integers `differences`, which describes the **differences** between each pair of **consecutive** integers of a **hidden** sequence of length `(n + 1)`. More formally, call the hidden sequenc... | dolphin | [
0.027217993512749672,
0.03516664728522301,
-0.014294421300292015,
-0.022644508630037308,
0.041624657809734344,
-0.01971067115664482,
-0.04206058010458946,
0.06283647567033768,
0.04201329126954079,
-0.007486102171242237,
0.024934057146310806,
0.03578281030058861,
-0.03527628257870674,
-0.00... | 0.85239 | 0.797451 | 0.05494 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
You are in a city that consists of `n` intersections numbered from `0` to `n - 1` with **bi-directional** roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection... | dolphin | [
0.029010413214564323,
0.022904785349965096,
-0.01648097112774849,
-0.010728777386248112,
0.030890319496393204,
-0.01214818935841322,
-0.056892506778240204,
0.0723101794719696,
0.04949568584561348,
-0.010151795111596584,
0.029939968138933182,
0.04673769697546959,
-0.024626407772302628,
-0.0... | 0.844052 | 0.789368 | 0.054684 |
Please write the following solution using R:
You are given an integer array `nums`. We call a subset of `nums` **good** if its product can be represented as a product of one or more **distinct prime** numbers.
* For example, if `nums = [1, 2, 3, 4]`:
* `[2, 3]`, `[1, 2, 3]`, and `[1, 3]` are **good** subsets w... | dolphin | [
0.03368835151195526,
0.01659388840198517,
-0.032265402376651764,
-0.035287659615278244,
0.03576582670211792,
-0.02920514903962612,
-0.038183413445949554,
0.05443765968084335,
0.04667261615395546,
-0.0038278482388705015,
0.01635836996138096,
0.022137241438031197,
-0.037582896649837494,
-0.0... | 0.834424 | 0.776563 | 0.057861 |
Please focus on the efficiency of this problem and provide code in R:
You are given a **positive** integer `num` consisting of exactly four digits. Split `num` into two new integers `new1` and `new2` by using the **digits** found in `num`. **Leading zeros** are allowed in `new1` and `new2`, and **all** the digits found... | dolphin | [
0.007640447933226824,
0.026590321213006973,
-0.025310149416327477,
-0.031919363886117935,
0.04293244704604149,
-0.006343889981508255,
-0.03806433081626892,
0.05313442274928093,
0.05290552228689194,
-0.0007993163890205324,
0.013023976236581802,
0.04414960369467735,
-0.01981731317937374,
-0.... | 0.836796 | 0.780746 | 0.05605 |
Please explain the following problem in detail and provide code in Object Pascal:
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 **a... | dolphin | [
0.021646961569786072,
0.026286307722330093,
-0.01153518445789814,
-0.02997857891023159,
0.03456655517220497,
-0.02582160010933876,
-0.02335081435739994,
0.059912219643592834,
0.02837069146335125,
-0.0024817551020532846,
0.039445795118808746,
0.028145769611001015,
-0.03213891014456749,
-0.0... | 0.840501 | 0.779812 | 0.060689 |
Please write the following solution using java:
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_ `nums`.
Note that `abs(x)` ... | dolphin | [
0.02548002451658249,
0.02979513257741928,
-0.03250671178102493,
-0.022574912756681442,
0.033239610493183136,
-0.021340079605579376,
-0.032742250710725784,
0.02654450759291649,
0.04521084949374199,
-0.014914970844984055,
0.029894419014453888,
0.017427854239940643,
-0.03169533610343933,
-0.0... | 0.831924 | 0.764586 | 0.067337 |
Please explain the following problem in detail and provide code in Julia:
Given an integer array `nums` and an integer `k`, return _the number of **subarrays** of_ `nums` _where the least common multiple of the subarray's elements is_ `k`.
A **subarray** is a contiguous non-empty sequence of elements within an array.
... | dolphin | [
0.003355820896103978,
0.045013271272182465,
-0.04523393511772156,
-0.023950880393385887,
0.05145159363746643,
-0.015627268701791763,
-0.03146655857563019,
0.04003715515136719,
0.024768231436610222,
-0.011911127716302872,
0.028071744367480278,
0.021084798499941826,
-0.005817359313368797,
0.... | 0.838186 | 0.781036 | 0.05715 |
Please focus on the functionality of this problem and provide code in Scala:
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.0014263080665841699,
0.030493075028061867,
-0.02333224005997181,
-0.040630318224430084,
0.039703719317913055,
-0.026758985593914986,
-0.017355676740407944,
0.044425297528505325,
0.022869497537612915,
-0.0061170849949121475,
0.030867639929056168,
0.03364471346139908,
-0.03552764654159546,
... | 0.838816 | 0.785183 | 0.053633 |
Please write the following solution using R:
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:** nums = \[1,3,5,4,4,6\]
**Output:*... | dolphin | [
0.013403081335127354,
0.04341990873217583,
-0.01859145797789097,
-0.018323522061109543,
0.03488181531429291,
0.0005403070827014744,
-0.04753677546977997,
0.06344377249479294,
0.030369410291314125,
-0.0067814430221915245,
0.01063825748860836,
0.01186560932546854,
-0.06643503904342651,
-0.01... | 0.82911 | 0.770622 | 0.058488 |
Please focus on the algorithm of this problem and provide code in Kotlin:
Given an array `arr` that represents a permutation of numbers from `1` to `n`.
You have a binary string of size `n` that initially has all its bits set to zero. At each step `i` (assuming both the binary string and `arr` are 1-indexed) from `1` ... | dolphin | [
0.01832772046327591,
0.025855807587504387,
-0.014913611114025116,
-0.03990950062870979,
0.046780720353126526,
-0.04538658261299133,
-0.03208278864622116,
0.07128038257360458,
0.02777017652988434,
-0.018399307504296303,
0.015397504903376102,
0.008461249060928822,
-0.013930559158325195,
-0.0... | 0.859318 | 0.800568 | 0.05875 |
Please write the following solution using c++:
Given an array of integers `nums` and an integer `k`, return _the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than_ `k`.
**Example 1:**
**Input:** nums = \[10,5,2,6\], k = 100
**Output:** 8
**Explanation:** The 8 ... | dolphin | [
0.027552824467420578,
0.03231602534651756,
-0.029824551194906235,
-0.013210626319050789,
0.05303312838077545,
-0.0038820754271000624,
-0.03674611449241638,
0.08157683908939362,
0.04178190976381302,
-0.0012114375131204724,
0.009492123499512672,
0.03893999010324478,
-0.0225913617759943,
-0.0... | 0.840712 | 0.773582 | 0.067131 |
Please write the following solution using Groovy:
You want to build some obstacle courses. You are given a **0-indexed** integer array `obstacles` of length `n`, where `obstacles[i]` describes the height of the `ith` obstacle.
For every index `i` between `0` and `n - 1` (**inclusive**), find the length of the **longes... | dolphin | [
0.02106199413537979,
0.018571946769952774,
-0.020590858533978462,
-0.03635428845882416,
0.02422722615301609,
-0.024386439472436905,
-0.04663899540901184,
0.02533446066081524,
0.04520760476589203,
-0.02795328199863434,
0.01744045503437519,
0.021562304347753525,
-0.021398009732365608,
-0.006... | 0.84458 | 0.788473 | 0.056107 |
Please explain the reasoning behind the following solution 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`
... | dolphin | [
0.030436934903264046,
0.027865638956427574,
-0.02068682201206684,
-0.038397166877985,
0.029565108940005302,
-0.008243226446211338,
-0.024854006245732307,
0.10085056722164154,
0.04543597623705864,
-0.01783541776239872,
0.03537113592028618,
0.035432010889053345,
-0.04461695998907089,
-0.0008... | 0.842737 | 0.783302 | 0.059436 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You are given a **0-indexed** integer array `nums`. For each index `i` (`1 <= i <= nums.length - 2`) the **beauty** of `nums[i]` equals:
* `2`, if `nums[j] < nums[i] < nums[k]`, for **all** `0 <= j < i` and for **all** `i < k <= nums.length -... | dolphin | [
0.010692969895899296,
0.033342599868774414,
-0.025422964245080948,
-0.026287883520126343,
0.024341169744729996,
-0.018915247172117233,
-0.044179365038871765,
0.07769035547971725,
0.021591342985630035,
-0.007231822703033686,
0.02372037246823311,
0.03417873755097389,
-0.04578845947980881,
-0... | 0.846473 | 0.784871 | 0.061602 |
Please focus on the functionality of this problem and provide code in Julia:
Given an integer array `nums`, return _the maximum result of_ `nums[i] XOR nums[j]`, where `0 <= i <= j < n`.
**Example 1:**
**Input:** nums = \[3,10,5,25,2,8\]
**Output:** 28
**Explanation:** The maximum result is 5 XOR 25 = 28.
**Example ... | dolphin | [
0.02327892929315567,
0.02790353074669838,
-0.03540794551372528,
-0.01068775076419115,
0.015311597846448421,
-0.02251453883945942,
-0.03253887966275215,
0.05592973530292511,
0.039285462349653244,
-0.0036951431538909674,
0.01988859288394451,
0.02900652587413788,
-0.032441139221191406,
-0.014... | 0.848479 | 0.785289 | 0.06319 |
Please explain the reasoning behind the following solution and provide code in PHP:
You are given an integer array `nums` and an integer `k`.
In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array.
Return _the maximum number of operations you can perform on the a... | dolphin | [
0.018095118924975395,
0.03707011416554451,
-0.019825316965579987,
-0.02841644361615181,
0.04245389997959137,
-0.018512822687625885,
-0.03366309404373169,
0.07286045700311661,
0.05529996007680893,
-0.00620943121612072,
0.013747017830610275,
0.023692162707448006,
-0.02461269125342369,
-0.011... | 0.84296 | 0.788155 | 0.054806 |
Please write the following solution using Kotlin:
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.03320606052875519,
0.021243028342723846,
-0.021113311871886253,
-0.01865529827773571,
0.05116966739296913,
-0.01336938701570034,
-0.02417507953941822,
0.06063881143927574,
0.04182596877217293,
-0.024730674922466278,
0.01335118617862463,
0.032317571341991425,
-0.03062552586197853,
-0.0082... | 0.853082 | 0.793792 | 0.05929 |
Please explain the following problem in detail and provide code in Haskell:
There is an **undirected** graph with `n` nodes, numbered from `0` to `n - 1`.
You are given a **0-indexed** integer array `scores` of length `n` where `scores[i]` denotes the score of node `i`. You are also given a 2D integer array `edges` wh... | dolphin | [
-0.004692092537879944,
0.0108864177018404,
-0.005878249648958445,
-0.026937048882246017,
0.037580545991659164,
-0.03799707815051079,
-0.019533490762114525,
0.0446956530213356,
0.031181424856185913,
0.0002513476647436619,
0.017732761800289154,
0.02102569490671158,
-0.0062453532591462135,
-0... | 0.842459 | 0.789229 | 0.05323 |
Please write the following solution using ANSI C:
Given an integer `n`, return all the numbers in the range `[1, n]` sorted in lexicographical order.
You must write an algorithm that runs in `O(n)` time and uses `O(1)` extra space.
**Example 1:**
**Input:** n = 13
**Output:** \[1,10,11,12,13,2,3,4,5,6,7,8,9\]
**Exa... | dolphin | [
0.04155309870839119,
0.03922800347208977,
-0.019517207518219948,
-0.03794243186712265,
0.026021502912044525,
-0.028003044426441193,
-0.04597136750817299,
0.05197862163186073,
0.017577530816197395,
-0.016173457726836205,
0.024090971797704697,
0.03234165906906128,
-0.05005650222301483,
-0.02... | 0.832371 | 0.763371 | 0.069 |
Please explain the reasoning behind the following solution and provide code in python:
Given an integer array `nums` and an integer `k`, you are asked to construct the array `ans` of size `n-k+1` where `ans[i]` is the number of **distinct** numbers in the subarray `nums[i:i+k-1] = [nums[i], nums[i+1], ..., nums[i+k-1]]... | dolphin | [
0.027892351150512695,
0.04622012376785278,
-0.032137736678123474,
-0.02333608642220497,
0.047364797443151474,
-0.03163238987326622,
-0.02916317991912365,
0.05536002293229103,
0.030199749395251274,
0.000026831252398551442,
0.02627420425415039,
0.0230695977807045,
-0.03385484591126442,
0.023... | 0.842156 | 0.788799 | 0.053357 |
Please explain the following problem in detail and provide code in Elixir:
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... | dolphin | [
0.03153122588992119,
0.046364665031433105,
-0.023290015757083893,
-0.037805814296007156,
0.019246693700551987,
-0.01218334585428238,
-0.026822401210665703,
0.04404008761048317,
0.027807218953967094,
-0.00518940482288599,
0.03302757441997528,
0.03133956342935562,
-0.020223449915647507,
-0.0... | 0.84941 | 0.786433 | 0.062977 |
Please explain the reasoning behind the following solution and provide code in Scheme:
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 element... | dolphin | [
-0.007293590810149908,
0.016893040388822556,
-0.02320130169391632,
-0.03553769737482071,
0.05868713930249214,
-0.030916498973965645,
-0.027336204424500465,
0.04209494590759277,
0.04230361059308052,
-0.014126135967671871,
0.024466535076498985,
0.0042020585387945175,
-0.03695392608642578,
0.... | 0.846367 | 0.791956 | 0.054411 |
Please focus on the algorithm of this problem and provide code in c++:
There is a special kind of apple tree that grows apples every day for `n` days. On the `ith` day, the tree grows `apples[i]` apples that will rot after `days[i]` days, that is on day `i + days[i]` the apples will be rotten and cannot be eaten. On so... | dolphin | [
0.0180955920368433,
0.012700823135674,
-0.005409932695329189,
-0.02140052430331707,
0.022432398051023483,
-0.03245595097541809,
-0.023609057068824768,
0.11142249405384064,
0.011663828045129776,
-0.02568288892507553,
0.012549668550491333,
0.04691210016608238,
-0.0281009953469038,
0.00513788... | 0.844672 | 0.788422 | 0.056249 |
Please focus on the efficiency of this problem and provide code in Scheme:
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 gene... | dolphin | [
0.01574433594942093,
0.033808961510658264,
-0.013027021661400795,
-0.013687041588127613,
0.029850907623767853,
-0.021786082535982132,
-0.033756107091903687,
0.06151403859257698,
0.033185817301273346,
-0.026653407141566277,
0.03691931441426277,
0.010329268872737885,
-0.028613673523068428,
-... | 0.852485 | 0.788893 | 0.063592 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You are given an `m x n` binary matrix `grid`. An island is a group of `1`'s (representing land) connected **4-directionally** (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
An island is considered ... | dolphin | [
0.006198583636432886,
0.027916857972741127,
-0.030316149815917015,
-0.03469937667250633,
0.028542006388306618,
-0.036824408918619156,
-0.040287818759679794,
0.07318032532930374,
0.023479074239730835,
-0.030347052961587906,
0.0284438319504261,
-0.0009554579155519605,
-0.04081076756119728,
-... | 0.844318 | 0.789206 | 0.055112 |
Please focus on the efficiency of this problem and provide code in Objective-C:
You are given a **0-indexed** string `pattern` of length `n` consisting of the characters `'I'` meaning **increasing** and `'D'` meaning **decreasing**.
A **0-indexed** string `num` of length `n + 1` is created using the following conditio... | dolphin | [
0.008071372285485268,
0.028879819437861443,
-0.02332988567650318,
-0.035606369376182556,
0.02801603637635708,
-0.03210064768791199,
-0.027305254712700844,
0.07144702970981598,
0.0237923301756382,
-0.011507226154208183,
0.032080452889204025,
0.014155755750834942,
-0.03681524097919464,
-0.01... | 0.848897 | 0.79365 | 0.055247 |
Please explain the following problem in detail and provide code in Scala:
You are given a positive integer `n` representing the number of nodes in a **connected undirected graph** containing **exactly one** cycle. The nodes are numbered from `0` to `n - 1` (**inclusive**).
You are also given a 2D integer array `edges`... | dolphin | [
0.006141102872788906,
0.01856563799083233,
-0.026018252596259117,
-0.028222069144248962,
0.04183332622051239,
-0.039542850106954575,
-0.01539578102529049,
0.0400049202144146,
0.023899352177977562,
-0.00805596075952053,
0.03755359351634979,
0.028286298736929893,
-0.0022641124669462442,
-0.0... | 0.846355 | 0.792925 | 0.05343 |
Please explain the following problem in detail and provide code in python:
You are given a binary string `s` consisting only of zeroes and ones.
A substring of `s` is considered balanced if **all zeroes are before ones** and the number of zeroes is equal to the number of ones inside the substring. Notice that the empt... | dolphin | [
0.03231343999505043,
0.032137300819158554,
-0.029976272955536842,
-0.03855029121041298,
0.043793901801109314,
-0.047327227890491486,
-0.01371636614203453,
0.04939577728509903,
0.031311601400375366,
-0.008707192726433277,
0.02338378317654133,
0.028276219964027405,
-0.02602216973900795,
-0.0... | 0.833926 | 0.778139 | 0.055787 |
Please focus on the algorithm of this problem and provide code in java:
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 differe... | dolphin | [
0.0066234334371984005,
0.04156319051980972,
-0.030505046248435974,
-0.019464073702692986,
0.039545655250549316,
-0.027915025129914284,
-0.019369617104530334,
0.060799188911914825,
0.017868900671601295,
-0.02191256545484066,
0.022206539288163185,
0.009835650213062763,
-0.034732431173324585,
... | 0.838989 | 0.777303 | 0.061686 |
Please focus on the efficiency of this problem and provide code in Scheme:
You are given a binary string `s` and a positive integer `k`.
Return _the length of the **longest** subsequence of_ `s` _that makes up a **binary** number less than or equal to_ `k`.
Note:
* The subsequence can contain **leading zeroes**.
*... | dolphin | [
0.01456288993358612,
0.03478802740573883,
-0.02642863243818283,
-0.036110617220401764,
0.04090196266770363,
-0.044676825404167175,
-0.036732617765665054,
0.050846029072999954,
0.04829558730125427,
-0.00813826359808445,
0.032992489635944366,
0.021057259291410446,
-0.02342415601015091,
0.000... | 0.840204 | 0.779424 | 0.060781 |
Please focus on the efficiency of this problem and provide code in R:
Given an integer array `arr` and a target value `target`, return the integer `value` such that when we change all the integers larger than `value` in the given array to be equal to `value`, the sum of the array gets as close as possible (in absolute ... | dolphin | [
0.021634303033351898,
0.036108504980802536,
-0.03357721120119095,
-0.035204771906137466,
0.033582381904125214,
-0.027081871405243874,
-0.047315847128629684,
0.03568089008331299,
0.04368366673588753,
-0.013861759565770626,
0.024552496150135994,
0.02809191681444645,
-0.0369858592748642,
-0.0... | 0.838447 | 0.780357 | 0.05809 |
Please focus on the functionality of this problem and provide code in ANSI C:
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... | dolphin | [
0.042717911303043365,
0.03448689728975296,
-0.03328898549079895,
-0.030865851789712906,
0.015268305316567421,
-0.033095549792051315,
-0.03762347623705864,
0.07738194614648819,
0.04573521763086319,
-0.01577509380877018,
0.03261366859078407,
0.024599691852927208,
-0.031372781842947006,
-0.01... | 0.851173 | 0.789393 | 0.06178 |
Please explain the reasoning behind the following solution and provide code in Scheme:
You are given two arrays of integers `nums1` and `nums2`, possibly of different lengths. The values in the arrays are between `1` and `6`, inclusive.
In one operation, you can change any integer's value in **any** of the arrays to *... | dolphin | [
0.02303542010486126,
0.021952537819743156,
-0.026912502944469452,
-0.03244365379214287,
0.04760972410440445,
-0.019993389025330544,
-0.029993677511811256,
0.059625253081321716,
0.03057980164885521,
-0.03412087261676788,
0.018079154193401337,
0.02116854302585125,
-0.023360436782240868,
-0.0... | 0.855742 | 0.802467 | 0.053276 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You are given two **0-indexed** arrays `nums1` and `nums2` of length `n`, both of which are **permutations** of `[0, 1, ..., n - 1]`.
A **good triplet** is a set of `3` **distinct** values which are present in **increasing order** by position b... | dolphin | [
0.01768609508872032,
0.02319934032857418,
-0.019852450117468834,
-0.041330091655254364,
0.023293636739253998,
-0.01477159932255745,
-0.0469125360250473,
0.06807034462690353,
0.018138427287340164,
-0.011912976391613483,
0.022457027807831764,
0.02241344377398491,
-0.042416512966156006,
-0.02... | 0.845594 | 0.788424 | 0.057169 |
translate this code to Scheme:
```c
#include <stdio.h>
#define MAX_SIZE 1000
int max(int a, int b) {
return a > b ? a : b;
}
int maxIndices(int *arr, int n, int d) {
int max_visits = 0;
for(int i = 0; i < n; i++) {
int visited[MAX_SIZE] = {0};
visited[i] = 1;
int count = 1;
... | dolphin | [
0.027366140857338905,
0.02022288739681244,
-0.01759924739599228,
-0.020476875826716423,
0.017236165702342987,
-0.02967199869453907,
-0.02340528927743435,
0.06115027889609337,
0.031827669590711594,
-0.012460622005164623,
0.024406924843788147,
0.024911101907491684,
-0.03286677598953247,
-0.0... | 0.853561 | 0.795424 | 0.058137 |
Please explain the reasoning behind the following solution and provide code in Kotlin:
A sequence is **special** if it consists of a **positive** number of `0`s, followed by a **positive** number of `1`s, then a **positive** number of `2`s.
* For example, `[0,1,2]` and `[0,0,1,1,1,2]` are special.
* In contrast, `... | dolphin | [
0.008346602320671082,
0.02407401241362095,
-0.014996059238910675,
-0.017850663512945175,
0.04034622758626938,
-0.027111588045954704,
-0.04193153604865074,
0.06002302095293999,
0.04574688896536827,
-0.023259572684764862,
0.0174128245562315,
0.028569689020514488,
-0.03682183846831322,
-0.001... | 0.853671 | 0.796716 | 0.056955 |
Please focus on the algorithm of this problem and provide code in R:
Given a string `s`, find _the longest palindromic **subsequence**'s length in_ `s`.
A **subsequence** is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
**Exa... | dolphin | [
0.00699925422668457,
0.006507128477096558,
-0.021817563101649284,
-0.030658669769763947,
0.028054093942046165,
-0.03505141660571098,
-0.019231274724006653,
0.05041908845305443,
0.037165697664022446,
-0.007939976640045643,
0.01616831310093403,
0.032606352120637894,
-0.024093830958008766,
-0... | 0.827044 | 0.77314 | 0.053903 |
Please explain the reasoning behind the following solution and provide code in F#:
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... | dolphin | [
0.022147957235574722,
0.01962449960410595,
-0.024007227271795273,
-0.009120329283177853,
0.04214247316122055,
-0.03223775699734688,
-0.02538810856640339,
0.06413805484771729,
0.0495130755007267,
-0.015244944021105766,
0.03251339867711067,
0.02660544030368328,
-0.0471273697912693,
-0.018794... | 0.843744 | 0.789888 | 0.053856 |
Please write the following solution using Mojo:
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` means that on the `(i+1)th` d... | dolphin | [
0.013784127309918404,
0.043958183377981186,
-0.03307562321424484,
-0.037259791046381,
0.031204650178551674,
-0.051199495792388916,
-0.03181500360369682,
0.06652761995792389,
0.022596325725317,
-0.012937663123011589,
0.021304761990904808,
0.029363645240664482,
-0.015673447400331497,
-0.0071... | 0.850943 | 0.797609 | 0.053334 |
Please explain the following problem in detail and provide code in java:
An array `arr` a **mountain** if the following properties hold:
* `arr.length >= 3`
* There exists some `i` with `0 < i < arr.length - 1` such that:
* `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]`
* `arr[i] > arr[i + 1] > ... > ar... | dolphin | [
0.034073252230882645,
0.03428695723414421,
-0.03568901866674423,
-0.035516805946826935,
0.022648194804787636,
-0.03834008798003197,
-0.04615171253681183,
0.0680975392460823,
0.023872215300798416,
-0.020442884415388107,
0.025133056566119194,
0.012243583798408508,
-0.04295438900589943,
-0.01... | 0.846487 | 0.779207 | 0.06728 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
Given a binary array `nums`, return _the maximum length of a contiguous subarray with an equal number of_ `0` _and_ `1`.
**Example 1:**
**Input:** nums = \[0,1\]
**Output:** 2
**Explanation:** \[0, 1\] is the longest contiguous sub... | dolphin | [
0.023555241525173187,
0.030872708186507225,
-0.01694868877530098,
-0.03103799931704998,
0.030009018257260323,
-0.027503542602062225,
-0.05188777297735214,
0.07434207946062088,
0.04228359833359718,
-0.021153302863240242,
0.025953928008675575,
0.02761855535209179,
-0.039674874395132065,
-0.0... | 0.837615 | 0.774376 | 0.063239 |
Please explain the following problem in detail and provide code in Kotlin:
You are given an array `nums`. You can rotate it by a non-negative integer `k` so that the array becomes `[nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]]`. Afterward, any entries that are less than or equal to... | dolphin | [
0.006022308021783829,
0.034403905272483826,
-0.009295103140175343,
-0.020945321768522263,
0.022652646526694298,
-0.022998303174972534,
-0.027829216793179512,
0.04479063302278519,
0.023041699081659317,
-0.008821165189146996,
0.01523901429027319,
0.0291502233594656,
-0.035482537001371384,
0.... | 0.842142 | 0.783113 | 0.059029 |
Please focus on the functionality of this problem and provide code in PHP:
Given an integer array `nums`, return `true` if any value appears **at least twice** in the array, and return `false` if every element is distinct.
**Example 1:**
**Input:** nums = \[1,2,3,1\]
**Output:** true
**Example 2:**
**Input:** nums ... | dolphin | [
0.011280989274382591,
0.019710006192326546,
-0.02218334563076496,
-0.01156842615455389,
0.035386886447668076,
-0.030495591461658478,
-0.003946093842387199,
0.07953501492738724,
0.0452459491789341,
-0.010613970458507538,
0.017080524936318398,
0.004022166598588228,
-0.022967245429754257,
-0.... | 0.833498 | 0.779114 | 0.054384 |
Please explain the reasoning behind the following solution and provide code in R:
You are given an integer array `nums` and an integer `k`.
In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array.
Return _the maximum number of operations you can perform on the arr... | dolphin | [
0.018948422744870186,
0.03405122086405754,
-0.02261655405163765,
-0.03730928152799606,
0.041799940168857574,
-0.012484388425946236,
-0.038996852934360504,
0.0672798901796341,
0.05061693489551544,
-0.0030720075592398643,
0.0033218604512512684,
0.02739041857421398,
-0.022915923967957497,
-0.... | 0.838012 | 0.783338 | 0.054674 |
Please write the following solution using PHP:
Given two integers `n` and `k`, return _all possible combinations of_ `k` _numbers chosen from the range_ `[1, n]`.
You may return the answer in **any order**.
**Example 1:**
**Input:** n = 4, k = 2
**Output:** \[\[1,2\],\[1,3\],\[1,4\],\[2,3\],\[2,4\],\[3,4\]\]
**Expla... | dolphin | [
0.03722798824310303,
0.048347216099500656,
-0.020452316850423813,
-0.024361157789826393,
0.05427514389157295,
-0.036577560007572174,
-0.007667505647987127,
0.04869447648525238,
0.04197589308023453,
0.013492634519934654,
0.044737692922353745,
0.029623720794916153,
-0.03517214581370354,
-0.0... | 0.817185 | 0.760403 | 0.056781 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.