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 focus on the efficiency of this problem and provide code in ANSI C:
You are given a string `num`, representing a large integer, and an integer `k`.
We call some integer **wonderful** if it is a **permutation** of the digits in `num` and is **greater in value** than `num`. There can be many wonderful integers. H... | dolphin | [
0.019189337268471718,
0.04291299358010292,
-0.014884190633893013,
-0.04206836596131325,
0.02421754226088524,
-0.0296309981495142,
-0.03594323620200157,
0.06591919809579849,
0.034274280071258545,
-0.01542845368385315,
0.029631981626152992,
0.02122899703681469,
-0.031202193349599838,
-0.0026... | 0.847849 | 0.78825 | 0.059598 |
Please focus on the algorithm of this problem and provide code in R:
There are `n` people standing in a queue, and they numbered from `0` to `n - 1` in **left to right** order. You are given an array `heights` of **distinct** integers where `heights[i]` represents the height of the `ith` person.
A person can **see** a... | dolphin | [
0.01762302964925766,
0.02642112597823143,
-0.017510654404759407,
-0.029166975989937782,
0.020376697182655334,
-0.008431240916252136,
-0.02772773616015911,
0.06835269927978516,
0.03614308312535286,
-0.0034055181313306093,
0.018661171197891235,
0.024018874391913414,
-0.021407881751656532,
-0... | 0.842745 | 0.788555 | 0.05419 |
Please explain the following problem in detail and provide code in Swift:
You are given the `head` of a linked list containing unique integer values and an integer array `nums` that is a subset of the linked list values.
Return _the number of connected components in_ `nums` _where two values are connected if they appe... | dolphin | [
0.02483000047504902,
0.028243692591786385,
-0.020707692950963974,
-0.014271277002990246,
0.045813582837581635,
-0.016352003440260887,
-0.02122553624212742,
0.05264529585838318,
0.03614899143576622,
0.008895532228052616,
0.025355597957968712,
0.014454621821641922,
-0.011821447871625423,
-0.... | 0.83607 | 0.77657 | 0.0595 |
Please explain the reasoning behind the following solution and provide code in ANSI 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.
**... | dolphin | [
0.01282141450792551,
0.046208202838897705,
-0.02298371121287346,
-0.03600145876407623,
0.03941226750612259,
-0.025883423164486885,
-0.03846094012260437,
0.06989501416683197,
0.027423501014709473,
-0.021576255559921265,
0.02569456398487091,
0.048924338072538376,
-0.02911454625427723,
-0.029... | 0.830526 | 0.773065 | 0.057461 |
Please write the following solution using java:
Alice and Bob play a game with piles of stones. There are an **even** 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. The **total** number of stones across ... | dolphin | [
0.02844817377626896,
0.01926046423614025,
-0.040457647293806076,
-0.02491133101284504,
0.010387715883553028,
-0.05219843238592148,
-0.011141598224639893,
0.05429310351610184,
0.03329889476299286,
-0.02128748409450054,
0.025030912831425667,
0.019438643008470535,
-0.02068360708653927,
-0.009... | 0.835725 | 0.781565 | 0.054161 |
Please write the following solution using C#:
You are given two **non-increasing 0-indexed** integer arrays `nums1` and `nums2`.
A pair of indices `(i, j)`, where `0 <= i < nums1.length` and `0 <= j < nums2.length`, is **valid** if both `i <= j` and `nums1[i] <= nums2[j]`. The **distance** of the pair is `... | dolphin | [
0.018583184108138084,
0.027711451053619385,
-0.02577393129467964,
-0.02580452151596546,
0.03766779601573944,
-0.020980384200811386,
-0.03578885272145271,
0.08349598199129105,
0.04301536828279495,
-0.024179330095648766,
0.021755967289209366,
0.016135841608047485,
-0.035616714507341385,
-0.0... | 0.844413 | 0.780899 | 0.063514 |
Please write the following solution using Visual Basic .NET:
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` a... | dolphin | [
0.013552701100707054,
0.024527905508875847,
-0.027546463534235954,
-0.03087986633181572,
0.043037522584199905,
-0.02136852592229843,
-0.01721886172890663,
0.07552315294742584,
0.039899054914712906,
-0.034481678158044815,
0.015432242304086685,
0.019177615642547607,
-0.030489392578601837,
-0... | 0.852249 | 0.798263 | 0.053985 |
Please write the following solution using c++:
Given an integer `n`, return _an array_ `ans` _of length_ `n + 1` _such that for each_ `i` (`0 <= i <= n`)_,_ `ans[i]` _is the **number of**_ `1`_**'s** in the binary representation of_ `i`.
**Example 1:**
**Input:** n = 2
**Output:** \[0,1,1\]
**Explanation:**
0 --> 0
1... | dolphin | [
0.020411496981978416,
0.027094392105937004,
-0.009716821834445,
-0.026845937594771385,
0.03297046944499016,
-0.03031965158879757,
-0.036515917629003525,
0.08829192072153091,
0.021792016923427582,
-0.01622934266924858,
0.02966124378144741,
0.030091146007180214,
-0.018994538113474846,
-0.017... | 0.837902 | 0.775115 | 0.062788 |
Please explain the reasoning behind the following solution and provide code in Objective-C:
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:** nu... | dolphin | [
0.014048058539628983,
0.03348785638809204,
-0.03627333417534828,
-0.025319842621684074,
0.0495670847594738,
-0.00730666471645236,
-0.024204783141613007,
0.05470115691423416,
0.01969531923532486,
-0.006031149998307228,
0.028248190879821777,
0.021137816831469536,
-0.04519093781709671,
-0.002... | 0.834086 | 0.775192 | 0.058894 |
Please focus on the efficiency of this problem and provide code in Scheme:
Given an integer number `n`, return the difference between the product of its digits and the sum of its digits.
**Example 1:**
**Input:** n = 234
**Output:** 15
**Explanation:**
Product of digits = 2 \* 3 \* 4 = 24
Sum of digits = 2 + 3 + 4... | dolphin | [
0.03391963243484497,
0.029972027987241745,
-0.03165045380592346,
-0.04275164008140564,
0.04758740961551666,
-0.028191186487674713,
-0.048229288309812546,
0.05777539685368538,
0.0407773032784462,
0.004432341083884239,
0.015562983229756355,
0.04160762205719948,
-0.05540646240115166,
-0.02221... | 0.836423 | 0.78133 | 0.055092 |
Please write the following solution using ANSI C:
Given an integer array `nums`, find a subarray that has the largest product, and return _the product_.
The test cases are generated so that the answer will fit in a **32-bit** integer.
**Example 1:**
**Input:** nums = \[2,3,-2,4\]
**Output:** 6
**Explanation:** \[2,3... | dolphin | [
0.04201201722025871,
0.04433857649564743,
-0.028981110081076622,
-0.014464170671999454,
0.04106093943119049,
-0.013754062354564667,
-0.041878461837768555,
0.0769779160618782,
0.03714950010180473,
-0.023107798770070076,
0.02978069894015789,
0.041692718863487244,
-0.04322237893939018,
-0.042... | 0.83699 | 0.772213 | 0.064777 |
Please focus on the algorithm of this problem and provide code in python:
You are given an integer array `nums`.
Splitting of an integer array `nums` into **subarrays** is **valid** if:
* the _greatest common divisor_ of the first and last elements of each subarray is **greater** than `1`, and
* each element of `... | dolphin | [
0.022086765617132187,
0.03268422186374664,
-0.03507540374994278,
-0.014229165390133858,
0.03417151793837547,
-0.02205861546099186,
-0.034197524189949036,
0.06382498890161514,
0.01274782419204712,
-0.01889326050877571,
0.02505127526819706,
0.01528850942850113,
-0.013860601000487804,
-0.0058... | 0.840062 | 0.785033 | 0.05503 |
Please focus on the algorithm of this problem and provide code in ANSI C:
A magical string `s` consists of only `'1'` and `'2'` and obeys the following rules:
* The string s is magical because concatenating the number of contiguous occurrences of characters `'1'` and `'2'` generates the string `s` itself.
The first... | dolphin | [
0.025832751765847206,
0.03636198490858078,
-0.013043095357716084,
-0.04108947515487671,
0.025479568168520927,
-0.03169605880975723,
-0.035377245396375656,
0.09049514681100845,
0.01467486284673214,
-0.0138528011739254,
0.028405051678419113,
0.023157058283686638,
-0.033547624945640564,
-0.02... | 0.841906 | 0.777965 | 0.063941 |
Please explain the reasoning behind the following solution and provide code in Visual Basic .NET:
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 number... | dolphin | [
0.02700524404644966,
0.03703781217336655,
-0.030986327677965164,
-0.023628635331988335,
0.05043978616595268,
-0.027149494737386703,
-0.005837548058480024,
0.07338854670524597,
0.036930423229932785,
-0.011369040235877037,
0.023601092398166656,
0.025452563539147377,
-0.03497042879462242,
-0.... | 0.843081 | 0.779765 | 0.063315 |
Please focus on the efficiency of this problem and provide code in Scheme:
Given a binary array `nums`, you should delete one element from it.
Return _the size of the longest non-empty subarray containing only_ `1`_'s in the resulting array_. Return `0` if there is no such subarray.
**Example 1:**
**Input:** nums = ... | dolphin | [
0.021041003987193108,
0.03689619526267052,
-0.03443417325615883,
-0.03145698085427284,
0.035415168851614,
-0.032676100730895996,
-0.046358607709407806,
0.054042767733335495,
0.04089935123920441,
-0.013704640790820122,
0.0246358010917902,
0.013707691803574562,
-0.02609030343592167,
-0.01357... | 0.845452 | 0.784211 | 0.06124 |
Please write the following solution using Go:
Given a binary array `nums`, return _the maximum number of consecutive_ `1`_'s in the array if you can flip at most one_ `0`.
**Example 1:**
**Input:** nums = \[1,0,1,1,0\]
**Output:** 4
**Explanation:**
- If we flip the first zero, nums becomes \[1,1,1,1,0\] and we have... | dolphin | [
-0.0032800270710140467,
0.03837879002094269,
0.001000024494715035,
-0.029387259855866432,
0.03501848131418228,
-0.019466280937194824,
-0.04539936035871506,
0.050634097307920456,
0.040453992784023285,
-0.02424478344619274,
0.014915146864950657,
0.015481602400541306,
-0.029662804678082466,
-... | 0.836072 | 0.777343 | 0.058729 |
Please explain the following problem in detail and provide code in F#:
You may recall that an array `arr` is a **mountain array** if and only if:
* `arr.length >= 3`
* There exists some index `i` (**0-indexed**) with `0 < i < arr.length - 1` such that:
* `arr[0] < arr[1] < ... < arr[i - 1] < arr[i]`
* ... | dolphin | [
0.019323328509926796,
0.030512448400259018,
-0.027131862938404083,
-0.05113731324672699,
0.03125254809856415,
-0.03261187672615051,
-0.03311442956328392,
0.0675986260175705,
0.03749808669090271,
-0.02121354267001152,
0.022641552612185478,
0.010812925174832344,
-0.03570946305990219,
-0.0175... | 0.844537 | 0.78686 | 0.057677 |
Please focus on the functionality of this problem and provide code in python:
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 w... | dolphin | [
0.009736455045640469,
0.03982925042510033,
-0.022369520738720894,
-0.012574095278978348,
0.034247882664203644,
-0.023682694882154465,
-0.029553905129432678,
0.04886708781123161,
0.01244034431874752,
-0.00937622133642435,
0.02450435422360897,
0.003529180772602558,
-0.029077818617224693,
0.0... | 0.843749 | 0.789664 | 0.054086 |
Please explain the reasoning behind the following solution and provide code in Scheme:
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\]
**Outpu... | dolphin | [
0.020748235285282135,
0.011206774041056633,
-0.024906404316425323,
-0.02578611671924591,
0.038262203335762024,
-0.01876210607588291,
-0.0010943975066766143,
0.07464607059955597,
0.030157603323459625,
-0.019110852852463722,
0.02250947430729866,
0.02254643104970455,
-0.030831124633550644,
-0... | 0.834399 | 0.777187 | 0.057211 |
Please focus on the functionality of this problem and provide code in Julia:
Given an array of integers `nums`, return _the number of **good pairs**_.
A pair `(i, j)` is called _good_ if `nums[i] == nums[j]` and `i` < `j`.
**Example 1:**
**Input:** nums = \[1,2,3,1,1,3\]
**Output:** 4
**Explanation:** There are 4 go... | dolphin | [
0.006483577657490969,
0.010697620920836926,
-0.047855526208877563,
-0.023052161559462547,
0.03431842103600502,
-0.016032682731747627,
-0.03674124553799629,
0.04839601367712021,
0.032785266637802124,
-0.013926845043897629,
0.010142194107174873,
0.023858407512307167,
-0.021587561815977097,
-... | 0.846376 | 0.787958 | 0.058418 |
Please write the following solution using Go:
You are given an integer array of unique positive integers `nums`. Consider the following graph:
* There are `nums.length` nodes, labeled `nums[0]` to `nums[nums.length - 1]`,
* There is an undirected edge between `nums[i]` and `nums[j]` if `nums[i]` and `nums[j]` shar... | dolphin | [
0.029415758326649666,
0.04685347154736519,
-0.025209780782461166,
-0.03644459694623947,
0.031043028458952904,
-0.012046088464558125,
-0.03137741610407829,
0.05291668698191643,
0.03583300858736038,
-0.00565108610317111,
0.025350777432322502,
0.03232957422733307,
-0.02980520762503147,
-0.025... | 0.848923 | 0.784184 | 0.064739 |
Please explain the following problem in detail and provide code in Swift:
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.012061250396072865,
0.029207106679677963,
-0.035383179783821106,
-0.020227422937750816,
0.0474381297826767,
-0.029210997745394707,
-0.032321747392416,
0.058201566338539124,
0.03031151555478573,
-0.005565826781094074,
0.026110924780368805,
0.016619142144918442,
-0.018628759309649467,
0.00... | 0.84193 | 0.783659 | 0.058271 |
Please explain the following problem in detail and provide code in Clojure:
Given an integer array `nums`, return _all the different possible non-decreasing subsequences of the given array with at least two elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[4,6,7,7\]
**Output:**... | dolphin | [
0.008965013548731804,
0.027341265231370926,
-0.008587079122662544,
-0.02747470699250698,
0.035863351076841354,
-0.021415654569864273,
-0.023304149508476257,
0.04426150768995285,
0.04144490510225296,
-0.010797107592225075,
0.038077570497989655,
0.026882771402597427,
-0.04117908701300621,
-0... | 0.835522 | 0.781209 | 0.054313 |
Please explain the reasoning behind the following solution and provide code in c++:
Given an array of integers `arr`, return `true` _if the number of occurrences of each value in the array is **unique** or_ `false` _otherwise_.
**Example 1:**
**Input:** arr = \[1,2,2,1,1,3\]
**Output:** true
**Explanation:** The valu... | dolphin | [
0.006150270812213421,
0.00964791513979435,
-0.026417618617415428,
-0.020060013979673386,
0.051098596304655075,
-0.018278030678629875,
-0.015357454307377338,
0.10586101561784744,
0.038397468626499176,
-0.02341526374220848,
0.016727952286601067,
0.004806166980415583,
-0.00905149057507515,
-0... | 0.83042 | 0.773699 | 0.056721 |
Please explain the reasoning behind the following solution and provide code in python:
You are given an array `nums` of positive integers and a **positive** integer `k`.
A subset of `nums` is **beautiful** if it does not contain two integers with an absolute difference equal to `k`.
Return _the number of **non-empty ... | dolphin | [
0.013584371656179428,
0.044287435710430145,
-0.035416554659605026,
-0.02650488168001175,
0.04741532355546951,
-0.02810601145029068,
-0.035642609000205994,
0.0416049063205719,
0.03705901280045509,
-0.00274452893063426,
0.025899579748511314,
0.026985062286257744,
-0.03317674621939659,
0.0108... | 0.843621 | 0.786676 | 0.056945 |
Please focus on the efficiency of this problem and provide code in ANSI C:
Given two positive integers `num1` and `num2`, find the positive integer `x` such that:
* `x` has the same number of set bits as `num2`, and
* The value `x XOR num1` is **minimal**.
Note that `XOR` is the bitwise XOR operation.
Return _th... | dolphin | [
0.017562774941325188,
0.02135821059346199,
-0.03273330256342888,
-0.017215220257639885,
0.028576809912919998,
-0.021768707782030106,
-0.030834108591079712,
0.08892521262168884,
0.05216452479362488,
-0.029573095962405205,
0.031948115676641464,
0.0049694194458425045,
-0.03069186583161354,
-0... | 0.836851 | 0.781237 | 0.055614 |
Please write the following solution using java:
Given a `m x n` matrix `mat` and an integer `threshold`, return _the maximum side-length of a square with a sum less than or equal to_ `threshold` _or return_ `0` _if there is no such square_.
**Example 1:**
**Input:** mat = \[\[1,1,3,2,4,3,2\],\[1,1,3,2,4,3,2\],\[1,1,3... | dolphin | [
0.01044625137001276,
0.006019044201821089,
-0.03049723245203495,
-0.051159925758838654,
0.051518432796001434,
-0.01391889899969101,
-0.048319168388843536,
0.05029267445206642,
0.029544977471232414,
-0.0086764395236969,
0.01734836958348751,
0.04111001640558243,
-0.030898524448275566,
-0.019... | 0.831451 | 0.770984 | 0.060467 |
Please explain the following problem in detail and provide code in c++:
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:** nu... | dolphin | [
0.009264180436730385,
0.019594047218561172,
-0.020512372255325317,
-0.044735778123140335,
0.040589336305856705,
-0.008767282590270042,
-0.02621358260512352,
0.09204377979040146,
0.04214031994342804,
-0.0025255815126001835,
0.0336843803524971,
0.03697674348950386,
-0.040544118732213974,
-0.... | 0.836722 | 0.772953 | 0.063769 |
Please focus on the algorithm of this problem and provide code in Haskell:
You are given an integer array `nums` of size `n`.
Consider a **non-empty** subarray from `nums` that has the **maximum** possible **bitwise AND**.
* In other words, let `k` be the maximum value of the bitwise AND of **any** subarray of `num... | dolphin | [
0.01216884609311819,
0.009327486157417297,
-0.01781480386853218,
-0.018149979412555695,
0.03296950086951256,
-0.032882653176784515,
-0.026613961905241013,
0.046674855053424835,
0.03531397134065628,
-0.018099842593073845,
0.031189704313874245,
0.04885417968034744,
-0.028055673465132713,
-0.... | 0.839173 | 0.78434 | 0.054833 |
Please focus on the algorithm of this problem and provide code in java:
You are given an integer `n`. A **0-indexed** integer array `nums` of length `n + 1` is generated in the following way:
* `nums[0] = 0`
* `nums[1] = 1`
* `nums[2 * i] = nums[i]` when `2 <= 2 * i <= n`
* `nums[2 * i + 1] = nums[i] + nums[i ... | dolphin | [
0.03387167677283287,
0.028338119387626648,
-0.02757933735847473,
-0.02164311893284321,
0.033800072968006134,
-0.03978246822953224,
-0.03660693019628525,
0.051344867795705795,
0.006255646701902151,
-0.023774882778525352,
0.03329785540699959,
0.04143289849162102,
-0.037443749606609344,
-0.01... | 0.846263 | 0.77572 | 0.070543 |
Please explain the following problem in detail and provide code in Scheme:
You are given a numeric string `num`, representing a very large **palindrome**.
Return _the **smallest palindrome larger than**_ `num` _that can be created by rearranging its digits. If no such palindrome exists, return an empty string_ `" "`.
... | dolphin | [
0.03876003623008728,
0.030296238139271736,
-0.000890736177098006,
-0.05584480240941048,
0.017311381176114082,
-0.005180142354220152,
-0.003265128470957279,
0.06073848530650139,
0.03034985437989235,
-0.0022108403500169516,
0.027591262012720108,
0.0390109047293663,
-0.04586060345172882,
-0.0... | 0.831812 | 0.777214 | 0.054598 |
Please explain the following problem in detail and provide code in Scheme:
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:**... | dolphin | [
0.013331505469977856,
0.0311396736651659,
-0.02342269755899906,
-0.03268925100564957,
0.055425435304641724,
-0.025676744058728218,
-0.03396875783801079,
0.056515883654356,
0.028727401047945023,
-0.004329725168645382,
0.006577541120350361,
0.018620217218995094,
-0.03960566967725754,
-0.0195... | 0.852544 | 0.796745 | 0.0558 |
Please explain the following problem in detail and provide code in Fortran:
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`... | dolphin | [
0.0271912831813097,
0.025044487789273262,
-0.012337105348706245,
-0.03675733879208565,
0.04796723276376724,
-0.015453623607754707,
-0.02034275233745575,
0.06398338079452515,
0.034949541091918945,
-0.006058863364160061,
0.022504668682813644,
0.008470769040286541,
-0.03722753748297691,
-0.02... | 0.838868 | 0.783134 | 0.055734 |
Please focus on the efficiency of this problem and provide code in Swift:
An integer `x` is a **good** if after rotating each digit individually by 180 degrees, we get a valid number that is different from `x`. Each digit must be rotated - we cannot choose to leave it alone.
A number is valid if each digit remains a d... | dolphin | [
0.012312186881899834,
0.015623803250491619,
-0.025437457486987114,
-0.019214633852243423,
0.010212975554168224,
-0.02715594694018364,
-0.04317497834563255,
0.042734935879707336,
0.0205389391630888,
-0.014633982442319393,
0.005621086806058884,
0.024606404826045036,
-0.036608897149562836,
-0... | 0.843395 | 0.788522 | 0.054873 |
Please explain the following problem in detail and provide code in PHP:
You are given an integer array `nums`. The unique elements of an array are the elements that appear **exactly once** in the array.
Return _the **sum** of all the unique elements of_ `nums`.
**Example 1:**
**Input:** nums = \[1,2,3,2\]
**Output:*... | dolphin | [
-0.0014683108311146498,
0.036712899804115295,
-0.02053585834801197,
-0.02186276577413082,
0.05622656270861626,
-0.015572327189147472,
-0.01732008159160614,
0.051321376115083694,
0.040506646037101746,
0.005878346972167492,
0.018491780385375023,
0.007985543459653854,
-0.037877779453992844,
-... | 0.819145 | 0.75445 | 0.064695 |
Please write the following solution using Kotlin:
Given the `root` of a binary tree, the level of its root is `1`, the level of its children is `2`, and so on.
Return the **smallest** level `x` such that the sum of all the values of nodes at level `x` is **maximal**.
**Example 1:**
**Input:** root = \[1,7,0,7,-8,nul... | dolphin | [
0.023937642574310303,
0.029368439689278603,
-0.024596888571977615,
-0.04281133785843849,
0.032362326979637146,
-0.03781500086188316,
0.0006724191480316222,
0.04996410757303238,
0.027675341814756393,
-0.023367546498775482,
0.032033320516347885,
0.02920200116932392,
-0.0327521376311779,
0.00... | 0.837936 | 0.782491 | 0.055445 |
Please explain the following problem in detail and provide code in Objective-C:
You are given a string `num` consisting of digits only.
Return _the **largest palindromic** integer (in the form of a string) that can be formed using digits taken from_ `num`. It should not contain **leading zeroes**.
**Notes:**
* You... | dolphin | [
0.016619103029370308,
0.025622112676501274,
-0.009151282720267773,
-0.043606776744127274,
0.02412949688732624,
-0.03472234308719635,
-0.011440756730735302,
0.04785013943910599,
0.022260615602135658,
-0.015682028606534004,
0.04739447310566902,
0.0351116843521595,
-0.04873253032565117,
-0.01... | 0.823412 | 0.768157 | 0.055255 |
Please write the following solution using Groovy:
Given a sorted integer array `nums` and an integer `n`, add/patch elements to the array such that any number in the range `[1, n]` inclusive can be formed by the sum of some elements in the array.
Return _the minimum number of patches required_.
**Example 1:**
**Inpu... | dolphin | [
0.00980045273900032,
0.02567317523062229,
-0.02082046866416931,
-0.022822238504886627,
0.045865945518016815,
-0.028497403487563133,
-0.016419626772403717,
0.04749760776758194,
0.03148641064763069,
-0.004223196767270565,
0.003987712319940329,
0.03900095075368881,
-0.03637785091996193,
-0.00... | 0.851686 | 0.797183 | 0.054503 |
Please write the following solution using ANSI C:
Given an integer number `n`, return the difference between the product of its digits and the sum of its digits.
**Example 1:**
**Input:** n = 234
**Output:** 15
**Explanation:**
Product of digits = 2 \* 3 \* 4 = 24
Sum of digits = 2 + 3 + 4 = 9
Result = 24 - 9 = 1... | dolphin | [
0.026227161288261414,
0.02746318094432354,
-0.02052299492061138,
-0.04468558356165886,
0.047140736132860184,
-0.023279789835214615,
-0.04964270442724228,
0.07558588683605194,
0.037849631160497665,
0.0023263334296643734,
0.0169385839253664,
0.038518406450748444,
-0.07209926843643188,
-0.041... | 0.823266 | 0.759497 | 0.063769 |
Please write the following solution using Mojo:
Given an integer array `nums` that **does not contain** any zeros, find **the largest positive** integer `k` such that `-k` also exists in the array.
Return _the positive integer_ `k`. If there is no such integer, return `-1`.
**Example 1:**
**Input:** nums = \[-1,2,-3... | dolphin | [
0.031171685084700584,
0.03422379866242409,
-0.02550557255744934,
-0.03412076085805893,
0.042758867144584656,
-0.023787090554833412,
-0.027370773255825043,
0.041061632335186005,
0.029583480209112167,
-0.02472861297428608,
0.027624066919088364,
0.035298217087984085,
-0.037773795425891876,
-0... | 0.838023 | 0.78093 | 0.057092 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You are given an integer array `nums` and two integers `limit` and `goal`. The array `nums` has an interesting property that `abs(nums[i]) <= limit`.
Return _the minimum number of elements you need to add to make the sum of the array equal to_ ... | dolphin | [
0.010391481220722198,
0.02696348913013935,
-0.01823738031089306,
-0.028229212388396263,
0.035401418805122375,
-0.023722942918539047,
-0.038545142859220505,
0.060155291110277176,
0.0435456782579422,
-0.020918430760502815,
0.01141929067671299,
0.026546793058514595,
-0.04863991215825081,
-0.0... | 0.845767 | 0.78696 | 0.058807 |
Please focus on the algorithm of this problem and provide code in C#:
You have `n` `tiles`, where each tile has one letter `tiles[i]` printed on it.
Return _the number of possible non-empty sequences of letters_ you can make using the letters printed on those `tiles`.
**Example 1:**
**Input:** tiles = "AAB "
**Outp... | dolphin | [
0.021517982706427574,
0.017494995146989822,
0.0033453726209700108,
-0.008342763409018517,
0.028125574812293053,
-0.03596058487892151,
-0.018683459609746933,
0.09164004772901535,
0.023610079661011696,
-0.011678362265229225,
0.037705130875110626,
0.03533357381820679,
-0.043284427374601364,
-... | 0.835751 | 0.780383 | 0.055368 |
Please focus on the algorithm of this problem and provide code in Scheme:
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 len... | dolphin | [
0.006097177974879742,
0.014412601478397846,
-0.012448074296116829,
-0.01859760656952858,
0.024212129414081573,
-0.02801297977566719,
-0.015188576653599739,
0.059060730040073395,
0.03607664629817009,
-0.007311441004276276,
0.011269551701843739,
0.03009185381233692,
-0.022988075390458107,
-0... | 0.848059 | 0.784666 | 0.063393 |
Please explain the following problem in detail and provide code in Fortran:
Given an array of integers `nums`, return _the number of **good pairs**_.
A pair `(i, j)` is called _good_ if `nums[i] == nums[j]` and `i` < `j`.
**Example 1:**
**Input:** nums = \[1,2,3,1,1,3\]
**Output:** 4
**Explanation:** There are 4 goo... | dolphin | [
0.018592605367302895,
0.011231260374188423,
-0.03582146763801575,
-0.029379570856690407,
0.03929746150970459,
-0.016694117337465286,
-0.028903398662805557,
0.047666605561971664,
0.030555710196495056,
-0.010889951139688492,
0.011566948145627975,
0.03078281506896019,
-0.02608712576329708,
-0... | 0.84227 | 0.785526 | 0.056744 |
Please explain the following problem in detail and provide code in PHP:
You are given an **even** integer `n`. You initially have a permutation `perm` of size `n` where `perm[i] == i` **(0-indexed)**.
In one operation, you will create a new array `arr`, and for each `i`:
* If `i % 2 == 0`, then `arr[i]... | dolphin | [
0.014512388035655022,
0.0350787416100502,
-0.018679790198802948,
-0.02477082796394825,
0.022130396217107773,
-0.027358222752809525,
-0.033489301800727844,
0.0805489644408226,
0.029227275401353836,
-0.013232932426035404,
0.02328614331781864,
0.009351231157779694,
-0.022954141721129417,
-0.0... | 0.851936 | 0.796815 | 0.055121 |
Please write the following solution using Kotlin:
Given the array `nums` consisting of `2n` elements in the form `[x1,x2,...,xn,y1,y2,...,yn]`.
_Return the array in the form_ `[x1,y1,x2,y2,...,xn,yn]`.
**Example 1:**
**Input:** nums = \[2,5,1,3,4,7\], n = 3
**Output:** \[2,3,5,4,1,7\]
**Explanation:** Since x1\=2, ... | dolphin | [
0.011595185846090317,
0.03100001998245716,
-0.028431696817278862,
-0.03464661166071892,
0.038329336792230606,
-0.03242393583059311,
-0.03598187491297722,
0.04841942340135574,
0.04506537318229675,
-0.005789860617369413,
0.022813409566879272,
0.03739504516124725,
-0.03484011068940163,
-0.005... | 0.830238 | 0.773038 | 0.0572 |
Please explain the following problem in detail and provide code in ANSI C:
You are given a **0-indexed** positive integer array `nums` and a positive integer `k`.
A pair of numbers `(num1, num2)` is called **excellent** if the following conditions are satisfied:
* **Both** the numbers `num1` and `num2` exist in the... | dolphin | [
0.013706692494452,
0.02636614628136158,
-0.03069731593132019,
-0.027246633544564247,
0.029633548110723495,
-0.028454385697841644,
-0.04990861564874649,
0.07575295120477676,
0.03918871283531189,
-0.020687220618128777,
0.0248427614569664,
0.02367212064564228,
-0.039620961993932724,
-0.019417... | 0.847947 | 0.784882 | 0.063065 |
Please explain the following problem in detail and provide code in python:
Given an integer array `arr`, count how many elements `x` there are, such that `x + 1` is also in `arr`. If there are duplicates in `arr`, count them separately.
**Example 1:**
**Input:** arr = \[1,2,3\]
**Output:** 2
**Explanation:** 1 and 2 ... | dolphin | [
0.015486069023609161,
0.02342618629336357,
-0.04472269490361214,
-0.024118516594171524,
0.035348281264305115,
-0.028623275458812714,
-0.02510819397866726,
0.060531217604875565,
0.023692909628152847,
-0.013202349655330181,
0.012894293293356895,
-0.007854039780795574,
-0.033141572028398514,
... | 0.82772 | 0.768141 | 0.059579 |
Please explain the reasoning behind the following solution and provide code in c++:
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 ... | dolphin | [
0.034320391714572906,
0.02264845371246338,
-0.016209032386541367,
-0.009626715444028378,
0.023717297241091728,
-0.027541041374206543,
-0.029472097754478455,
0.08571653068065643,
0.042793210595846176,
-0.020601237192749977,
0.024013949558138847,
0.038231007754802704,
-0.03326575085520744,
-... | 0.837134 | 0.781117 | 0.056016 |
Please explain the following problem in detail and provide code in javascript:
There is a tree (i.e. a connected, undirected graph with no cycles) consisting of `n` nodes numbered from `0` to `n - 1` and exactly `n - 1` edges.
You are given a **0-indexed** integer array `vals` of length `n` where `vals[i]` denotes the... | dolphin | [
0.02295835129916668,
0.015288570895791054,
-0.030768785625696182,
-0.018191728740930557,
0.026877544820308685,
-0.027841605246067047,
-0.014435439370572567,
0.052989691495895386,
0.027282070368528366,
-0.0055929566733539104,
0.032190870493650436,
0.0007935545290820301,
-0.014509759843349457,... | 0.853573 | 0.797726 | 0.055846 |
Please write the following solution using Clojure:
Given an array `nums` of integers, a _move_ consists of choosing any element and **decreasing it by 1**.
An array `A` is a _zigzag array_ if either:
* Every even-indexed element is greater than adjacent elements, ie. `A[0] > A[1] < A[2] > A[3] < A[4] > ...`
* OR,... | dolphin | [
0.02315974421799183,
0.03255776688456535,
-0.020820319652557373,
-0.028113462030887604,
0.04185887426137924,
-0.01995893195271492,
-0.041853003203868866,
0.032521143555641174,
0.021669510751962662,
-0.006048483308404684,
0.023232096806168556,
0.016166575253009796,
-0.039047371596097946,
-0... | 0.840542 | 0.780048 | 0.060493 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
You are given an integer array `banned` and two integers `n` and `maxSum`. You are choosing some number of integers following the below rules:
* The chosen integers have to be in the range `[1, n]`.
* Each integer can be chosen ... | dolphin | [
0.037728749215602875,
0.028294259682297707,
-0.023352956399321556,
-0.023282337933778763,
0.0352746844291687,
-0.03836672753095627,
-0.04550764709711075,
0.05472841113805771,
0.027256187051534653,
-0.012306070886552334,
0.018836375325918198,
0.03489909693598747,
-0.04995153844356537,
-0.02... | 0.841721 | 0.781414 | 0.060307 |
Please write the following solution using ANSI C:
You are given two **0-indexed** binary arrays `nums1` and `nums2`. Find the **widest** pair of indices `(i, j)` such that `i <= j` and `nums1[i] + nums1[i+1] + ... + nums1[j] == nums2[i] + nums2[i+1] + ... + nums2[j]`.
The **widest** pair of indices is the pair with th... | dolphin | [
0.023172687739133835,
0.03363844007253647,
-0.024389153346419334,
-0.04152664169669151,
0.034806039184331894,
-0.01996949128806591,
-0.04891609400510788,
0.08035144209861755,
0.034736327826976776,
-0.029860706999897957,
0.03155391290783882,
0.011716518551111221,
-0.036545176059007645,
-0.0... | 0.847069 | 0.781118 | 0.065951 |
Please focus on the efficiency of this problem and provide code in java:
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
... | dolphin | [
0.027649033814668655,
0.03174585849046707,
-0.04877879470586777,
-0.016032205894589424,
0.013802548870444298,
-0.03855818510055542,
-0.025813201442360878,
0.05946946144104004,
0.03345899656414986,
-0.02116301655769348,
0.02997964434325695,
0.01926332339644432,
-0.05011618882417679,
-0.0230... | 0.84545 | 0.786403 | 0.059046 |
Please focus on the algorithm of this problem and provide code in ANSI C:
Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return _an array of the values of all nodes that have a distance_ `k` _from the target node._
You can return the answer in **any order**.
**Example 1:**... | dolphin | [
0.02494581788778305,
0.043247174471616745,
-0.02900339476764202,
-0.02489008568227291,
0.02673572301864624,
-0.05012032762169838,
-0.013591035269200802,
0.06617741286754608,
0.03951049596071243,
-0.020600561052560806,
0.05168827250599861,
0.011025200597941875,
-0.03033078834414482,
0.00122... | 0.831018 | 0.77574 | 0.055279 |
Please write the following solution using Scala:
You are given two integer arrays `nums1` and `nums2` of length `n`.
The **XOR sum** of the two integer arrays is `(nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1])` (**0-indexed**).
* For example, the **XOR sum** of `[1,2,3]` a... | dolphin | [
0.016881560906767845,
0.037371277809143066,
-0.02323390357196331,
-0.020626399666070938,
0.03172951564192772,
-0.0003742013650480658,
-0.01760830171406269,
0.04842822626233101,
0.04314236715435982,
-0.005856365896761417,
0.011493665166199207,
0.007165967486798763,
-0.025416135787963867,
-0... | 0.840014 | 0.785635 | 0.054379 |
Please write the following solution using C#:
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 derived from another array b... | dolphin | [
0.021085208281874657,
0.03159184381365776,
-0.026506293565034866,
-0.04281649366021156,
0.0293593592941761,
-0.01689150743186474,
-0.017764538526535034,
0.08107555657625198,
0.03785483539104462,
-0.014969817362725735,
0.024371158331632614,
0.026608586311340332,
-0.04104765132069588,
-0.004... | 0.833333 | 0.769304 | 0.06403 |
Please explain the following problem in detail and provide code in java:
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
**Expl... | dolphin | [
0.0019804276525974274,
0.03282298147678375,
-0.034092601388692856,
-0.018783601000905037,
0.04482562467455864,
-0.017086086794734,
-0.04408228397369385,
0.03357783704996109,
0.023503340780735016,
-0.0032716230489313602,
0.030781215056777,
0.022700604051351547,
-0.03767016530036926,
-0.0221... | 0.840388 | 0.773763 | 0.066625 |
Please explain the following problem in detail and provide code in python:
Given an array `nums` sorted in **non-decreasing** order, return _the maximum between the number of positive integers and the number of negative integers._
* In other words, if the number of positive integers in `nums` is `pos` and the number... | dolphin | [
0.02093208208680153,
0.017283497378230095,
-0.03972556069493294,
-0.01285129226744175,
0.016133226454257965,
-0.016248788684606552,
-0.04698273912072182,
0.030799293890595436,
0.020071985200047493,
-0.0040676831267774105,
0.022575709968805313,
0.039575282484292984,
-0.029784081503748894,
0... | 0.837443 | 0.780683 | 0.05676 |
Please explain the reasoning behind the following solution and provide code in PHP:
The **product difference** between two pairs `(a, b)` and `(c, d)` is defined as `(a * b) - (c * d)`.
* For example, the product difference between `(5, 6)` and `(2, 7)` is `(5 * 6) - (2 * 7) = 16`.
Given an integer array `nums`, ch... | dolphin | [
0.02646658755838871,
0.03452974185347557,
-0.02180413529276848,
-0.012875137850642204,
0.05789829045534134,
-0.015473231673240662,
-0.05182160437107086,
0.06478741019964218,
0.04791765660047531,
-0.007697718683630228,
0.020275073125958443,
0.039413247257471085,
-0.03706711530685425,
-0.017... | 0.847453 | 0.793086 | 0.054367 |
Please explain the following problem in detail and provide code in R:
You are given two **0-indexed** binary arrays `nums1` and `nums2`. Find the **widest** pair of indices `(i, j)` such that `i <= j` and `nums1[i] + nums1[i+1] + ... + nums1[j] == nums2[i] + nums2[i+1] + ... + nums2[j]`.
The **widest** pair of indices... | dolphin | [
0.01790395751595497,
0.031869374215602875,
-0.031582094728946686,
-0.040415696799755096,
0.04062740132212639,
-0.01475320290774107,
-0.04541986435651779,
0.06494726240634918,
0.03365596383810043,
-0.01019969116896391,
0.015149544924497604,
0.018760843202471733,
-0.029207631945610046,
-0.01... | 0.838907 | 0.783358 | 0.05555 |
Please explain the following problem in detail and provide code in Scheme:
You are given an integer array `nums`.
In one move, you can choose one element of `nums` and change it to **any value**.
Return _the minimum difference between the largest and smallest value of `nums` **after performing at most three moves**_.... | dolphin | [
0.024824097752571106,
0.0285943616181612,
-0.02141394279897213,
-0.02998037077486515,
0.04308884218335152,
-0.027120595797896385,
-0.036972202360630035,
0.06100991740822792,
0.03208846598863602,
-0.021571580320596695,
0.0422244556248188,
0.030203651636838913,
-0.041408464312553406,
-0.0054... | 0.852616 | 0.791684 | 0.060932 |
Please explain the reasoning behind the following solution and provide code in c++:
Given two arrays of **unique** digits `nums1` and `nums2`, return _the **smallest** number that contains **at least** one digit from each array_.
**Example 1:**
**Input:** nums1 = \[4,1,3\], nums2 = \[5,7\]
**Output:** 15
**Explanatio... | dolphin | [
-0.002815829124301672,
0.02864658460021019,
-0.018172400072216988,
-0.03864331543445587,
0.05056389793753624,
-0.008726590313017368,
-0.03033379465341568,
0.08365250378847122,
0.03731705620884895,
-0.01872703991830349,
0.022385045886039734,
0.02861860767006874,
-0.01191210187971592,
-0.008... | 0.83214 | 0.776609 | 0.05553 |
Please explain the following problem in detail and provide code in C#:
An integer has _sequential digits_ if and only if each digit in the number is one more than the previous digit.
Return a **sorted** list of all the integers in the range `[low, high]` inclusive that have sequential digits.
**Example 1:**
**Input:... | dolphin | [
0.015107478946447372,
0.02080289088189602,
-0.010662408545613289,
-0.03698387369513512,
0.01645848900079727,
-0.03376593068242073,
-0.02570086158812046,
0.07973874360322952,
0.020033422857522964,
-0.007092822343111038,
0.03526834025979042,
0.036865077912807465,
-0.04534589499235153,
-0.009... | 0.826686 | 0.773182 | 0.053505 |
Please write the following solution using Swift:
Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _where_ `0 <= i < j < n`, _such that_ `nums[i] == nums[j]` _and_ `(i * j)` _is divisible by_ `k`.
**Example 1:**
**Input:** nums = \[3,1,2,2,2,1,3\], ... | dolphin | [
0.018282296136021614,
0.03370397165417671,
-0.03841035068035126,
-0.014325795695185661,
0.06769991666078568,
-0.025863196700811386,
-0.020645424723625183,
0.05780842900276184,
0.030442779883742332,
-0.009650752879679203,
0.030776066705584526,
0.007954994216561317,
-0.0205988809466362,
-0.0... | 0.845198 | 0.783675 | 0.061523 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You are given an integer array `nums` of `2 * n` integers. You need to partition `nums` into **two** arrays of length `n` to **minimize the absolute difference** of the **sums** of the arrays. To partition `nums`, put each element of `nums` into... | dolphin | [
0.02119610831141472,
0.026908425614237785,
-0.02265041321516037,
-0.017967989668250084,
0.017289213836193085,
-0.01113811507821083,
-0.03520897775888443,
0.05990849807858467,
0.047121040523052216,
-0.02294130250811577,
0.022915014997124672,
0.021696848794817924,
-0.04817643016576767,
-0.00... | 0.841477 | 0.785735 | 0.055742 |
Please focus on the functionality of this problem and provide code in Lisp:
Given a **circular integer array** `nums` of length `n`, return _the maximum possible sum of a non-empty **subarray** of_ `nums`.
A **circular array** means the end of the array connects to the beginning of the array. Formally, the next elemen... | dolphin | [
0.008153953589498997,
0.03859793394804001,
-0.02675051987171173,
-0.02932923659682274,
0.032957639545202255,
-0.01686873845756054,
-0.026519427075982094,
0.030947038903832436,
0.034267358481884,
0.00250760605558753,
0.04951581731438637,
0.04134893789887428,
-0.03280176967382431,
-0.0066523... | 0.843702 | 0.789503 | 0.054199 |
Please write the following solution using ANSI C:
Write an efficient algorithm that searches for a value `target` in an `m x n` integer matrix `matrix`. This matrix has the following properties:
* Integers in each row are sorted in ascending from left to right.
* Integers in each column are sorted in ascending fro... | dolphin | [
0.01788758486509323,
0.017228074371814728,
-0.025899019092321396,
-0.04245896264910698,
0.051159944385290146,
-0.02925562858581543,
-0.03816349804401398,
0.06546823680400848,
0.026652760803699493,
-0.017755640670657158,
0.015568692237138748,
0.016585079953074455,
-0.04197944700717926,
-0.0... | 0.837082 | 0.775706 | 0.061376 |
Please explain the following problem in detail and provide code in PHP:
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 directly below or ... | dolphin | [
-0.004660760518163443,
0.020280323922634125,
-0.027297092601656914,
-0.03105875290930271,
0.059688057750463486,
-0.026548683643341064,
-0.01708696037530899,
0.06658874452114105,
0.045604828745126724,
-0.012553364969789982,
0.02696189098060131,
0.0058440761640667915,
-0.030062159523367882,
... | 0.836937 | 0.7807 | 0.056237 |
Please explain the following problem in detail and provide code in java:
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
**Explana... | dolphin | [
0.022911231964826584,
0.015419180504977703,
-0.01526959054172039,
-0.03434837982058525,
0.03499326482415199,
-0.03249376267194748,
-0.05043861269950867,
0.03959910571575165,
0.04949946701526642,
-0.011103284545242786,
0.03651370108127594,
0.03910525143146515,
-0.04917212575674057,
-0.03735... | 0.831569 | 0.767352 | 0.064217 |
Please focus on the functionality of this problem and provide code in c++:
Given an integer array `nums`, return _the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle_.
**Example 1:**
**Input:** nums = \[2,2,3,4\]
**Output:** 3
**Explanation:** Valid combi... | dolphin | [
0.012415711767971516,
0.021877173334360123,
-0.015621917322278023,
-0.015112216584384441,
0.037012308835983276,
-0.002475638408213854,
-0.030993923544883728,
0.0930107906460762,
0.026849405840039253,
0.006935431621968746,
0.03657837212085724,
0.044260259717702866,
-0.02352232299745083,
-0.... | 0.831886 | 0.773684 | 0.058202 |
Please focus on the algorithm of this problem and provide code in Scala:
Given an integer array `nums` of size `n`, return _the minimum number of moves required to make all array elements equal_.
In one move, you can increment or decrement an element of the array by `1`.
Test cases are designed so that the answer wil... | dolphin | [
0.00970443245023489,
0.009547334164381027,
-0.023658523336052895,
-0.032443881034851074,
0.04426164925098419,
-0.03869805112481117,
-0.00984253454953432,
0.06010860949754715,
0.016126496717333794,
-0.03777347877621651,
0.04093201458454132,
0.01778258942067623,
-0.027116671204566956,
-0.009... | 0.849173 | 0.794843 | 0.05433 |
Please explain the reasoning behind the following solution and provide code in PHP:
There is an undirected connected tree with `n` nodes labeled from `0` to `n - 1` and `n - 1` edges.
You are given the integer `n` and the array `edges` where `edges[i] = [ai, bi]` indicates that there is an edge between nodes `ai` and ... | dolphin | [
0.004819180816411972,
0.03367173671722412,
-0.02176041714847088,
-0.032568611204624176,
0.03833604231476784,
-0.038348983973264694,
-0.018132101744413376,
0.059270717203617096,
0.03742162138223648,
0.012530334293842316,
0.036140862852334976,
0.024770786985754967,
-0.04370677098631859,
0.00... | 0.84038 | 0.787116 | 0.053264 |
Please focus on the algorithm of this problem and provide code in javascript:
You are given an integer array `nums` sorted in **non-decreasing** order.
Build and return _an integer array_ `result` _with the same length as_ `nums` _such that_ `result[i]` _is equal to the **summation of absolute differences** between_ `... | dolphin | [
0.007807106710970402,
0.020108060911297798,
-0.023408330976963043,
-0.020045801997184753,
0.03386721760034561,
-0.02197183668613434,
-0.03406493738293648,
0.061938486993312836,
0.04265500232577324,
-0.014418484643101692,
0.02262580208480358,
0.01728144660592079,
-0.0556996650993824,
0.0007... | 0.841256 | 0.787076 | 0.054181 |
Please focus on the efficiency of this problem and provide code in Fortran:
You are given an array `nums` consisting of positive integers.
Starting with `score = 0`, apply the following algorithm:
* Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest inde... | dolphin | [
0.026586515828967094,
0.0434562973678112,
-0.023828117176890373,
-0.03350384160876274,
0.032836079597473145,
-0.008747379295527935,
-0.023071903735399246,
0.06729348003864288,
0.03245113417506218,
-0.0012261326191946864,
0.020450938493013382,
0.026655586436390877,
-0.01689712516963482,
-0.... | 0.854961 | 0.797976 | 0.056984 |
Please write the following solution using javascript:
Given a **0-indexed** integer array `nums`, find a **0-indexed** integer array `answer` where:
* `answer.length == nums.length`.
* `answer[i] = |leftSum[i] - rightSum[i]|`.
Where:
* `leftSum[i]` is the sum of elements to the left of the index `i` in the arr... | dolphin | [
0.02240690588951111,
0.04083056375384331,
-0.031734537333250046,
-0.033582039177417755,
0.04424811154603958,
-0.013920292258262634,
-0.014695950783789158,
0.052311237901449203,
0.04881232604384422,
-0.011352366767823696,
0.025393741205334663,
0.011866247281432152,
-0.041490472853183746,
-0... | 0.836464 | 0.776822 | 0.059642 |
Please explain the following problem in detail and provide code in Object Pascal:
There are `m` boys and `n` girls in a class attending an upcoming party.
You are given an `m x n` integer matrix `grid`, where `grid[i][j]` equals `0` or `1`. If `grid[i][j] == 1`, then that means the `ith` boy can invite the `jth` girl ... | dolphin | [
-0.005209431517869234,
0.026659172028303146,
-0.01715254783630371,
-0.0431862473487854,
0.040990810841321945,
-0.05149303749203682,
-0.016725067049264908,
0.04021357744932175,
0.044856369495391846,
-0.002933477284386754,
0.026510359719395638,
0.043954599648714066,
-0.021553918719291687,
-0... | 0.845211 | 0.790029 | 0.055182 |
Please write the following solution using Dart:
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:**
**Input:** nums = \[14,... | dolphin | [
0.02459333837032318,
0.020417919382452965,
-0.022389456629753113,
-0.01357209961861372,
0.011754108592867851,
-0.01937512494623661,
-0.03896934166550636,
0.05233251675963402,
0.0399058535695076,
-0.00835746806114912,
0.014705397188663483,
0.029743824154138565,
-0.03792516887187958,
-0.0177... | 0.846634 | 0.782704 | 0.06393 |
Please explain the following problem in detail and provide code in C#:
You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of `n` nodes numbered from `0` to `n - 1` and exactly `n - 1` `edges`. The **root** of the tree is the node `0`, and each node of the tree has **a label** which ... | dolphin | [
0.006079714745283127,
0.025494925677776337,
-0.030905405059456825,
-0.02237219549715519,
0.031224288046360016,
-0.049003954976797104,
-0.005333180073648691,
0.07726670801639557,
0.029677212238311768,
0.0027154465205967426,
0.030078263953328133,
0.011466847732663155,
-0.04052118957042694,
-... | 0.841396 | 0.787286 | 0.05411 |
Please focus on the functionality of this problem and provide code in Mojo:
Given an integer array `nums` of `2n` integers, group these integers into `n` pairs `(a1, b1), (a2, b2), ..., (an, bn)` such that the sum of `min(ai, bi)` for all `i` is **maximized**. Return _the maximized sum_.
**Example 1:**
**Input:** num... | dolphin | [
0.01573365554213524,
0.027787676081061363,
-0.04096514731645584,
-0.02315477281808853,
0.04185217618942261,
-0.009676944464445114,
-0.026946987956762314,
0.03887662664055824,
0.03550723195075989,
-0.004365889355540276,
0.014575337059795856,
0.03078910894691944,
-0.034321051090955734,
-0.01... | 0.84074 | 0.783384 | 0.057356 |
Please focus on the algorithm of this problem and provide code in javascript:
There is a street with `n * 2` **plots**, where there are `n` plots on each side of the street. The plots on each side are numbered from `1` to `n`. On each plot, a house can be placed.
Return _the number of ways houses can be placed such th... | dolphin | [
0.01570921577513218,
0.020529398694634438,
-0.023103933781385422,
-0.010259306989610195,
0.02313672937452793,
-0.022453200072050095,
-0.02494625747203827,
0.05735570937395096,
0.039158813655376434,
-0.017170067876577377,
0.020490195602178574,
0.0520770438015461,
-0.031728651374578476,
-0.0... | 0.845312 | 0.791927 | 0.053386 |
Please write the following solution using Object Pascal:
You are given a string `s`. An **awesome** substring is a non-empty substring of `s` such that we can make any number of swaps in order to make it a palindrome.
Return _the length of the maximum length **awesome substring** of_ `s`.
**Example 1:**
**Input:** s... | dolphin | [
0.03267154097557068,
0.015758447349071503,
-0.007596293929964304,
-0.036974985152482986,
0.02529471553862095,
-0.04192478209733963,
-0.01669621281325817,
0.027823366224765778,
0.035943303257226944,
-0.009419016540050507,
0.03069797344505787,
0.038853149861097336,
-0.037008222192525864,
-0.... | 0.826175 | 0.771053 | 0.055121 |
Please focus on the efficiency of this problem and provide code in Rust:
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 ... | dolphin | [
0.02458619698882103,
0.03574571758508682,
-0.010955778881907463,
-0.023078816011548042,
0.02333177626132965,
-0.023283176124095917,
-0.04227314889431,
0.06237119063735008,
0.045746881514787674,
-0.027663955464959145,
0.038169242441654205,
0.03727347403764725,
-0.029928063973784447,
-0.0234... | 0.844371 | 0.788642 | 0.055729 |
Please write the following solution using Julia:
Given an array of unique integers, `arr`, where each integer `arr[i]` is strictly greater than `1`.
We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values o... | dolphin | [
0.026010241359472275,
0.03509601578116417,
-0.029666932299733162,
-0.01987524703145027,
0.041327737271785736,
-0.045022960752248764,
-0.024337589740753174,
0.06543586403131485,
0.037583477795124054,
-0.02808459848165512,
0.030984900891780853,
0.0105962622910738,
-0.03874232992529869,
-0.02... | 0.842239 | 0.776605 | 0.065634 |
Please explain the reasoning behind the following solution and provide code in Scheme:
Given an array of unique integers, `arr`, where each integer `arr[i]` is strictly greater than `1`.
We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should b... | dolphin | [
0.03326418995857239,
0.03937521576881409,
-0.02401798404753208,
-0.018546385690569878,
0.04404991492629051,
-0.05308455601334572,
-0.024393079802393913,
0.05824608355760574,
0.03760507330298424,
-0.027807800099253654,
0.031655412167310715,
0.008318375796079636,
-0.03988504409790039,
-0.009... | 0.840646 | 0.785332 | 0.055314 |
Please write the following solution using ANSI C:
Given an array of digits `digits`, return _the largest multiple of **three** that can be formed by concatenating some of the given digits in **any order**_. If there is no answer return an empty string.
Since the answer may not fit in an integer data type, return the a... | dolphin | [
0.028820287436246872,
0.037149131298065186,
-0.019480600953102112,
-0.05160360038280487,
0.034496527165174484,
-0.027545351535081863,
-0.03208578750491142,
0.04878117889165878,
0.023882277309894562,
-0.015625640749931335,
0.031103510409593582,
0.037859078496694565,
-0.05201522260904312,
-0... | 0.831866 | 0.777437 | 0.054429 |
Please focus on the efficiency of this problem and provide code in C#:
Given an integer array `nums`, find the **maximum** possible **bitwise OR** of a subset of `nums` and return _the **number of different non-empty subsets** with the maximum bitwise OR_.
An array `a` is a **subset** of an array `b` if `a` can be obt... | dolphin | [
0.0283447727560997,
0.022441092878580093,
-0.03445614129304886,
0.006514971610158682,
0.02250729501247406,
-0.02958877943456173,
-0.03475095331668854,
0.07671263068914413,
0.04680570960044861,
-0.021931739524006844,
0.03491617366671562,
0.020005134865641594,
-0.036232464015483856,
-0.02266... | 0.844871 | 0.778574 | 0.066297 |
Please focus on the functionality of this problem and provide code in Scheme:
Given a string `s` of zeros and ones, _return the maximum score after splitting the string into two **non-empty** substrings_ (i.e. **left** substring and **right** substring).
The score after splitting a string is the number of **zeros** in... | dolphin | [
0.025269435718655586,
0.019012274220585823,
-0.030568860471248627,
-0.030512036755681038,
0.03709796816110611,
-0.034165237098932266,
-0.03152383863925934,
0.04296553507447243,
0.019156349822878838,
0.0005467315786518157,
0.020130455493927002,
0.03557636961340904,
-0.028197791427373886,
-0... | 0.838411 | 0.783606 | 0.054805 |
Please write the following solution using python:
You are given a string `num` consisting of digits only.
Return _the **largest palindromic** integer (in the form of a string) that can be formed using digits taken from_ `num`. It should not contain **leading zeroes**.
**Notes:**
* You do **not** need to use all th... | dolphin | [
0.02021072804927826,
0.022265709936618805,
-0.01173180341720581,
-0.04215677082538605,
0.020302634686231613,
-0.03063390403985977,
-0.009562079794704914,
0.030895328149199486,
0.020112931728363037,
-0.011852520518004894,
0.04205526039004326,
0.03861280530691147,
-0.04513787478208542,
-0.01... | 0.82132 | 0.764302 | 0.057018 |
Please write the following solution using R:
The **bitwise AND** of an array `nums` is the bitwise AND of all integers in `nums`.
* For example, for `nums = [1, 5, 3]`, the bitwise AND is equal to `1 & 5 & 3 = 1`.
* Also, for `nums = [7]`, the bitwise AND is `7`.
You are given an array of positive integers `candi... | dolphin | [
0.015864139422774315,
0.03659750893712044,
-0.024034040048718452,
-0.018576761707663536,
0.0378025583922863,
-0.010219160467386246,
-0.03529275208711624,
0.048698969185352325,
0.028736939653754234,
-0.0028462186455726624,
0.025321735069155693,
0.04418373107910156,
-0.035927169024944305,
-0... | 0.836023 | 0.772361 | 0.063662 |
Please write the following solution using Go:
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 and ... | dolphin | [
0.02701256424188614,
0.024010375142097473,
-0.01586843468248844,
-0.027306394651532173,
0.045063260942697525,
0.0015035090036690235,
-0.040075987577438354,
0.06733077764511108,
0.05061735957860947,
-0.019876688718795776,
0.00949513167142868,
0.007550740148872137,
-0.0296990554779768,
-0.04... | 0.848288 | 0.794951 | 0.053337 |
Please explain the reasoning behind the following solution and provide code in R:
Given a positive integer `n`, return the number of the integers in the range `[0, n]` whose binary representations **do not** contain consecutive ones.
**Example 1:**
**Input:** n = 5
**Output:** 5
**Explanation:**
Here are the non-nega... | dolphin | [
0.0033698028419166803,
0.017379339784383774,
-0.026442397385835648,
-0.039553478360176086,
0.04147851839661598,
-0.014394438825547695,
-0.047892976552248,
0.05941304564476013,
0.039805203676223755,
-0.011173643171787262,
0.017626192420721054,
0.02919292077422142,
-0.032746944576501846,
-0.... | 0.831551 | 0.773198 | 0.058353 |
Please write the following solution using Julia:
You are given a 2D integer array `ranges` where `ranges[i] = [starti, endi]` denotes that all integers between `starti` and `endi` (both **inclusive**) are contained in the `ith` range.
You are to split `ranges` into **two** (possibly empty) groups such that:
* Each ... | dolphin | [
0.031937822699546814,
0.013120485469698906,
-0.04322997108101845,
-0.02583152987062931,
0.04278421401977539,
-0.019737066701054573,
-0.04209117591381073,
0.05386022478342056,
0.036600060760974884,
-0.018912537023425102,
0.010673522017896175,
0.02506783977150917,
-0.034501414746046066,
-0.0... | 0.847638 | 0.790395 | 0.057242 |
translate this code from java to c++:
```java
import java.util.*;
public int maxStarSum(int[] vals, int[][] edges, int k) {
List<Integer>[] adj = new ArrayList[vals.length];
for (int i = 0; i < vals.length; i++) {
adj[i] = new ArrayList<Integer>();
}
for (int[] edge : edges) {
adj[edge... | dolphin | [
0.00925218965858221,
0.02158297598361969,
-0.016329871490597725,
-0.03475172072649002,
0.03482915833592415,
-0.005445756018161774,
-0.017120670527219772,
0.08164238929748535,
0.03619372472167015,
-0.017976438626646996,
0.026328779757022858,
0.035447027534246445,
-0.02278529852628708,
-0.00... | 0.822184 | 0.765565 | 0.056619 |
Please explain the following problem in detail and provide code in Groovy:
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] > ... > ... | dolphin | [
0.027850894257426262,
0.03005640208721161,
-0.02829638496041298,
-0.04095574468374252,
0.024346131831407547,
-0.036709100008010864,
-0.04125969111919403,
0.06313822418451309,
0.03130960464477539,
-0.024501709267497063,
0.024538038298487663,
0.01744760572910309,
-0.035739488899707794,
-0.01... | 0.843127 | 0.787187 | 0.05594 |
Please focus on the algorithm of this problem and provide code in C#:
You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.
Return _the single element that appears only once_.
Your solution must run in `O(log n)` time and... | dolphin | [
0.006638058461248875,
0.024101097136735916,
-0.023252686485648155,
-0.01630091480910778,
0.01866738311946392,
-0.03399642929434776,
-0.030553258955478668,
0.09609510749578476,
0.03462984412908554,
-0.009939633309841156,
0.020939193665981293,
0.002865632064640522,
-0.028235258534550667,
-0.... | 0.84355 | 0.790191 | 0.05336 |
Please explain the following problem in detail and provide code in Scheme:
You are standing at position `0` on an infinite number line. There is a destination at position `target`.
You can make some number of moves `numMoves` so that:
* On each move, you can either go left or right.
* During the `ith` move (start... | dolphin | [
0.014486229047179222,
0.024624237790703773,
-0.01617518998682499,
-0.036390069872140884,
0.03996565565466881,
-0.007316233590245247,
-0.04797855764627457,
0.04534699022769928,
0.0351245291531086,
-0.01881353370845318,
0.03850965574383736,
0.024817615747451782,
-0.021473011001944542,
-0.021... | 0.848921 | 0.790344 | 0.058577 |
Please write the following solution using Visual Basic .NET:
Suppose you have `n` integers labeled `1` through `n`. A permutation of those `n` integers `perm` (**1-indexed**) is considered a **beautiful arrangement** if for every `i` (`1 <= i <= n`), **either** of the following is true:
* `perm[i]` is divisible by `... | dolphin | [
0.03781827166676521,
0.04094730690121651,
-0.02832941710948944,
-0.03895027935504913,
0.037487804889678955,
-0.029280349612236023,
-0.025999102741479874,
0.07238999009132385,
0.03466007858514786,
-0.01114427950233221,
0.036776792258024216,
0.01575629785656929,
-0.0308256596326828,
-0.01991... | 0.843028 | 0.782787 | 0.060241 |
Please focus on the algorithm of this problem and provide code in PHP:
You are given an array `nums` consisting of non-negative integers. You are also given a `queries` array, where `queries[i] = [xi, mi]`.
The answer to the `ith` query is the maximum bitwise `XOR` value of `xi` and any element of `nums` that does not... | dolphin | [
0.019294338300824165,
0.024629482999444008,
-0.031129108741879463,
-0.0075710127130150795,
0.026819810271263123,
-0.022834474220871925,
-0.024055715650320053,
0.07384616136550903,
0.03338855877518654,
-0.009884849190711975,
0.03026997298002243,
0.023342957720160484,
-0.046953823417425156,
... | 0.846783 | 0.791962 | 0.054821 |
Please explain the following problem in detail and provide code in java:
There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he **refuses to steal from adjacent homes**.
The **capability** of the robber is the ma... | dolphin | [
0.028517847880721092,
0.048217371106147766,
-0.011933289468288422,
-0.02461785078048706,
0.03904813528060913,
-0.01986921764910221,
-0.018265822902321815,
0.04765085130929947,
0.033434923738241196,
-0.01591356284916401,
0.02114945650100708,
0.04796644672751427,
-0.040026530623435974,
-0.02... | 0.844226 | 0.787955 | 0.056271 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.