instruction_seed stringlengths 308 3.48k | source stringclasses 1
value | embeddings listlengths 1.02k 1.02k | mean_positive_score float64 0.8 0.86 | mean_negative_score float64 0.74 0.8 | difference_score float64 0.05 0.07 |
|---|---|---|---|---|---|
Please explain the following problem in detail and provide code in Fortran:
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\]
**Ou... | dolphin | [
0.024227440357208252,
0.045158788561820984,
-0.019753364846110344,
-0.03060241974890232,
0.04148957133293152,
-0.034465573728084564,
-0.02466934733092785,
0.047302551567554474,
0.029662204906344414,
-0.008378217928111553,
0.025874225422739983,
0.042156435549259186,
-0.03083348646759987,
-0... | 0.835423 | 0.780484 | 0.054939 |
Please explain the following problem in detail and provide code in ANSI C:
You are given an array `arr` of positive integers. You are also given the array `queries` where `queries[i] = [lefti, righti]`.
For each query `i` compute the **XOR** of elements from `lefti` to `righti` (that is, `arr[lefti] XOR arr[lefti + 1]... | dolphin | [
0.0430196076631546,
0.0394350104033947,
-0.02089484967291355,
-0.023208094760775566,
0.01831355132162571,
-0.02829566039144993,
-0.033265192061662674,
0.08151295781135559,
0.046219415962696075,
-0.012032626196742058,
0.027483602985739708,
0.0009247080888599157,
-0.050199445337057114,
-0.02... | 0.839533 | 0.780567 | 0.058966 |
Please write the following solution using Haskell:
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 di... | dolphin | [
0.021790700033307076,
0.01768243871629238,
-0.01825355924665928,
-0.03394579142332077,
0.061544932425022125,
-0.036777056753635406,
-0.01859329827129841,
0.033790748566389084,
0.028322242200374603,
0.0006076675490476191,
0.02988499589264393,
0.043670061975717545,
-0.03771160915493965,
-0.0... | 0.832259 | 0.77787 | 0.054389 |
Please explain the following problem in detail and provide code in ANSI C:
Given an integer array `arr`, remove a subarray (can be empty) from `arr` such that the remaining elements in `arr` are **non-decreasing**.
Return _the length of the shortest subarray to remove_.
A **subarray** is a contiguous subsequence of t... | dolphin | [
0.011759066954255104,
0.047487348318099976,
-0.02416742965579033,
-0.035130780190229416,
0.042174480855464935,
-0.03907051682472229,
-0.04307479411363602,
0.06780724972486496,
0.06357631832361221,
-0.009885920211672783,
0.017898187041282654,
-0.003561627585440874,
-0.029704751446843147,
-0... | 0.832816 | 0.775458 | 0.057359 |
Please focus on the functionality of this problem and provide code in Elixir:
Given a positive integer `n`, find and return _the **longest distance** between any two **adjacent**_ `1`_'s in the binary representation of_ `n`_. If there are no two adjacent_ `1`_'s, return_ `0`_._
Two `1`'s are **adjacent** if there are ... | dolphin | [
0.029163561761379242,
0.029019517824053764,
-0.020202619954943657,
-0.04338987171649933,
0.01961801014840603,
-0.03692188858985901,
-0.03993877023458481,
0.04738914221525192,
0.036556512117385864,
-0.014859218150377274,
0.04230203479528427,
0.022261228412389755,
-0.026863940060138702,
0.00... | 0.849144 | 0.795759 | 0.053386 |
Please write the following solution using Scala:
Given the `root` of a binary tree, return the most frequent **subtree sum**. If there is a tie, return all the values with the highest frequency in any order.
The **subtree sum** of a node is defined as the sum of all the node values formed by the subtree rooted at that... | dolphin | [
0.0226006917655468,
0.025321412831544876,
-0.03092307411134243,
-0.019299814477562904,
0.02170475386083126,
-0.0319845974445343,
0.002340374980121851,
0.03973601385951042,
0.010034482926130295,
0.007019112352281809,
0.04173802584409714,
0.01984505169093609,
-0.02925238572061062,
0.01206781... | 0.828319 | 0.770663 | 0.057656 |
Please write the following solution using R:
You are given an integer `n` and an integer `start`.
Define an array `nums` where `nums[i] = start + 2 * i` (**0-indexed**) and `n == nums.length`.
Return _the bitwise XOR of all elements of_ `nums`.
**Example 1:**
**Input:** n = 5, start = 0
**Output:** 8
**Explanation:... | dolphin | [
0.027596598491072655,
0.034334324300289154,
-0.041187554597854614,
-0.021765395998954773,
0.023846467956900597,
-0.030590364709496498,
-0.025536159053444862,
0.07288007438182831,
0.04222780466079712,
-0.007907822728157043,
0.01804385893046856,
0.025773916393518448,
-0.05757482349872589,
-0... | 0.834649 | 0.777495 | 0.057154 |
Please write the following solution using c++:
You are given a **0-indexed** integer array `nums`. You have to partition the array into one or more **contiguous** subarrays.
We call a partition of the array **valid** if each of the obtained subarrays satisfies **one** of the following conditions:
1. The subarray con... | dolphin | [
0.028413260355591774,
0.0191132053732872,
-0.010974010452628136,
-0.02085164375603199,
0.03827556222677231,
-0.0020977871026843786,
-0.018919171765446663,
0.11086203157901764,
0.028362255543470383,
-0.01082440372556448,
0.02411705255508423,
0.020405640825629234,
-0.017642641440033913,
-0.0... | 0.847643 | 0.787171 | 0.060472 |
Please explain the reasoning behind the following solution and provide code in Objective-C:
You are given an integer array `nums`. You want to maximize the number of points you get by performing the following operation any number of times:
* Pick any `nums[i]` and delete it to earn `nums[i]` points. Afterwards, you ... | dolphin | [
0.021047160029411316,
0.02012728899717331,
-0.02535652555525303,
-0.028200380504131317,
0.03042241930961609,
-0.0439859963953495,
-0.03683652728796005,
0.060123980045318604,
0.039355307817459106,
-0.014254486188292503,
0.021989045664668083,
0.020830703899264336,
-0.03944632411003113,
-0.00... | 0.845507 | 0.790463 | 0.055044 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
Given an integer array `nums`, your goal is to make all elements in `nums` equal. To complete one operation, follow these steps:
1. Find the **largest** value in `nums`. Let its index be `i` (**0-indexed**) and its value be `larges... | dolphin | [
0.03008442558348179,
0.03008033148944378,
-0.03134043514728546,
-0.042021408677101135,
0.027316657826304436,
-0.02970890700817108,
-0.02871214598417282,
0.0827549546957016,
0.026459863409399986,
-0.02861666865646839,
0.03846687451004982,
0.024297069758176804,
-0.04336818680167198,
-0.00722... | 0.839462 | 0.781516 | 0.057946 |
Please write the following solution using ANSI C:
Given an integer `n`, return the `nth` digit of the infinite integer sequence `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]`.
**Example 1:**
**Input:** n = 3
**Output:** 3
**Example 2:**
**Input:** n = 11
**Output:** 0
**Explanation:** The 11th digit of the sequence 1, ... | dolphin | [
0.03475983440876007,
0.03941943123936653,
0.004696818068623543,
-0.06182779371738434,
0.019861212000250816,
-0.03525609150528908,
-0.03822150453925133,
0.061698827892541885,
0.02163991890847683,
-0.006865070667117834,
0.04063926637172699,
0.031426090747117996,
-0.0666789561510086,
-0.01741... | 0.818142 | 0.762092 | 0.05605 |
Please focus on the efficiency of this problem and provide code in Scheme:
In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has `n` empty baskets, the `ith` basket is at `position[i]`, Morty has `m` balls and needs to distri... | dolphin | [
0.03376462683081627,
0.02924056351184845,
-0.034250643104314804,
-0.02327963523566723,
0.03227757290005684,
-0.023807667195796967,
-0.03686100244522095,
0.03937412053346634,
0.03721059113740921,
-0.023102616891264915,
0.018664343282580376,
0.03948899358510971,
-0.01711917854845524,
-0.0118... | 0.84521 | 0.790233 | 0.054976 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You are given an integer array `nums` and an integer `k`.
In one operation, you can choose any index `i` where `0 <= i < nums.length` and change `nums[i]` to `nums[i] + x` where `x` is an integer from the range `[-k, k]`. You can apply this ope... | dolphin | [
0.012787215411663055,
0.03250694274902344,
-0.016151024028658867,
-0.029309384524822235,
0.03210759162902832,
-0.032203979790210724,
-0.043696966022253036,
0.07924584299325943,
0.03888736665248871,
-0.013091491535305977,
0.02677117846906185,
0.024859415367245674,
-0.040257710963487625,
-0.... | 0.847784 | 0.789086 | 0.058698 |
Please focus on the functionality of this problem and provide code in C#:
Given a 2D `grid` of `0`s and `1`s, return the number of elements in the largest **square** subgrid that has all `1`s on its **border**, or `0` if such a subgrid doesn't exist in the `grid`.
**Example 1:**
**Input:** grid = \[\[1,1,1\],\[1,0,1\... | dolphin | [
0.005552785005420446,
0.03337286040186882,
-0.02288607507944107,
-0.033328983932733536,
0.02233736403286457,
-0.03048497624695301,
-0.02793421596288681,
0.07494263350963593,
0.033239979296922684,
-0.006265490781515837,
0.018007274717092514,
0.023289082571864128,
-0.03595121577382088,
-0.02... | 0.836894 | 0.776183 | 0.060711 |
Please explain the following problem in detail and provide code in python:
You are given a **0-indexed** array `nums` consisting of `n` positive integers.
The array `nums` is called **alternating** if:
* `nums[i - 2] == nums[i]`, where `2 <= i <= n - 1`.
* `nums[i - 1] != nums[i]`, where `1 <= i <= n - 1`.
In on... | dolphin | [
0.016606546938419342,
0.034909687936306,
-0.0112784868106246,
-0.012502250261604786,
0.02204704098403454,
-0.030604878440499306,
-0.027913834899663925,
0.061101529747247696,
0.02190288156270981,
-0.011672220192849636,
0.006711102556437254,
-0.005192034412175417,
-0.036167293787002563,
-0.0... | 0.845362 | 0.789903 | 0.055458 |
Please explain the following problem in detail and provide code in c++:
Given a **0-indexed** `n x n` integer matrix `grid`, _return the number of pairs_ `(ri, cj)` _such that row_ `ri` _and column_ `cj` _are equal_.
A row and column pair is considered equal if they contain the same elements in the same order (i.e., a... | dolphin | [
0.00556074408814311,
0.013343537226319313,
-0.036095812916755676,
-0.04281280189752579,
0.039813753217458725,
-0.013147762045264244,
-0.02349071390926838,
0.09282904118299484,
0.03201371058821678,
-0.02757686749100685,
0.02107665129005909,
0.017433125525712967,
-0.03829565271735191,
-0.015... | 0.839925 | 0.778741 | 0.061184 |
Please write the following solution using Object Pascal:
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\]... | dolphin | [
0.043548908084630966,
0.04293515160679817,
-0.017221013084053993,
-0.03251784294843674,
0.05562341585755348,
-0.0326591432094574,
0.002820218913257122,
0.037020083516836166,
0.0437261201441288,
0.017045754939317703,
0.04752699285745621,
0.03585558384656906,
-0.02775656059384346,
-0.0034100... | 0.822418 | 0.765608 | 0.056811 |
Please explain the reasoning behind the following solution and provide code in C#:
You are given a **0-indexed** integer array `nums` and an integer `k`.
You are initially standing at index `0`. In one move, you can jump at most `k` steps forward without going outside the boundaries of the array. That is, you can jump... | dolphin | [
-0.0023122269194573164,
0.021651051938533783,
-0.012495317496359348,
-0.0351368747651577,
0.03786661848425865,
-0.0278927031904459,
-0.030802827328443527,
0.07433562725782394,
0.039967525750398636,
-0.0049265059642493725,
0.0248930174857378,
0.03067735768854618,
-0.041707318276166916,
-0.0... | 0.84948 | 0.794271 | 0.055209 |
Please explain the following problem in detail and provide code in Elixir:
You are given a **0-indexed** integer array `nums`. You can apply the following operation any number of times:
* Pick any element from `nums` and put it at the end of `nums`.
The prefix sum array of `nums` is an array `prefix` of the same le... | dolphin | [
0.009449053555727005,
0.01878591626882553,
-0.01168505847454071,
-0.03469394892454147,
0.01947949081659317,
-0.02661169320344925,
-0.01531184185296297,
0.05195775628089905,
0.03829207271337509,
-0.00317148445174098,
0.01231200061738491,
0.028175098821520805,
-0.01761937141418457,
-0.025979... | 0.853054 | 0.792903 | 0.060151 |
Please explain the following problem in detail and provide code in c++:
You are given a **0-indexed** integer array `order` of length `n`, a **permutation** of integers from `1` to `n` representing the **order** of insertion into a **binary search tree**.
A binary search tree is defined as follows:
* The left subtr... | dolphin | [
0.01956017129123211,
0.019614148885011673,
-0.0271656084805727,
-0.028330110013484955,
0.021850883960723877,
-0.021450145170092583,
-0.016167456284165382,
0.0874815359711647,
0.02805713564157486,
-0.004177196882665157,
0.028014231473207474,
0.01663888804614544,
-0.023086799308657646,
0.013... | 0.831244 | 0.77472 | 0.056523 |
Please explain the following problem in detail and provide code in javascript:
Given a string s, return _the number of different non-empty palindromic subsequences in_ `s`. Since the answer may be very large, return it **modulo** `109 + 7`.
A subsequence of a string is obtained by deleting zero or more characters from... | dolphin | [
0.0038095603231340647,
0.0029936109203845263,
-0.026395481079816818,
-0.02231750264763832,
0.03288077563047409,
-0.036508720368146896,
-0.007380180060863495,
0.05313549190759659,
0.03578763082623482,
-0.014058546163141727,
0.02943471632897854,
0.016438394784927368,
-0.03923357278108597,
-0... | 0.836273 | 0.781151 | 0.055123 |
Please write the following solution using c++:
You are given an `m x n` binary matrix `grid`.
A **move** consists of choosing any row or column and toggling each value in that row or column (i.e., changing all `0`'s to `1`'s, and all `1`'s to `0`'s).
Every row of the matrix is interpreted as a binary number, and the ... | dolphin | [
0.005745301488786936,
0.013586974702775478,
-0.016599806025624275,
-0.046872980892658234,
0.05030607804656029,
-0.039514362812042236,
-0.04033493995666504,
0.08327702432870865,
0.03548388183116913,
-0.003913195338100195,
0.018334226682782173,
0.022263377904891968,
-0.04258408024907112,
-0.... | 0.83466 | 0.774291 | 0.06037 |
Please write the following solution using Julia:
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` ... | dolphin | [
0.006032693665474653,
0.044227223843336105,
-0.03705219551920891,
-0.03511270135641098,
0.032679274678230286,
-0.045488834381103516,
-0.02535221539437771,
0.06897664815187454,
0.022628596052527428,
-0.0075701382011175156,
0.020557420328259468,
0.031340375542640686,
-0.008219134993851185,
0... | 0.849537 | 0.794489 | 0.055049 |
Please focus on the functionality of this problem and provide code in Elixir:
Given an integer array `nums`, return _the number of **reverse pairs** in the array_.
A **reverse pair** is a pair `(i, j)` where:
* `0 <= i < j < nums.length` and
* `nums[i] > 2 * nums[j]`.
**Example 1:**
**Input:** nums = \[1,3,2,3,... | dolphin | [
0.013847436755895615,
0.03383203595876694,
-0.023300599306821823,
-0.033273763954639435,
0.022760316729545593,
0.0008431209716945887,
-0.014513762667775154,
0.05290365591645241,
0.030669623985886574,
0.005040963180363178,
0.017343182116746902,
0.026172492653131485,
-0.029676036909222603,
-... | 0.84289 | 0.786391 | 0.056499 |
translate this code to Scheme:
```cpp
int findLengthOfShortestSubarray(vector<int>& arr) {
int n = arr.size();
int left = 0, right = n - 1;
while (left < n - 1 && arr[left] <= arr[left + 1]) left++;
if (left == n - 1) return 0;
while (right > 0 && arr[right] >= arr[right - 1]) right--;
int re... | dolphin | [
0.02325468324124813,
0.021155640482902527,
-0.025845669209957123,
-0.03658663481473923,
0.038936156779527664,
-0.0092546995729208,
-0.030848218128085136,
0.08082044124603271,
0.04550102725625038,
-0.01030722539871931,
0.021396715193986893,
0.030734403058886528,
-0.016136951744556427,
0.000... | 0.829548 | 0.771999 | 0.057549 |
Please write the following solution using ANSI C:
Given four integer arrays `nums1`, `nums2`, `nums3`, and `nums4` all of length `n`, return the number of tuples `(i, j, k, l)` such that:
* `0 <= i, j, k, l < n`
* `nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0`
**Example 1:**
**Input:** nums1 = \[1,2\], nums2 =... | dolphin | [
0.011314612813293934,
0.0315246507525444,
-0.01862766407430172,
-0.037806324660778046,
0.04984992370009422,
-0.0242275632917881,
-0.03716510906815529,
0.07698177546262741,
0.032789234071969986,
-0.00849102158099413,
0.010601666755974293,
0.016414940357208252,
-0.04374044016003609,
-0.03880... | 0.847653 | 0.787378 | 0.060275 |
Please explain the following problem in detail and provide code in Objective-C:
You are given an integer array `arr`.
We split `arr` into some number of **chunks** (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array.
Return _the largest number of ch... | dolphin | [
0.051000066101551056,
0.030549149960279465,
-0.014979486353695393,
-0.01789853535592556,
0.0261220745742321,
-0.015399806201457977,
-0.042043935507535934,
0.040949828922748566,
0.016670629382133484,
-0.022179637104272842,
0.027084870263934135,
0.00868840329349041,
-0.03607682138681412,
0.0... | 0.834622 | 0.771174 | 0.063448 |
Please focus on the efficiency of this problem and provide code in Objective-C:
You have an array `arr` of length `n` where `arr[i] = (2 * i) + 1` for all valid values of `i` (i.e., `0 <= i < n`).
In one operation, you can select two indices `x` and `y` where `0 <= x, y < n` and subtract `1` from `arr[x]` and add `1` ... | dolphin | [
0.02982417494058609,
0.02555011957883835,
-0.037648070603609085,
-0.04429291933774948,
0.024315742775797844,
-0.03632786497473717,
-0.030439753085374832,
0.07785428315401077,
0.027403343468904495,
-0.026856504380702972,
0.03001224622130394,
0.010844627395272255,
-0.026123248040676117,
-0.0... | 0.844221 | 0.789531 | 0.05469 |
Please explain the following problem in detail and provide code in Visual Basic .NET:
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.012441481463611126,
0.019407816231250763,
-0.008850148878991604,
-0.02107303775846958,
0.04021017253398895,
-0.019785771146416664,
-0.021795004606246948,
0.07378990203142166,
0.04773945361375809,
-0.012314383871853352,
0.037340689450502396,
0.023125972598791122,
-0.05610836297273636,
-0.... | 0.839028 | 0.778592 | 0.060436 |
Please focus on the functionality of this problem and provide code in R:
Given an array `nums` of positive integers, return the longest possible length of an array prefix of `nums`, such that it is possible to remove **exactly one** element from this prefix so that every number that has appeared in it will have the sam... | dolphin | [
0.017553191632032394,
0.025078797712922096,
-0.03549962118268013,
-0.03538890928030014,
0.024370567873120308,
-0.030288832262158394,
-0.03529820591211319,
0.06105548515915871,
0.041438888758420944,
-0.01527786161750555,
0.0047852592542767525,
0.009345264174044132,
-0.01405719667673111,
-0.... | 0.847505 | 0.790066 | 0.057439 |
Please write the following solution using R:
Given an integer array `nums` and two integers `firstLen` and `secondLen`, return _the maximum sum of elements in two non-overlapping **subarrays** with lengths_ `firstLen` _and_ `secondLen`.
The array with length `firstLen` could occur before or after the array with length... | dolphin | [
0.01384969986975193,
0.02536444552242756,
-0.036868561059236526,
-0.03248056396842003,
0.03674227371811867,
-0.004349911585450172,
-0.045896586030721664,
0.04855554178357124,
0.041434112936258316,
-0.010040398687124252,
0.021145157516002655,
0.041407495737075806,
-0.04399923235177994,
-0.0... | 0.833144 | 0.771871 | 0.061273 |
Please write the following solution using ANSI C:
A perfectly straight street is represented by a number line. The street has street lamp(s) on it and is represented by a 2D integer array `lights`. Each `lights[i] = [positioni, rangei]` indicates that there is a street lamp at position `positioni` that lights up the ar... | dolphin | [
0.019450640305876732,
0.04739953950047493,
-0.025875385850667953,
-0.03742668032646179,
0.03921155631542206,
-0.03953590989112854,
-0.0334610790014267,
0.0743091031908989,
0.040706925094127655,
-0.02158740721642971,
0.034007325768470764,
0.0438586100935936,
-0.043451543897390366,
-0.051502... | 0.840965 | 0.784767 | 0.056198 |
Please explain the following problem in detail and provide code in Julia:
You are given an integer array `nums` and an integer `k`. Find the **largest even sum** of any subsequence of `nums` that has a length of `k`.
Return _this sum, or_ `-1` _if such a sum does not exist_.
A **subsequence** is an array that can be ... | dolphin | [
0.01564936898648739,
0.036196768283843994,
-0.02883104234933853,
-0.04624528810381889,
0.030853739008307457,
-0.01008814200758934,
-0.017697155475616455,
0.055027320981025696,
0.03661075234413147,
-0.010194959118962288,
0.024600550532341003,
0.03524400293827057,
-0.031149450689554214,
0.01... | 0.839935 | 0.783056 | 0.056879 |
Please explain the following problem in detail and provide code in Scheme:
The **n-queens** puzzle is the problem of placing `n` queens on an `n x n` chessboard such that no two queens attack each other.
Given an integer `n`, return _the number of distinct solutions to the **n-queens puzzle**_.
**Example 1:**
**Inpu... | dolphin | [
0.029029756784439087,
0.015518808737397194,
-0.035826511681079865,
-0.02553347311913967,
0.03308333083987236,
-0.012838071212172508,
-0.01605053059756756,
0.05761411413550377,
0.04169641062617302,
-0.0009094890556298196,
0.03132932260632515,
0.025952408090233803,
-0.041986335068941116,
-0.... | 0.828577 | 0.772634 | 0.055943 |
Please explain the following problem in detail and provide code in ANSI C:
Given an array of integers `arr`, you are initially positioned at the first index of the array.
In one step you can jump from index `i` to index:
* `i + 1` where: `i + 1 < arr.length`.
* `i - 1` where: `i - 1 >= 0`.
* `j` where: `arr[i] ... | dolphin | [
0.016871338710188866,
0.03697272017598152,
-0.01584925688803196,
-0.0444239042699337,
0.03767784684896469,
-0.03337898105382919,
-0.05032140016555786,
0.07283679395914078,
0.03164752945303917,
-0.019730733707547188,
0.02969643473625183,
0.005004602484405041,
-0.04325084388256073,
-0.008451... | 0.841727 | 0.779934 | 0.061792 |
Please focus on the functionality of this problem and provide code in Kotlin:
Given an integer n, return _the smallest **prime palindrome** greater than or equal to_ `n`.
An integer is **prime** if it has exactly two divisors: `1` and itself. Note that `1` is not a prime number.
* For example, `2`, `3`, `5`, `7`, `... | dolphin | [
0.025979062542319298,
0.0264284648001194,
0.00030557624995708466,
-0.039071254432201385,
0.02732732519507408,
-0.03166939690709114,
-0.0074969627894461155,
0.06713088601827621,
0.03333001211285591,
-0.010601521469652653,
0.03512890636920929,
0.020227668806910515,
-0.023285754024982452,
-0.... | 0.829974 | 0.776239 | 0.053735 |
Please explain the reasoning behind the following solution and provide code in c++:
Given a **(0-indexed)** integer array `nums` and two integers `low` and `high`, return _the number of **nice pairs**_.
A **nice pair** is a pair `(i, j)` where `0 <= i < j < nums.length` and `low <= (nums[i] XOR nums[j]) <= high`.
**E... | dolphin | [
0.007983207702636719,
0.010290317237377167,
-0.0344826877117157,
-0.011180544272065163,
0.04451524466276169,
0.0009372977074235678,
-0.04182807356119156,
0.08660835027694702,
0.03418901190161705,
-0.011096090078353882,
0.02234727330505848,
0.03382866457104683,
-0.03896324336528778,
-0.0218... | 0.84238 | 0.784439 | 0.057941 |
Please write the following solution using java:
You are given two positive integers `left` and `right` with `left <= right`. Calculate the **product** of all integers in the **inclusive** range `[left, right]`.
Since the product may be very large, you will **abbreviate** it following these steps:
1. Count all **trai... | dolphin | [
0.028783151879906654,
0.038550108671188354,
-0.04099152609705925,
-0.02289591170847416,
0.034850720316171646,
-0.03399315103888512,
-0.018682872876524925,
0.05821666121482849,
0.03932628780603409,
-0.01677611656486988,
0.014435996301472187,
0.02614418789744377,
-0.029756642878055573,
-0.03... | 0.840864 | 0.786284 | 0.054581 |
Please write the following solution using Ruby:
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,2,2\]
**Output:** \[\[\],\[... | dolphin | [
0.04414425790309906,
0.030694657936692238,
-0.019168436527252197,
-0.02640681341290474,
0.04516308009624481,
-0.03882580250501633,
-0.0033175377175211906,
0.0492778904736042,
0.052716150879859924,
-0.03721721097826958,
0.038455069065093994,
0.018562056124210358,
-0.045240651816129684,
-0.0... | 0.83578 | 0.781471 | 0.054309 |
Please focus on the efficiency of this problem and provide code in PHP:
Given an `m x n` `matrix`, return _a new matrix_ `answer` _where_ `answer[row][col]` _is the_ _**rank** of_ `matrix[row][col]`.
The **rank** is an **integer** that represents how large an element is compared to other elements. It is calculated usi... | dolphin | [
0.026881122961640358,
0.0337480753660202,
-0.029685966670513153,
-0.03748597949743271,
0.041170403361320496,
-0.024606425315141678,
-0.021293876692652702,
0.06502930819988251,
0.059235744178295135,
-0.01807212270796299,
0.01230891328305006,
0.016728432849049568,
-0.034112218767404556,
-0.0... | 0.84013 | 0.786395 | 0.053735 |
Please write the following solution using Objective-C:
You are given `n` rectangles represented by a **0-indexed** 2D integer array `rectangles`, where `rectangles[i] = [widthi, heighti]` denotes the width and height of the `ith` rectangle.
Two rectangles `i` and `j` (`i < j`) are considered **interchangeable** if the... | dolphin | [
0.0128516536206007,
0.047662604600191116,
-0.04016239941120148,
-0.018570682033896446,
0.034856121987104416,
-0.010195422917604446,
-0.034267157316207886,
0.0590474009513855,
0.031143954023718834,
-0.03000699169933796,
0.021600302308797836,
0.018626246601343155,
-0.033828891813755035,
-0.0... | 0.840126 | 0.78126 | 0.058865 |
Please explain the following problem in detail and provide code in Scheme:
Given the array `nums`, for each `nums[i]` find out how many numbers in the array are smaller than it. That is, for each `nums[i]` you have to count the number of valid `j's` such that `j != i` **and** `nums[j] < nums[i]`.
Return the answer in ... | dolphin | [
0.000311863113893196,
0.0366467610001564,
-0.01962488889694214,
-0.02560088038444519,
0.04194808751344681,
-0.013140484690666199,
-0.021684957668185234,
0.058055728673934937,
0.041237715631723404,
-0.0057482062838971615,
0.013712350279092789,
0.01497666072100401,
-0.05878099054098129,
-0.0... | 0.834129 | 0.777193 | 0.056935 |
Please focus on the algorithm of this problem and provide code in 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 ano... | dolphin | [
0.012546535581350327,
0.02446548081934452,
-0.020440421998500824,
-0.027139484882354736,
0.013513082638382912,
-0.036402150988578796,
-0.004318412393331528,
0.09575972706079483,
0.013902971521019936,
-0.022200793027877808,
0.03879792243242264,
0.01828303188085556,
-0.022983377799391747,
-0... | 0.839262 | 0.784353 | 0.054909 |
Please write the following solution using Kotlin:
Given an integer array `nums` and an integer `k`, split `nums` into `k` non-empty subarrays such that the largest sum of any subarray is **minimized**.
Return _the minimized largest sum of the split_.
A **subarray** is a contiguous part of the array.
**Example 1:**
... | dolphin | [
0.016010675579309464,
0.026118146255612373,
-0.03381425514817238,
-0.0283635426312685,
0.04323457181453705,
-0.004429815337061882,
-0.022177457809448242,
0.045323025435209274,
0.03931368142366409,
-0.010990647599101067,
0.033575043082237244,
0.03305080533027649,
-0.03195730224251747,
0.017... | 0.835915 | 0.773261 | 0.062654 |
Please write the following solution using C#:
Given an integer array `nums` of **unique** elements, 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,2,3\]
**Output:** \[\[\],\[1\],\[2... | dolphin | [
0.04158219322562218,
0.026229819282889366,
-0.011162346228957176,
-0.015290756709873676,
0.04390741512179375,
-0.043539341539144516,
-0.00807873997837305,
0.07330568879842758,
0.05815403163433075,
-0.017445344477891922,
0.03079707734286785,
0.021213050931692123,
-0.05053160712122917,
-0.03... | 0.833364 | 0.770974 | 0.06239 |
Please write the following solution using Object Pascal:
Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`.
Each number in `candidates` may only be used **once** in the combination.
**Note:** ... | dolphin | [
0.025465279817581177,
0.03237930312752724,
-0.016871802508831024,
-0.022137045860290527,
0.05102166160941124,
-0.014933635480701923,
-0.011108282022178173,
0.030429121106863022,
0.046461574733257294,
-0.0003367739263921976,
0.023624634370207787,
0.021974759176373482,
-0.025256505236029625,
... | 0.837165 | 0.782753 | 0.054412 |
Please explain the following problem in detail and provide code in Fortran:
You are given an integer array `nums` and an integer `k`. You may partition `nums` into one or more **subsequences** such that each element in `nums` appears in **exactly** one of the subsequences.
Return _the **minimum** number of subsequence... | dolphin | [
0.02549794502556324,
0.018219683319330215,
-0.026116065680980682,
-0.015450378879904747,
0.0392395444214344,
-0.007609793916344643,
-0.022574467584490776,
0.061283305287361145,
0.026720961555838585,
0.004759198520332575,
0.02936309389770031,
0.037630755454301834,
-0.029271479696035385,
0.0... | 0.841562 | 0.783537 | 0.058025 |
Please focus on the efficiency of this problem and provide code in Scheme:
An array `nums` of length `n` is **beautiful** if:
* `nums` is a permutation of the integers in the range `[1, n]`.
* For every `0 <= i < j < n`, there is no index `k` with `i < k < j` where `2 * nums[k] == nums[i] + nums[j]`.
Given the in... | dolphin | [
0.03501874953508377,
0.03885086998343468,
-0.024883819743990898,
-0.030313830822706223,
0.033236611634492874,
-0.03208824247121811,
-0.04446475952863693,
0.05039740353822708,
0.03953888267278671,
-0.008420182392001152,
0.030682597309350967,
0.040261369198560715,
-0.03351948782801628,
-0.01... | 0.845279 | 0.777311 | 0.067968 |
Please focus on the efficiency of this problem and provide code in javascript:
You are given a string `s` that consists of the digits `'1'` to `'9'` and two integers `k` and `minLength`.
A partition of `s` is called **beautiful** if:
* `s` is partitioned into `k` non-intersecting substrings.
* Each substring has ... | dolphin | [
0.018345506861805916,
0.01861756294965744,
-0.04071209579706192,
-0.038043998181819916,
0.03422316536307335,
-0.032780278474092484,
-0.015911953523755074,
0.0500338114798069,
0.03962705284357071,
-0.009456900879740715,
0.039581216871738434,
0.02383340336382389,
-0.02121586911380291,
0.0040... | 0.857154 | 0.8021 | 0.055053 |
Please focus on the functionality of this problem and provide code in c++:
There is a robot on an `m x n` grid. The robot is initially located at the **top-left corner** (i.e., `grid[0][0]`). The robot tries to move to the **bottom-right corner** (i.e., `grid[m - 1][n - 1]`). The robot can only move either down or righ... | dolphin | [
0.006691149901598692,
0.02197074703872204,
-0.013570594601333141,
-0.02508179284632206,
0.027906572446227074,
-0.0070024956949055195,
-0.03307536989450455,
0.08778312802314758,
0.04126235842704773,
-0.013295714743435383,
0.02150586061179638,
0.05249756574630737,
-0.01967761293053627,
-0.03... | 0.844499 | 0.787562 | 0.056937 |
Please write the following solution using Scheme:
Given two integers `num` and `k`, consider a set of positive integers with the following properties:
* The units digit of each integer is `k`.
* The sum of the integers is `num`.
Return _the **minimum** possible size of such a set, or_ `-1` _if no such set exists.... | dolphin | [
0.025753755122423172,
0.03051653318107128,
-0.035618122667074203,
-0.035974081605672836,
0.03799698129296303,
-0.028075190261006355,
-0.018596818670630455,
0.04754802957177162,
0.03934271261096001,
-0.011235236190259457,
0.03249016031622887,
0.04256637766957283,
-0.026478545740246773,
-0.0... | 0.84371 | 0.773814 | 0.069896 |
Please explain the following problem in detail and provide code in python:
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... | dolphin | [
0.014196932315826416,
0.029142457991838455,
-0.032834142446517944,
-0.02944224514067173,
0.039045631885528564,
-0.017638953402638435,
-0.025327885523438454,
0.05066486448049545,
0.01939164102077484,
-0.027279073372483253,
0.01537356711924076,
0.013805657625198364,
-0.022199969738721848,
-0... | 0.849723 | 0.796182 | 0.053541 |
Please explain the following problem in detail and provide code in PHP:
Let's say a positive integer is a **super-palindrome** if it is a palindrome, and it is also the square of a palindrome.
Given two positive integers `left` and `right` represented as strings, return _the number of **super-palindromes** integers in... | dolphin | [
0.01504184678196907,
0.03609718754887581,
-0.026182908564805984,
-0.022800087928771973,
0.024164477363228798,
-0.009288172237575054,
-0.015347170643508434,
0.05442751571536064,
0.033305153250694275,
-0.007425909861922264,
0.032602835446596146,
0.027052760124206543,
-0.03460763394832611,
-0... | 0.836254 | 0.772463 | 0.063791 |
Please explain the following problem in detail and provide code in python:
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:** nums ... | dolphin | [
0.017122112214565277,
0.032305240631103516,
-0.040401261299848557,
-0.019432326778769493,
0.036775168031454086,
-0.03095771186053753,
-0.02745683118700981,
0.0505477637052536,
0.02052590809762478,
0.0011828403221443295,
0.021635744720697403,
0.020196784287691116,
-0.019310588017106056,
0.0... | 0.84277 | 0.780903 | 0.061867 |
translate this code to java:
```c
#include <stdio.h>
int minOperations(int* nums, int numsSize){
int i = 0, j = numsSize - 1;
int operations = 0;
while(i < j){
if(nums[i] == nums[j]){
i++;
j--;
}
else if(nums[i] < nums[j]){
nums[i+1] += nums[... | dolphin | [
0.0161272119730711,
0.02009320817887783,
-0.034770529717206955,
-0.017628517001867294,
0.03816814348101616,
-0.009841379709541798,
-0.02687419205904007,
0.05213356018066406,
0.03331412374973297,
-0.0220502857118845,
0.018111934885382652,
0.00005052454798715189,
-0.030332425609230995,
-0.01... | 0.839579 | 0.780165 | 0.059414 |
Please write the following solution using Mojo:
You are given a positive integer `num`. You may swap any two digits of `num` that have the same **parity** (i.e. both odd digits or both even digits).
Return _the **largest** possible value of_ `num` _after **any** number of swaps._
**Example 1:**
**Input:** num = 1234... | dolphin | [
0.036121074110269547,
0.02479236014187336,
-0.019396815448999405,
-0.039744772017002106,
0.010806210339069366,
-0.013376029208302498,
-0.03797616809606552,
0.034619107842445374,
0.030037807300686836,
-0.01728171296417713,
0.027370736002922058,
0.027393018826842308,
-0.05352582782506943,
-0... | 0.8364 | 0.774545 | 0.061854 |
Please explain the following problem in detail and provide code in java:
Given an integer array `nums`, return _the number of non-empty **subarrays** with the leftmost element of the subarray not larger than other elements in the subarray_.
A **subarray** is a **contiguous** part of an array.
**Example 1:**
**Input:... | dolphin | [
0.019944775849580765,
0.032257094979286194,
-0.03483420982956886,
-0.025636015459895134,
0.03380635753273964,
-0.004498930182307959,
-0.03694397956132889,
0.044756930321455,
0.016277780756354332,
-0.010715269483625889,
0.0354754813015461,
0.03401803597807884,
-0.04712335020303726,
-0.01141... | 0.84606 | 0.782788 | 0.063272 |
Please write the following solution using Scala:
Given an integer `n`, return the count of all numbers with unique digits, `x`, where `0 <= x < 10n`.
**Example 1:**
**Input:** n = 2
**Output:** 91
**Explanation:** The answer should be the total numbers in the range of 0 <= x < 100, excluding 11,22,33,44,55,66,77,88,9... | dolphin | [
0.0026440341025590897,
0.013118493370711803,
-0.026327697560191154,
-0.02895326539874077,
0.037210363894701004,
-0.02585095353424549,
-0.013740653172135353,
0.03504730761051178,
0.019336003810167313,
-0.00450117839500308,
0.010323148220777512,
0.03143526613712311,
-0.03709140419960022,
-0.... | 0.825424 | 0.767403 | 0.058021 |
Please write the following solution using ANSI C:
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 given array after partitioni... | dolphin | [
0.03869142383337021,
0.04159751534461975,
-0.01799570396542549,
-0.034864600747823715,
0.02694839984178543,
-0.022305143997073174,
-0.03608804568648338,
0.06076924875378609,
0.03288272023200989,
-0.01655632071197033,
0.04432446509599686,
0.016686489805579185,
-0.04398629814386368,
-0.01032... | 0.835868 | 0.766814 | 0.069054 |
Please explain the following problem in detail and provide code in Object Pascal:
We have an integer array `arr`, where all the integers in `arr` are equal except for one integer which is **larger** than the rest of the integers. You will not be given direct access to the array, instead, you will have an **API** `Array... | dolphin | [
0.01987878419458866,
0.04629654064774513,
-0.01632368192076683,
-0.05098572000861168,
0.039869558066129684,
-0.022133169695734978,
-0.028160370886325836,
0.06501792371273041,
0.04473535716533661,
-0.010149284265935421,
0.024593936279416084,
0.018235769122838974,
-0.04206507280468941,
0.004... | 0.843977 | 0.790387 | 0.05359 |
Please write the following solution using Object Pascal:
You are given a **0-indexed**, **strictly increasing** integer array `nums` and a positive integer `diff`. A triplet `(i, j, k)` is an **arithmetic triplet** if the following conditions are met:
* `i < j < k`,
* `nums[j] - nums[i] == diff`, and
* `nums[k] ... | dolphin | [
0.026827771216630936,
0.025387408211827278,
-0.01741548627614975,
-0.028716014698147774,
0.0495576448738575,
-0.015311747789382935,
-0.023444434627890587,
0.06342437863349915,
0.04343123733997345,
-0.007918205112218857,
0.024288121610879898,
0.0024705829564481974,
-0.04220840334892273,
-0.... | 0.843837 | 0.782839 | 0.060998 |
Please explain the following problem in detail and provide code in ANSI C:
A **subsequence** of a string is good if it is not empty and the frequency of each one of its characters is the same.
Given a string `s`, return _the number of good subsequences of_ `s`. Since the answer may be too large, return it modulo `109 ... | dolphin | [
0.020302047953009605,
0.013781137764453888,
-0.02922791987657547,
-0.03823358938097954,
0.03103777766227722,
-0.03928443416953087,
-0.029783260077238083,
0.06140584498643875,
0.01374176237732172,
-0.015583801083266735,
0.013081258162856102,
0.02560211345553398,
-0.03919411823153496,
-0.022... | 0.837371 | 0.782565 | 0.054806 |
Please write the following solution using c++:
Given an array of `n` integers `nums` and an integer `target`, find the number of index triplets `i`, `j`, `k` with `0 <= i < j < k < n` that satisfy the condition `nums[i] + nums[j] + nums[k] < target`.
**Example 1:**
**Input:** nums = \[-2,0,1,3\], target = 2
**Output:... | dolphin | [
0.013304789550602436,
0.005938027985394001,
-0.024148469790816307,
-0.023928266018629074,
0.05055207014083862,
0.002862504217773676,
-0.03884008154273033,
0.07063359767198563,
0.02917581982910633,
0.0027593174017965794,
0.015998994931578636,
0.03488684445619583,
-0.04835847020149231,
-0.03... | 0.845342 | 0.779986 | 0.065357 |
Please explain the following problem in detail and provide code in ANSI C:
Given an integer `n`, count _the total number of digit_ `1` _appearing in all non-negative integers less than or equal to_ `n`.
**Example 1:**
**Input:** n = 13
**Output:** 6
**Example 2:**
**Input:** n = 0
**Output:** 0
**Constraints:**
*... | dolphin | [
0.010701116174459457,
0.026921482756733894,
-0.02410578913986683,
-0.04043402895331383,
0.030773546546697617,
-0.02780517376959324,
-0.034820735454559326,
0.06400001049041748,
0.018891673535108566,
0.010395335964858532,
0.031368743628263474,
0.030496161431074142,
-0.04455605521798134,
-0.0... | 0.829622 | 0.768372 | 0.06125 |
Please explain the following problem in detail and provide code in Scheme:
You are given a **0-indexed** integer array `nums`. You are also given an integer `key`, which is present in `nums`.
For every unique integer `target` in `nums`, **count** the number of times `target` immediately follows an occurrence of `key` ... | dolphin | [
0.034780245274305344,
0.028126144781708717,
-0.03607075288891792,
-0.010578857734799385,
0.03517615422606468,
-0.014408308081328869,
-0.042438097298145294,
0.05343037471175194,
0.026447482407093048,
-0.009794705547392368,
0.02257089503109455,
0.009602396748960018,
-0.03159475326538086,
0.0... | 0.853055 | 0.792432 | 0.060622 |
Please write the following solution using java:
There is an `m x n` grid with a ball. The ball is initially at the position `[startRow, startColumn]`. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply **at most** `maxMove`... | dolphin | [
0.0181682500988245,
0.011781863868236542,
-0.029567444697022438,
-0.032342858612537384,
0.045853644609451294,
-0.027326710522174835,
-0.04273992404341698,
0.04791625589132309,
0.050799932330846786,
-0.026077108457684517,
0.022225573658943176,
0.031047234311699867,
-0.04226391017436981,
-0.... | 0.832761 | 0.774074 | 0.058686 |
Please write the following solution using Haskell:
A **swap** is defined as taking two **distinct** positions in an array and swapping the values in them.
A **circular** array is defined as an array where we consider the **first** element and the **last** element to be **adjacent**.
Given a **binary** **circular** ar... | dolphin | [
-0.004550545942038298,
0.03553305193781853,
-0.018018098548054695,
-0.024999123066663742,
0.046917855739593506,
-0.01959717459976673,
-0.035875238478183746,
0.029294369742274284,
0.028973443433642387,
-0.005565308034420013,
0.01268680114299059,
0.006020542234182358,
-0.017320072278380394,
... | 0.84323 | 0.789423 | 0.053807 |
Please explain the reasoning behind the following solution and provide code in Mojo:
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.015186142176389694,
0.014886933378875256,
-0.019902870059013367,
-0.03746383637189865,
0.04332299530506134,
-0.03324074298143387,
-0.04660947248339653,
0.04256583750247955,
0.03241853788495064,
-0.0014322977513074875,
0.02456590346992016,
0.03228868544101715,
-0.05107954144477844,
-0.008... | 0.840946 | 0.785675 | 0.055272 |
Please write the following solution using Mojo:
Given two integers `left` and `right` that represent the range `[left, right]`, return _the bitwise AND of all numbers in this range, inclusive_.
**Example 1:**
**Input:** left = 5, right = 7
**Output:** 4
**Example 2:**
**Input:** left = 0, right = 0
**Output:** 0
*... | dolphin | [
0.03003803640604019,
0.02719826065003872,
-0.022687245160341263,
-0.03884092718362808,
0.0266901645809412,
-0.01599002815783024,
-0.026729712262749672,
0.060033757239580154,
0.04054000601172447,
-0.02387494221329689,
0.029766205698251724,
0.04737396910786629,
-0.031214425340294838,
-0.0425... | 0.834429 | 0.775419 | 0.05901 |
Please write the following solution using Object Pascal:
You are given a non-negative integer array `nums`. In one operation, you must:
* Choose a positive integer `x` such that `x` is less than or equal to the **smallest non-zero** element in `nums`.
* Subtract `x` from every **positive** element in `nums`.
Retu... | dolphin | [
0.01599111780524254,
0.023743225261569023,
-0.021696215495467186,
-0.021173741668462753,
0.045198243111371994,
-0.029041018337011337,
-0.018296048045158386,
0.05478157848119736,
0.06539981812238693,
-0.013224580325186253,
0.015309554524719715,
0.015451032668352127,
-0.019533663988113403,
-... | 0.844768 | 0.789093 | 0.055676 |
Please write the following solution using Julia:
You are given an array `target` that consists of **distinct** integers and another integer array `arr` that **can** have duplicates.
In one operation, you can insert any integer at any position in `arr`. For example, if `arr = [1,4,1,2]`, you can add `3` in the middle a... | dolphin | [
0.027908144518733025,
0.024539673700928688,
-0.027078544721007347,
-0.024853557348251343,
0.04662342742085457,
0.007829408161342144,
-0.03673238679766655,
0.06712564080953598,
0.04612516984343529,
-0.019366566091775894,
0.010625290684401989,
0.01051456667482853,
-0.02528400532901287,
-0.03... | 0.850921 | 0.795168 | 0.055753 |
Please explain the reasoning behind the following solution and provide code in PHP:
Given an array of integers `nums` and an integer `k`. A continuous subarray is called **nice** if there are `k` odd numbers on it.
Return _the number of **nice** sub-arrays_.
**Example 1:**
**Input:** nums = \[1,1,2,1,1\], k = 3
**Ou... | dolphin | [
0.008427152410149574,
0.039991363883018494,
-0.035007353872060776,
-0.01489281840622425,
0.044631607830524445,
-0.01564639061689377,
-0.03189085051417351,
0.054836440831422806,
0.04112960770726204,
0.0008337710169143975,
0.0328078530728817,
0.007990874350070953,
-0.0404062420129776,
-0.008... | 0.837985 | 0.780783 | 0.057201 |
Please explain the following problem in detail and provide code in PHP:
Consider a matrix `M` with dimensions `width * height`, such that every cell has value `0` or `1`, and any **square** sub-matrix of `M` of size `sideLength * sideLength` has at most `maxOnes` ones.
Return the maximum possible number of ones that t... | dolphin | [
0.023312365636229515,
0.03514120355248451,
-0.01904505304992199,
-0.023267168551683426,
0.04727265238761902,
-0.019114457070827484,
-0.0456235408782959,
0.07049241662025452,
0.03687182441353798,
-0.008362384513020515,
0.017697684466838837,
0.033117469400167465,
-0.03275681659579277,
-0.029... | 0.841013 | 0.781562 | 0.059451 |
Please focus on the efficiency of this problem and provide code in c++:
You are given an array of integers `nums` and an integer `target`.
Return _the number of **non-empty** subsequences of_ `nums` _such that the sum of the minimum and maximum element on it is less or equal to_ `target`. Since the answer may be too l... | dolphin | [
0.01801260933279991,
0.004978753626346588,
-0.03176402673125267,
-0.024635685607790947,
0.04789591208100319,
0.006766405887901783,
-0.04347414895892143,
0.08039568364620209,
0.02825477160513401,
-0.00906448159366846,
0.02505382150411606,
0.04181884229183197,
-0.04174884036183357,
-0.021986... | 0.85222 | 0.784059 | 0.068161 |
Please focus on the functionality of this problem and provide code in c++:
Given an `m x n` binary matrix `mat`, _return the number of **submatrices** that have all ones_.
**Example 1:**
**Input:** mat = \[\[1,0,1\],\[1,1,0\],\[1,1,0\]\]
**Output:** 13
**Explanation:**
There are 6 rectangles of side 1x1.
There are 2... | dolphin | [
0.014708555303514004,
0.017466817051172256,
-0.027382556349039078,
-0.03330982103943825,
0.03867552801966667,
-0.01571207121014595,
-0.02413044683635235,
0.09420831501483917,
0.033600807189941406,
-0.004004574380815029,
0.013054373674094677,
0.036082591861486435,
-0.02258775196969509,
-0.0... | 0.838365 | 0.783595 | 0.05477 |
Please write the following solution using javascript:
You are given a **0-indexed** integer array `nums`. In one operation, select **any** non-negative integer `x` and an index `i`, then **update** `nums[i]` to be equal to `nums[i] AND (nums[i] XOR x)`.
Note that `AND` is the bitwise AND operation and `XOR` is the bit... | dolphin | [
0.036520346999168396,
0.0292988121509552,
-0.025241350755095482,
-0.006921285297721624,
0.02166069857776165,
-0.029764952138066292,
-0.020451702177524567,
0.05018719285726547,
0.04231804981827736,
-0.020974351093173027,
0.0252666138112545,
0.025882234796881676,
-0.036378052085638046,
-0.01... | 0.837225 | 0.783813 | 0.053413 |
Please write the following solution using PHP:
You are given an integer array `nums`. You want to maximize the number of points you get by performing the following operation any number of times:
* Pick any `nums[i]` and delete it to earn `nums[i]` points. Afterwards, you must delete **every** element equal to `nums[... | dolphin | [
0.016183044761419296,
0.022682633250951767,
-0.022269902750849724,
-0.018630648031830788,
0.02690937928855419,
-0.034822143614292145,
-0.03266802430152893,
0.05565829947590828,
0.05210862308740616,
-0.006073533091694117,
0.01278688758611679,
0.021030912175774574,
-0.03534034267067909,
-0.0... | 0.848416 | 0.787867 | 0.060549 |
Please focus on the efficiency of this problem and provide code in c++:
Given the `root` of a binary tree, find the maximum value `v` for which there exist **different** nodes `a` and `b` where `v = |a.val - b.val|` and `a` is an ancestor of `b`.
A node `a` is an ancestor of `b` if either: any child of `a` is equal to... | dolphin | [
0.04189329966902733,
0.026609234511852264,
-0.031062861904501915,
-0.010864725336432457,
0.02565094642341137,
-0.02497558481991291,
-0.021683592349290848,
0.10363367199897766,
0.04673296585679054,
-0.025576379150152206,
0.04325767606496811,
0.02901434525847435,
-0.025881635025143623,
-0.00... | 0.836137 | 0.780589 | 0.055548 |
Please focus on the functionality of this problem and provide code in Clojure:
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\... | dolphin | [
0.012285028584301472,
0.03577113151550293,
-0.0360584482550621,
-0.02717612497508526,
0.04089157283306122,
-0.003124946029856801,
-0.014916160143911839,
0.028601201251149178,
0.026464492082595825,
-0.0022397306747734547,
0.0278227087110281,
0.029600193724036217,
-0.03297087550163269,
-0.01... | 0.836954 | 0.779664 | 0.05729 |
Please explain the reasoning behind the following solution and provide code in PHP:
You are given two integer arrays `nums1` and `nums2`. We write the integers of `nums1` and `nums2` (in the order they are given) on two separate horizontal lines.
We may draw connecting lines: a straight line connecting two numbers `nu... | dolphin | [
0.011683394201099873,
0.026905188336968422,
-0.027992548421025276,
-0.023613693192601204,
0.04119306430220604,
-0.017400017008185387,
-0.04279458522796631,
0.0652654618024826,
0.05572330206632614,
-0.01953570730984211,
0.02193242497742176,
0.023424426093697548,
-0.00029793987050652504,
-0.... | 0.852048 | 0.795286 | 0.056761 |
Please explain the following problem in detail and provide code in C#:
You are given two **0-indexed** integer arrays `nums1` and `nums2`, each of size `n`, and an integer `diff`. Find the number of **pairs** `(i, j)` such that:
* `0 <= i < j <= n - 1` **and**
* `nums1[i] - nums1[j] <= nums2[i] - nums2[j] + diff`.... | dolphin | [
0.0072510940954089165,
0.0146416537463665,
-0.030975567176938057,
-0.029079362750053406,
0.045886747539043427,
-0.013017968274652958,
-0.03350770100951195,
0.08500194549560547,
0.041738033294677734,
-0.010010925121605396,
0.011894458904862404,
0.02504795975983143,
-0.050130970776081085,
-0... | 0.8502 | 0.787935 | 0.062264 |
Please write the following solution using Julia:
You are given a **0-indexed** integer array `nums` representing the contents of a **pile**, where `nums[0]` is the topmost element of the pile.
In one move, you can perform **either** of the following:
* If the pile is not empty, **remove** the topmost element of the... | dolphin | [
0.027007805183529854,
0.03174685314297676,
-0.010640950873494148,
-0.026524698361754417,
0.04141472280025482,
-0.022838197648525238,
-0.03148017078638077,
0.06146465986967087,
0.04293128475546837,
0.0018020689021795988,
0.038222577422857285,
0.02693711221218109,
-0.034481704235076904,
-0.0... | 0.85251 | 0.790342 | 0.062169 |
Please explain the following problem in detail and provide code in python:
Given an integer `n`, count _the total number of digit_ `1` _appearing in all non-negative integers less than or equal to_ `n`.
**Example 1:**
**Input:** n = 13
**Output:** 6
**Example 2:**
**Input:** n = 0
**Output:** 0
**Constraints:**
*... | dolphin | [
0.00936579704284668,
0.021900415420532227,
-0.03056952729821205,
-0.036616817116737366,
0.03376682475209236,
-0.023960933089256287,
-0.028810545802116394,
0.037375595420598984,
0.014640741981565952,
0.01493392325937748,
0.02853544056415558,
0.030007874593138695,
-0.037517249584198,
-0.0089... | 0.834258 | 0.777749 | 0.056509 |
Please explain the following problem in detail and provide code in c++:
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]`.
Retur... | dolphin | [
0.015525726601481438,
0.026349809020757675,
-0.0026935036294162273,
-0.02920631319284439,
0.02011772058904171,
-0.003148946911096573,
-0.03952727094292641,
0.08666358143091202,
0.029571708291769028,
-0.007904883474111557,
0.014398952014744282,
0.024743538349866867,
-0.03749237582087517,
-0... | 0.84024 | 0.773461 | 0.066779 |
Please write the following solution using Lua:
Given a binary array `nums` and an integer `goal`, return _the number of non-empty **subarrays** with a sum_ `goal`.
A **subarray** is a contiguous part of the array.
**Example 1:**
**Input:** nums = \[1,0,1,0,1\], goal = 2
**Output:** 4
**Explanation:** The 4 subarrays... | dolphin | [
0.0010785963386297226,
0.034410979598760605,
-0.02590363286435604,
-0.03111470304429531,
0.05219988524913788,
-0.010516401380300522,
-0.042575884610414505,
0.030459487810730934,
0.026064913719892502,
-0.010586605407297611,
0.0348280593752861,
0.028263943269848824,
-0.038809020072221756,
-0... | 0.839844 | 0.781167 | 0.058678 |
Please explain the reasoning behind the following solution and provide code in c++:
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.028893403708934784,
0.03374158963561058,
-0.024795936420559883,
-0.027808377519249916,
0.05254903808236122,
-0.012394364923238754,
-0.017574185505509377,
0.08676058799028397,
0.030766870826482773,
-0.011001856066286564,
0.0212404802441597,
0.03009251318871975,
-0.026003003120422363,
-0.0... | 0.842035 | 0.771725 | 0.07031 |
Please explain the following problem in detail and provide code in Dart:
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 = ... | dolphin | [
0.011754770763218403,
0.04001210257411003,
-0.03202330321073532,
-0.02353700064122677,
0.051979392766952515,
-0.0161886028945446,
-0.031211640685796738,
0.06790964305400848,
0.024791665375232697,
-0.005414952058345079,
0.016213828697800636,
0.022073552012443542,
-0.01682814583182335,
-0.01... | 0.845686 | 0.787463 | 0.058223 |
Please focus on the efficiency of this problem and provide code in Clojure:
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 2... | dolphin | [
0.03093048371374607,
0.03684581071138382,
-0.028199922293424606,
-0.017067840322852135,
0.015461714006960392,
-0.030467145144939423,
-0.030168479308485985,
0.040934622287750244,
0.041015490889549255,
-0.00953112542629242,
0.02522367611527443,
0.027508221566677094,
-0.030469628050923347,
-0... | 0.843846 | 0.786727 | 0.057119 |
Please write the following solution using Haskell:
Given an integer array `nums`, return `true` _if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or_ `false` _otherwise_.
**Example 1:**
**Input:** nums = \[1,5,11,5\]
**Output:** true
**Explanation:** The array... | dolphin | [
0.019383752718567848,
0.009002802893519402,
-0.020440831780433655,
-0.03133333846926689,
0.038205165416002274,
-0.014305206947028637,
0.009432986378669739,
0.0700736939907074,
0.03524992987513542,
-0.01885346882045269,
0.015129180625081062,
0.027171403169631958,
-0.023488104343414307,
-0.0... | 0.835012 | 0.777531 | 0.057481 |
Please write the following solution using Objective-C:
Given a list of non-negative integers `nums`, arrange them such that they form the largest number and return it.
Since the result may be very large, so you need to return a string instead of an integer.
**Example 1:**
**Input:** nums = \[10,2\]
**Output:** "210... | dolphin | [
0.034990403801202774,
0.03750711679458618,
-0.01987295038998127,
-0.037389934062957764,
0.02693762816488743,
-0.026731569319963455,
-0.028678040951490402,
0.03335591405630112,
0.024557923898100853,
-0.021430175751447678,
0.04316985234618187,
0.04016252979636192,
-0.04716482385993004,
-0.01... | 0.828277 | 0.770575 | 0.057702 |
Please focus on the efficiency of this problem and provide code in Julia:
You are given `nums`, an array of positive integers of size `2 * n`. You must perform `n` operations on this array.
In the `ith` operation **(1-indexed)**, you will:
* Choose two elements, `x` and `y`.
* Receive a score of `i * gcd(x, y)`.
... | dolphin | [
0.007451889105141163,
0.03895002231001854,
-0.035717692226171494,
-0.03156878799200058,
0.023777171969413757,
-0.028652014210820198,
-0.0364738404750824,
0.060163822025060654,
0.04447709396481514,
-0.0026692207902669907,
0.012583252042531967,
0.01593397557735443,
-0.017964765429496765,
-0.... | 0.849904 | 0.7952 | 0.054703 |
Please write the following solution using Julia:
Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[4,6,7,7\]
**Output:** \[\[4,6\],\[4,6,7\],\[4,6,... | dolphin | [
0.013767711818218231,
0.013170426711440086,
-0.011183980852365494,
-0.014243493787944317,
0.03689578175544739,
-0.011103639379143715,
-0.032644592225551605,
0.056656233966350555,
0.046944510191679,
-0.010901302099227905,
0.034187063574790955,
0.022810928523540497,
-0.046760495752096176,
-0... | 0.833005 | 0.767742 | 0.065263 |
Please write the following solution using Kotlin:
You are given `nums`, an array of positive integers of size `2 * n`. You must perform `n` operations on this array.
In the `ith` operation **(1-indexed)**, you will:
* Choose two elements, `x` and `y`.
* Receive a score of `i * gcd(x, y)`.
* Remove `x` and `y` f... | dolphin | [
0.018518563359975815,
0.031143398955464363,
-0.02145537920296192,
-0.033955901861190796,
0.03326035663485527,
-0.02773909829556942,
-0.03002556599676609,
0.05688488110899925,
0.03762444853782654,
-0.007257760502398014,
0.010195557959377766,
0.019496604800224304,
-0.01960819400846958,
-0.00... | 0.851935 | 0.788508 | 0.063428 |
Please write the following solution using Scheme:
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 = \[3,... | dolphin | [
0.037842247635126114,
0.04156561940908432,
-0.04280250146985054,
-0.0314062274992466,
0.039189040660858154,
-0.05032668635249138,
-0.00957532599568367,
0.03489060699939728,
0.04593454301357269,
-0.014187345281243324,
0.04966622591018677,
0.010983590967953205,
-0.026592113077640533,
0.00430... | 0.824959 | 0.76807 | 0.056889 |
Please write the following solution using c++:
Given a **0-indexed** integer array `nums` of size `n` and two integers `lower` and `upper`, return _the number of fair pairs_.
A pair `(i, j)` is **fair** if:
* `0 <= i < j < n`, and
* `lower <= nums[i] + nums[j] <= upper`
**Example 1:**
**Input:** nums = \[0,1,7,... | dolphin | [
0.007185569033026695,
0.022120244801044464,
-0.03127536177635193,
-0.019174816086888313,
0.04276198521256447,
0.02121615782380104,
-0.02568303421139717,
0.0964089184999466,
0.03559441119432449,
-0.02263905107975006,
0.021295608952641487,
0.03778701648116112,
-0.03243325278162956,
-0.035134... | 0.845439 | 0.773298 | 0.07214 |
Please write the following solution using Scheme:
Given a **0-indexed** integer array `nums`, find the **leftmost** `middleIndex` (i.e., the smallest amongst all the possible ones).
A `middleIndex` is an index where `nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + num... | dolphin | [
0.026119079440832138,
0.03216377645730972,
-0.024029957130551338,
-0.0379239059984684,
0.0368322879076004,
-0.010023019276559353,
-0.028490018099546432,
0.05086420476436615,
0.03085622750222683,
-0.01737290620803833,
0.02385363169014454,
0.011520574800670147,
-0.029327567666769028,
-0.0252... | 0.840341 | 0.78671 | 0.053631 |
Please write the following solution using Scheme:
You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height.
You are given a collection of `rods` that can be welded together. For example, if you have r... | dolphin | [
0.038703855127096176,
0.029733585193753242,
-0.03207612782716751,
-0.015591057017445564,
0.03834759071469307,
-0.044709350913763046,
-0.03402292728424072,
0.050444263964891434,
0.0329522043466568,
-0.008312759920954704,
0.017002733424305916,
0.04056263342499733,
-0.0356266163289547,
0.0088... | 0.838586 | 0.784937 | 0.05365 |
Please write the following solution using ANSI C:
You are given a **0-indexed** 2D integer array `questions` where `questions[i] = [pointsi, brainpoweri]`.
The array describes the questions of an exam, where you have to process the questions **in order** (i.e., starting from question `0`) and make a decision whether t... | dolphin | [
0.014978762716054916,
0.019974878057837486,
-0.016872121021151543,
-0.04259031265974045,
0.015496229752898216,
-0.02835416980087757,
-0.015995027497410774,
0.05678071081638336,
0.026464976370334625,
-0.013159960508346558,
0.018858106806874275,
0.03154807910323143,
-0.04020705074071884,
-0.... | 0.840377 | 0.786521 | 0.053857 |
Please focus on the functionality of this problem and provide code in ANSI C:
You are given an integer array `target`. You have an integer array `initial` of the same size as `target` with all elements initially zeros.
In one operation you can choose **any** subarray from `initial` and increment each value by one.
Re... | dolphin | [
0.02378280833363533,
0.04800417274236679,
-0.015378393232822418,
-0.029326435178518295,
0.030060330405831337,
-0.023519529029726982,
-0.04001731052994728,
0.07931920140981674,
0.032243456691503525,
-0.02857634425163269,
0.03224649280309677,
0.011160733178257942,
-0.04334210604429245,
-0.02... | 0.859271 | 0.797844 | 0.061426 |
Please explain the reasoning behind the following solution and provide code in c++:
You are given a string `s` and two integers `x` and `y`. You can perform two types of operations any number of times.
* Remove substring `"ab "` and gain `x` points.
* For example, when removing `"ab "` from `"cabxbae "` it bec... | dolphin | [
0.021421730518341064,
0.009481794200837612,
-0.03012251853942871,
-0.028853632509708405,
0.041411951184272766,
-0.04267380014061928,
-0.01980796828866005,
0.08223140984773636,
0.05920258164405823,
-0.013856182806193829,
0.00944249052554369,
0.037571027874946594,
-0.04319615662097931,
-0.01... | 0.839354 | 0.784347 | 0.055007 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.