instruction_seed
stringlengths
308
3.48k
source
stringclasses
1 value
embeddings
listlengths
1.02k
1.02k
mean_positive_score
float64
0.8
0.86
mean_negative_score
float64
0.74
0.8
difference_score
float64
0.05
0.07
Please write the following solution using ANSI C: Given the `root` of a binary search tree, a `target` value, and an integer `k`, return _the_ `k` _values in the BST that are closest to the_ `target`. You may return the answer in **any order**. You are **guaranteed** to have only one unique set of `k` values in the BS...
dolphin
[ 0.04389355331659317, 0.03993948549032211, -0.02810860238969326, -0.03249530494213104, 0.038448650389909744, -0.04505085572600365, -0.00916977971792221, 0.05777943506836891, 0.04499810189008713, -0.015468602068722248, 0.05059443414211273, 0.023778004571795464, -0.0327158197760582, -0.004328...
0.83789
0.783063
0.054826
Please write the following solution using Fortran: You are given an **even** number of people `numPeople` that stand around a circle and each person shakes hands with someone else so that there are `numPeople / 2` handshakes total. Return _the number of ways these handshakes could occur such that none of the handshake...
dolphin
[ 0.03850557282567024, 0.023423602804541588, -0.02990741655230522, -0.028611933812499046, 0.034784864634275436, -0.01494054589420557, -0.02361280843615532, 0.03228599205613136, 0.025252770632505417, -0.030585497617721558, 0.03074503131210804, 0.04386600852012634, -0.02079470269382, -0.037805...
0.835343
0.781007
0.054336
Please focus on the algorithm of this problem and provide code in c++: You are given an integer array `nums` and an integer `k`. In one operation, you can pick two numbers from the array whose sum equals `k` and remove them from the array. Return _the maximum number of operations you can perform on the array_. **Exa...
dolphin
[ 0.017415575683116913, 0.02492978237569332, -0.018511924892663956, -0.028420427814126015, 0.037036217749118805, -0.007742306683212519, -0.03202114254236221, 0.0997491106390953, 0.050243787467479706, -0.013050513342022896, 0.014106129296123981, 0.03148941323161125, -0.017573021352291107, -0....
0.841483
0.777792
0.063692
Please focus on the efficiency of this problem and provide code in c++: It is a sweltering summer day, and a boy wants to buy some ice cream bars. At the store, there are `n` ice cream bars. You are given an array `costs` of length `n`, where `costs[i]` is the price of the `ith` ice cream bar in coins. The boy initial...
dolphin
[ 0.032280802726745605, 0.029553484171628952, -0.02135959453880787, -0.01724984496831894, 0.0216530729085207, 0.00007412211562041193, -0.04569084569811821, 0.08754625916481018, 0.022115811705589294, -0.022261282429099083, 0.024312645196914673, 0.041278161108493805, -0.03219686076045036, -0.0...
0.843115
0.787056
0.05606
Please write the following solution using java: You are given an integer array `nums` with the following properties: * `nums.length == 2 * n`. * `nums` contains `n + 1` **unique** elements. * Exactly one element of `nums` is repeated `n` times. Return _the element that is repeated_ `n` _times_. **Example 1:** ...
dolphin
[ 0.027719812467694283, 0.025185799226164818, -0.028536077588796616, -0.026640797033905983, 0.03555656969547272, -0.024729356169700623, -0.030577117577195168, 0.06261889636516571, 0.016225386410951614, -0.006069356109946966, 0.02215413749217987, 0.01103300042450428, -0.027525093406438828, -0...
0.840698
0.768818
0.07188
Please write the following solution using Haskell: You are given an array `nums` of size `n` consisting of **distinct** integers from `1` to `n` and a positive integer `k`. Return _the number of non-empty subarrays in_ `nums` _that have a **median** equal to_ `k`. **Note**: * The median of an array is the **middle...
dolphin
[ 0.031225183978676796, 0.02333826571702957, -0.030455930158495903, -0.031063446775078773, 0.04603952169418335, -0.005643297452479601, -0.021075408905744553, 0.04624391719698906, 0.026996567845344543, -0.00829322636127472, 0.028502749279141426, 0.015733031556010246, -0.026369446888566017, -0...
0.833584
0.776441
0.057143
Please focus on the efficiency of this problem and provide code in java: You are given an integer array `rolls` of length `n` and an integer `k`. You roll a `k` sided dice numbered from `1` to `k`, `n` times, where the result of the `ith` roll is `rolls[i]`. Return _the length of the **shortest** sequence of rolls tha...
dolphin
[ 0.022912070155143738, 0.0334065742790699, -0.02365540899336338, -0.031682271510362625, 0.02172182686626911, -0.029681265354156494, -0.0243691299110651, 0.05240604281425476, 0.038485873490571976, -0.016672633588314056, 0.031492218375205994, 0.015817521139979362, -0.022376153618097305, 0.006...
0.845184
0.785316
0.059868
Please explain the following problem in detail and provide code in c++: Given a list of `dominoes`, `dominoes[i] = [a, b]` is **equivalent to** `dominoes[j] = [c, d]` if and only if either (`a == c` and `b == d`), or (`a == d` and `b == c`) - that is, one domino can be rotated to be equal to another domino. Return _th...
dolphin
[ 0.005318686831742525, 0.008102752268314362, -0.029357174411416054, -0.01663862355053425, 0.02926676720380783, 0.0024477122351527214, -0.01955118216574192, 0.0882776528596878, 0.03398677334189415, -0.027813494205474854, 0.01617070846259594, 0.03068227879703045, -0.021001791581511497, -0.017...
0.840374
0.781397
0.058977
Please focus on the efficiency of this problem and provide code in java: Given a `m x n` `grid` filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. **Note:** You can only move either down or right at any point in time. **Example 1:** **I...
dolphin
[ 0.0007047581020742655, 0.016773095354437828, -0.03521455079317093, -0.035157665610313416, 0.031169768422842026, -0.036026518791913986, -0.03538814187049866, 0.03392156958580017, 0.03209281712770462, -0.02271842770278454, 0.020783958956599236, 0.03337274119257927, -0.0275973379611969, -0.02...
0.840587
0.776286
0.064301
Please focus on the efficiency of this problem and provide code in Objective-C: Given an unsorted array of integers `nums`, return _the length of the longest consecutive elements sequence._ You must write an algorithm that runs in `O(n)` time. **Example 1:** **Input:** nums = \[100,4,200,1,3,2\] **Output:** 4 **Expl...
dolphin
[ 0.024620763957500458, 0.017792856320738792, -0.03336236625909805, -0.030115636065602303, 0.02734459936618805, -0.028162101283669472, -0.05110400170087814, 0.07018209248781204, 0.03579165041446686, -0.0244052205234766, 0.028079770505428314, 0.020125284790992737, -0.0354204960167408, -0.0067...
0.840632
0.776444
0.064188
Please focus on the algorithm of this problem and provide code in Mojo: You are given two integers `m` and `n`. Consider an `m x n` grid where each cell is initially white. You can paint each cell **red**, **green**, or **blue**. All cells **must** be painted. Return _the number of ways to color the grid with **no two...
dolphin
[ 0.011747382581233978, 0.021302087232470512, -0.020303821191191673, -0.03673721104860306, 0.019045358523726463, -0.040118198841810226, -0.04036726430058479, 0.06363658607006073, 0.029586639255285263, -0.0318760946393013, 0.035192590206861496, 0.025460820645093918, -0.008421671576797962, -0....
0.842423
0.78807
0.054353
Please write the following solution using c++: A **good meal** is a meal that contains **exactly two different food items** with a sum of deliciousness equal to a power of two. You can pick **any** two different foods to make a good meal. Given an array of integers `deliciousness` where `deliciousness[i]` is the deli...
dolphin
[ 0.02551252394914627, 0.008497636765241623, -0.008371385745704174, -0.042260169982910156, 0.03394888713955879, -0.009134328924119473, -0.0486147403717041, 0.08022581785917282, 0.04028759151697159, -0.03771661967039108, 0.03604460880160332, 0.041233889758586884, -0.029893962666392326, -0.016...
0.834714
0.774291
0.060423
Please write the following solution using Kotlin: You are given an array `nums` consisting of **positive** integers and an integer `k`. **Partition** the array into two ordered **groups** such that each element is in exactly **one** group. A partition is called great if the **sum** of elements of each group is greater...
dolphin
[ 0.030453983694314957, 0.024919381365180016, -0.034905482083559036, -0.029932677745819092, 0.03488275408744812, -0.026474827900528908, -0.017537793144583702, 0.040514569729566574, 0.03147754818201065, -0.012778888456523418, 0.024356549605727196, 0.017358772456645966, -0.028919456526637077, ...
0.846271
0.784968
0.061303
Please explain the reasoning behind the following solution and provide code in java: There is an undirected graph consisting of `n` nodes numbered from `0` to `n - 1`. You are given a **0-indexed** integer array `vals` of length `n` where `vals[i]` denotes the value of the `ith` node. You are also given a 2D integer a...
dolphin
[ 0.00684382114559412, 0.04165470972657204, -0.03264961019158363, -0.025676153600215912, 0.04166780039668083, -0.024983514100313187, -0.020796528086066246, 0.04741417616605759, 0.030068419873714447, -0.011298274621367455, 0.04425560683012009, 0.027292953804135323, -0.010987228713929653, -0.0...
0.839295
0.7781
0.061195
Please focus on the functionality of this problem and provide code in c++: Given an array of integers `nums`, sort the array in **increasing** order based on the frequency of the values. If multiple values have the same frequency, sort them in **decreasing** order. Return the _sorted array_. **Example 1:** **Input:*...
dolphin
[ 0.014948423020541668, 0.02806347794830799, -0.016775423660874367, -0.015545736998319626, 0.035269301384687424, -0.011966670863330364, -0.03746388480067253, 0.10512008517980576, 0.021572522819042206, 0.00042869136086665094, 0.017150690779089928, 0.012067287229001522, -0.05355776101350784, 0...
0.8157
0.762038
0.053662
Please write the following solution using Julia: There is a **hidden** integer array `arr` that consists of `n` non-negative integers. It was encoded into another integer array `encoded` of length `n - 1`, such that `encoded[i] = arr[i] XOR arr[i + 1]`. For example, if `arr = [1,0,2,1]`, then `encoded = [1,2,3]`. You...
dolphin
[ 0.03187699243426323, 0.04366380348801613, -0.02019861713051796, -0.03340543806552887, 0.020497962832450867, -0.03718554601073265, -0.020398108288645744, 0.0724615603685379, 0.04024118557572365, -0.019496843218803406, 0.03018818609416485, -0.0024051291402429342, -0.033163994550704956, -0.02...
0.853764
0.80041
0.053354
Please write the following solution using java: You are given an integer array `nums` of length `n`, and an integer array `queries` of length `m`. Return _an array_ `answer` _of length_ `m` _where_ `answer[i]` _is the **maximum** size of a **subsequence** that you can take from_ `nums` _such that the **sum** of its el...
dolphin
[ 0.01798650622367859, 0.019079728052020073, -0.036492474377155304, -0.027434518560767174, 0.046772561967372894, -0.005144523922353983, -0.02347312867641449, 0.054239675402641296, 0.022479239851236343, -0.013271423056721687, 0.023676255717873573, 0.02343537099659443, -0.03249436616897583, -0...
0.847237
0.779376
0.067861
Please explain the reasoning behind the following solution and provide code in Clojure: There exists an undirected and unrooted tree with `n` nodes indexed from `0` to `n - 1`. You are given an integer `n` and a 2D integer array edges of length `n - 1`, where `edges[i] = [ai, bi]` indicates that there is an edge betwee...
dolphin
[ 0.006821977440267801, 0.035794299095869064, -0.01894356496632099, -0.036548517644405365, 0.01496620662510395, -0.02353481389582157, -0.0062426007352769375, 0.044414911419153214, 0.019441872835159302, -0.006212019361555576, 0.036430295556783676, 0.022309331223368645, -0.010750602930784225, ...
0.848837
0.795253
0.053584
Please focus on the algorithm of this problem and provide code in Scala: You are given two integers `m` and `n`. Consider an `m x n` grid where each cell is initially white. You can paint each cell **red**, **green**, or **blue**. All cells **must** be painted. Return _the number of ways to color the grid with **no tw...
dolphin
[ 0.010164815932512283, 0.019700786098837852, -0.013037133030593395, -0.03006104752421379, 0.024036673828959465, -0.03889503702521324, -0.032712336629629135, 0.059851422905921936, 0.02117987722158432, -0.03416285663843155, 0.031056459993124008, 0.03359123691916466, 0.004164905287325382, -0.0...
0.841428
0.787477
0.053952
Please write the following solution using Dart: We have an array of integers, `nums`, and an array of `requests` where `requests[i] = [starti, endi]`. The `ith` request asks for the sum of `nums[starti] + nums[starti + 1] + ... + nums[endi - 1] + nums[endi]`. Both `starti` and `endi` are _0-indexed_. Return _the maxim...
dolphin
[ 0.012892495840787888, 0.029868371784687042, -0.01705757901072502, -0.03850997984409332, 0.03804066404700279, -0.016687721014022827, -0.043134547770023346, 0.03824654594063759, 0.0301678329706192, -0.01652693934738636, 0.025413723662495613, 0.0256308875977993, -0.04243452847003937, -0.00356...
0.845891
0.790951
0.05494
Please write the following solution using ANSI C: A chef has collected data on the `satisfaction` level of his `n` dishes. Chef can cook any dish in 1 unit of time. **Like-time coefficient** of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. `ti...
dolphin
[ 0.02013695240020752, 0.014816957525908947, -0.024997377768158913, -0.02744928188621998, 0.029577774927020073, -0.008044691756367683, -0.026852838695049286, 0.06933049857616425, 0.01949286460876465, -0.008380142040550709, 0.03861908242106438, 0.04205388203263283, -0.030469199642539024, -0.0...
0.845284
0.786357
0.058926
Please focus on the functionality of this problem and provide code in PHP: Given an integer array `nums` and an integer `k`, return `true` _if there are two **distinct indices**_ `i` _and_ `j` _in the array such that_ `nums[i] == nums[j]` _and_ `abs(i - j) <= k`. **Example 1:** **Input:** nums = \[1,2,3,1\], k = 3 **...
dolphin
[ 0.01763339526951313, 0.032072119414806366, -0.028982767835259438, -0.015379903838038445, 0.04081036150455475, -0.022701065987348557, -0.015819212421774864, 0.07986629009246826, 0.04130302742123604, -0.02083679474890232, 0.020539822056889534, 0.01602628082036972, -0.025767803192138672, -0.0...
0.848497
0.791796
0.056701
Please explain the following problem in detail and provide code in java: 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 a...
dolphin
[ 0.021477174013853073, 0.037195079028606415, -0.04373504966497421, -0.022927820682525635, 0.04348978400230408, -0.007013778667896986, -0.024565571919083595, 0.03580332174897194, 0.03229111433029175, -0.010228889063000679, 0.040005069226026535, 0.02695540338754654, -0.034737393260002136, 0.0...
0.83653
0.768789
0.067742
Please focus on the efficiency of this problem and provide code in Kotlin: 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 combin...
dolphin
[ 0.020553557202219963, 0.03139054402709007, -0.011416729539632797, -0.021761354058980942, 0.04169933497905731, -0.014840664342045784, -0.01945822313427925, 0.03867581859230995, 0.03798879683017731, -0.014453740790486336, 0.01961801014840603, 0.023587679490447044, -0.024057921022176743, -0.0...
0.8436
0.788808
0.054792
Please write the following solution using Kotlin: 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 an array. **Example 1:**...
dolphin
[ -0.005946060176938772, 0.029169119894504547, -0.012485972605645657, -0.03400726616382599, 0.04401182755827904, -0.011476484127342701, -0.019865740090608597, 0.0635644719004631, 0.03968404605984688, -0.015973761677742004, 0.011844517663121223, 0.018886318430304527, -0.05296988785266876, -0....
0.837342
0.7811
0.056241
Please explain the following problem in detail and provide code in PHP: Given an array of `points` where `points[i] = [xi, yi]` represents a point on the **X-Y** plane, return _the maximum number of points that lie on the same straight line_. **Example 1:** **Input:** points = \[\[1,1\],\[2,2\],\[3,3\]\] **Output:** ...
dolphin
[ 0.00003372214632690884, 0.021949414163827896, -0.024233737960457802, -0.04057963937520981, 0.03570549935102463, -0.012319393455982208, -0.03601808473467827, 0.04295080900192261, 0.050905920565128326, -0.0034455519635230303, 0.00007334526162594557, 0.029044365510344505, -0.011560792103409767,...
0.831191
0.772752
0.058439
Please explain the reasoning behind the following solution and provide code in java: Given a positive integer `num`, split it into two non-negative integers `num1` and `num2` such that: * The concatenation of `num1` and `num2` is a permutation of `num`. * In other words, the sum of the number of occurrences of...
dolphin
[ -0.007068267557770014, 0.02439534291625023, -0.023550255224108696, -0.024140678346157074, 0.04596102237701416, -0.018387340009212494, -0.020508069545030594, 0.04464760795235634, 0.026581814512610435, -0.019532974809408188, 0.01809294894337654, 0.029576553031802177, -0.02711474895477295, -0...
0.840486
0.778785
0.061701
Please write the following solution using Lua: You are given an integer array `nums`. A number `x` is **lonely** when it appears only **once**, and no **adjacent** numbers (i.e. `x + 1` and `x - 1)` appear in the array. Return _**all** lonely numbers in_ `nums`. You may return the answer in **any order**. **Example 1...
dolphin
[ 0.018317051231861115, 0.04237896203994751, -0.020107615739107132, -0.03406831622123718, 0.040899548679590225, -0.0223232451826334, -0.011883703991770744, 0.04161816090345383, 0.03430058807134628, -0.017541803419589996, 0.026368040591478348, 0.010595832951366901, -0.03426424041390419, -0.01...
0.839857
0.786571
0.053286
Please focus on the functionality of this problem and provide code in ANSI C: Given an integer array nums, return _the number of **AND triples**_. An **AND triple** is a triple of indices `(i, j, k)` such that: * `0 <= i < nums.length` * `0 <= j < nums.length` * `0 <= k < nums.length` * `nums[i] & nums[j] & n...
dolphin
[ 0.007153721526265144, 0.02096005156636238, -0.02564922720193863, -0.023598577827215195, 0.032774392515420914, -0.022807545959949493, -0.045115768909454346, 0.06859156489372253, 0.0074404277838766575, -0.005111610516905785, 0.032311081886291504, 0.033720336854457855, -0.05214746668934822, -...
0.841106
0.780816
0.06029
Please focus on the algorithm of this problem and provide code in Mojo: A decimal number is called **deci-binary** if each of its digits is either `0` or `1` without any leading zeros. For example, `101` and `1100` are **deci-binary**, while `112` and `3001` are not. Given a string `n` that represents a positive decim...
dolphin
[ -0.016552764922380447, 0.008274033665657043, -0.026062721386551857, -0.03794137388467789, 0.043517276644706726, -0.05259113758802414, -0.02769518457353115, 0.029280761256814003, 0.023106195032596588, -0.005022314377129078, 0.019591661170125008, 0.020132118836045265, -0.03799083083868027, -...
0.828936
0.775695
0.053241
Please explain the following problem in detail and provide code in Object Pascal: Given an integer array `nums` and an integer `k`, you are asked to construct the array `ans` of size `n-k+1` where `ans[i]` is the number of **distinct** numbers in the subarray `nums[i:i+k-1] = [nums[i], nums[i+1], ..., nums[i+k-1]]`. R...
dolphin
[ 0.02100672386586666, 0.04482351243495941, -0.01809305138885975, -0.022075684741139412, 0.04916545748710632, -0.029239360243082047, -0.013625817373394966, 0.058039456605911255, 0.04634164273738861, 0.0147953350096941, 0.03396680951118469, 0.028458984568715096, -0.031449951231479645, 0.00676...
0.838537
0.784287
0.05425
Please write the following solution using Kotlin: Given a string `s`, return the maximum number of ocurrences of **any** substring under the following rules: * The number of unique characters in the substring must be less than or equal to `maxLetters`. * The substring size must be between `minSize` and `maxSize` i...
dolphin
[ 0.005834509618580341, 0.007594713941216469, -0.013659646734595299, -0.02605997398495674, 0.04007367417216301, -0.010381779633462429, -0.02798367477953434, 0.04562012851238251, 0.02597719617187977, -0.0071233175694942474, 0.022501006722450256, 0.034069210290908813, -0.0212746262550354, -0.0...
0.836634
0.782798
0.053835
Please write the following solution using Groovy: You are given an integer array `nums` of length `n` which represents a permutation of all the integers in the range `[0, n - 1]`. The number of **global inversions** is the number of the different pairs `(i, j)` where: * `0 <= i < j < n` * `nums[i] > nums[j]` The...
dolphin
[ 0.009035148657858372, 0.0309140607714653, -0.014670920558273792, -0.019267216324806213, 0.041376788169145584, -0.02668364904820919, -0.010070966556668282, 0.07031180709600449, 0.02924923226237297, -0.016868796199560165, 0.014239019714295864, 0.028274089097976685, -0.02754836343228817, -0.0...
0.846634
0.790623
0.05601
Please write the following solution using java: The **diameter** of a tree is **the number of edges** in the longest path in that tree. There is an undirected tree of `n` nodes labeled from `0` to `n - 1`. You are given a 2D array `edges` where `edges.length == n - 1` and `edges[i] = [ai, bi]` indicates that there is ...
dolphin
[ 0.017688505351543427, 0.019098591059446335, -0.02451552264392376, -0.037741661071777344, 0.032590463757514954, -0.02616371400654316, -0.02207144908607006, 0.0416739284992218, 0.01802120916545391, -0.012911858037114143, 0.05383448302745819, 0.015503439120948315, -0.028669826686382294, -0.00...
0.821294
0.761257
0.060036
Please explain the following problem in detail and provide code in Julia: You are given an integer array `nums`. The **absolute sum** of a subarray `[numsl, numsl+1, ..., numsr-1, numsr]` is `abs(numsl + numsl+1 + ... + numsr-1 + numsr)`. Return _the **maximum** absolute sum of any **(possibly empty)** subarray of_ `n...
dolphin
[ 0.016832487657666206, 0.033668432384729385, -0.029357584193348885, -0.028317928314208984, 0.03289918601512909, -0.016258463263511658, -0.029024934396147728, 0.039504796266555786, 0.05113593116402626, -0.004843170288950205, 0.026535790413618088, 0.026035955175757408, -0.029559524729847908, ...
0.83401
0.774773
0.059237
Please write the following solution using Lua: You are given an integer array `nums`. In one move, you can pick an index `i` where `0 <= i < nums.length` and increment `nums[i]` by `1`. Return _the minimum number of moves to make every value in_ `nums` _**unique**_. The test cases are generated so that the answer fit...
dolphin
[ 0.006214139051735401, 0.03764297068119049, -0.013796055689454079, -0.02875785157084465, 0.043234582990407944, -0.016564084216952324, -0.02916192077100277, 0.05373997986316681, 0.028795914724469185, -0.03172195702791214, 0.04021964967250824, 0.011763472110033035, -0.03161025792360306, -0.02...
0.849672
0.791637
0.058035
Please explain the reasoning behind the following solution and provide code in PHP: Given a binary array `nums`, return _the maximum number of consecutive_ `1`_'s in the array_. **Example 1:** **Input:** nums = \[1,1,0,1,1,1\] **Output:** 3 **Explanation:** The first two digits or the last three digits are consecutiv...
dolphin
[ 0.011199722066521645, 0.04365374147891998, -0.011695957742631435, -0.031353339552879333, 0.04753798991441727, -0.03439294919371605, -0.04482056945562363, 0.06434888392686844, 0.03937850147485733, -0.016380133107304573, 0.029311655089259148, 0.02088139019906521, -0.03501003608107567, -0.003...
0.836726
0.779927
0.056799
Please focus on the efficiency of this problem and provide code in javascript: You are given an integer array `nums`. In one move, you can pick an index `i` where `0 <= i < nums.length` and increment `nums[i]` by `1`. Return _the minimum number of moves to make every value in_ `nums` _**unique**_. The test cases are ...
dolphin
[ 0.01058256532996893, 0.03468339145183563, -0.014819636940956116, -0.013051734305918217, 0.03250301629304886, -0.01707068830728531, -0.025925256311893463, 0.06408775597810745, 0.035342372953891754, -0.028344878926873207, 0.04041561111807823, 0.006983287166804075, -0.03073856607079506, -0.01...
0.85103
0.790976
0.060054
Please write the following solution using Haskell: You are given the array `nums` consisting of `n` positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of `n * (n + 1) / 2` numbers. _Return the sum of the number...
dolphin
[ 0.023183617740869522, 0.03311740979552269, -0.02006310597062111, -0.03155437484383583, 0.038435835391283035, -0.012947415001690388, -0.018551329150795937, 0.03596843034029007, 0.03417319431900978, -0.005505315959453583, 0.022404924035072327, 0.028683984652161598, -0.04488099366426468, -0.0...
0.843971
0.78339
0.06058
Please write the following solution using PHP: 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 the string. A sequence is pali...
dolphin
[ 0.0009329813765361905, 0.005176451988518238, -0.022743461653590202, -0.02287476509809494, 0.03348641097545624, -0.03587924316525459, -0.013553595170378685, 0.06685826927423477, 0.0382828563451767, -0.012833514250814915, 0.03136783465743065, 0.021273640915751457, -0.038820646703243256, -0.0...
0.831919
0.777556
0.054363
Please explain the following problem in detail and provide code in c++: You are given the `root` of a binary tree. A ZigZag path for a binary tree is defined as follow: * Choose **any** node in the binary tree and a direction (right or left). * If the current direction is right, move to the right child of the cur...
dolphin
[ 0.018185684457421303, 0.025778409093618393, -0.01884332299232483, -0.02721398137509823, 0.02304084040224552, -0.023219387978315353, -0.019641531631350517, 0.08027278631925583, 0.038955993950366974, -0.016507979482412338, 0.03973642364144325, 0.022071167826652527, -0.007422765716910362, -0....
0.836703
0.779036
0.057668
Please explain the following problem in detail and provide code in c++: Given a string `s`, return _the number of **palindromic substrings** in it_. A string is a **palindrome** when it reads the same backward as forward. A **substring** is a contiguous sequence of characters within the string. **Example 1:** **Inp...
dolphin
[ 0.006938369013369083, -0.002346574328839779, -0.020521488040685654, -0.028756987303495407, 0.03467380255460739, -0.017441414296627045, -0.009049986489117146, 0.08411301672458649, 0.03756627440452576, 0.007546836510300636, 0.030928634107112885, 0.03895577788352966, -0.03467893600463867, -0....
0.825239
0.767697
0.057542
Please write the following solution using PHP: You are given an `m x n` matrix `M` initialized with all `0`'s and an array of operations `ops`, where `ops[i] = [ai, bi]` means `M[x][y]` should be incremented by one for all `0 <= x < ai` and `0 <= y < bi`. Count and return _the number of maximum integers in the matrix ...
dolphin
[ 0.037286270409822464, 0.02374832145869732, -0.03107674978673458, -0.031410250812768936, 0.04089038446545601, -0.02710363082587719, -0.04962162300944328, 0.06571441888809204, 0.03833792358636856, -0.008627508766949177, 0.010386893525719643, 0.02572203055024147, -0.03913656622171402, -0.0308...
0.848738
0.787059
0.061679
Please focus on the algorithm of this problem and provide code in C#: Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. Yo...
dolphin
[ 0.011258331127464771, 0.02398940548300743, -0.02788615971803665, -0.018834538757801056, 0.03849013149738312, -0.01573667675256729, -0.02933947555720806, 0.07967880368232727, 0.030644554644823074, -0.011865717358887196, 0.02197941020131111, 0.03602607548236847, -0.034955427050590515, -0.017...
0.839432
0.785122
0.05431
Please focus on the functionality of this problem and provide code in C#: You are given two positive integer arrays `nums` and `target`, of the same length. In one operation, you can choose any two **distinct** indices `i` and `j` where `0 <= i, j < nums.length` and: * set `nums[i] = nums[i] + 2` and * set `nums[...
dolphin
[ 0.0183598380535841, 0.026987535879015923, -0.027910355478525162, -0.01458563283085823, 0.0426083467900753, -0.027141110971570015, -0.02220463566482067, 0.0949905663728714, 0.034849636256694794, -0.017970340326428413, 0.011189635843038559, 0.01048418041318655, -0.03306437283754349, -0.02132...
0.854027
0.799127
0.0549
Please write the following solution using javascript: 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 the inclusive ran...
dolphin
[ 0.018108360469341278, 0.02929895743727684, -0.031539011746644974, -0.024948444217443466, 0.025196988135576248, -0.006668904796242714, -0.008095093071460724, 0.04545893892645836, 0.02975892648100853, -0.015005293302237988, 0.03175682574510574, 0.020169982686638832, -0.03151925653219223, -0....
0.841584
0.783522
0.058061
Please write the following solution using Scheme: Given a positive integer `n`, find _the smallest integer which has exactly the same digits existing in the integer_ `n` _and is greater in value than_ `n`. If no such positive integer exists, return `-1`. **Note** that the returned integer should fit in **32-bit intege...
dolphin
[ 0.021531064063310623, 0.026672154664993286, -0.028369955718517303, -0.04022727161645889, 0.040763579308986664, -0.03132316470146179, -0.014886823482811451, 0.05731949582695961, 0.030042922124266624, -0.012475690804421902, 0.03847071900963783, 0.037949059158563614, -0.045747555792331696, -0...
0.834926
0.77601
0.058916
Please write the following solution using Objective-C: Given an integer array `nums` and an integer `k`, return _the length of the shortest non-empty **subarray** of_ `nums` _with a sum of at least_ `k`. If there is no such **subarray**, return `-1`. A **subarray** is a **contiguous** part of an array. **Example 1:**...
dolphin
[ 0.011604802682995796, 0.03428791090846062, -0.03094371221959591, -0.029327230527997017, 0.05068827047944069, -0.010066249407827854, -0.029578955844044685, 0.05012212693691254, 0.0336887426674366, -0.0051863547414541245, 0.03318284451961517, 0.02284763567149639, -0.03133488446474075, -0.007...
0.837201
0.773063
0.064138
Please focus on the functionality of this problem and provide code in Objective-C: Given an array of positive integers `nums` and a positive integer `target`, return _the **minimal length** of a_ _subarray_ _whose sum is greater than or equal to_ `target`. If there is no such subarray, return `0` instead. **Example 1:...
dolphin
[ 0.009188276715576649, 0.026107750833034515, -0.0333687849342823, -0.02270263247191906, 0.045121852308511734, -0.019406357780098915, -0.03705497831106186, 0.05627769976854324, 0.03440956026315689, -0.014156275428831577, 0.023166676983237267, 0.01518069114536047, -0.034984514117240906, -0.01...
0.848904
0.790863
0.058042
Please write the following solution using javascript: Given a **0-indexed** integer array `nums`, return _the number of subarrays of_ `nums` _having an even product_. **Example 1:** **Input:** nums = \[9,6,7,13\] **Output:** 6 **Explanation:** There are 6 subarrays with an even product: - nums\[0..1\] = 9 \* 6 = 54. ...
dolphin
[ 0.02348845824599266, 0.028446577489376068, -0.03723964840173721, -0.012337200343608856, 0.040794096887111664, -0.0007927738479338586, -0.0309000201523304, 0.06308604031801224, 0.030605191364884377, -0.009782887995243073, 0.006388029083609581, 0.02161475457251072, -0.041699811816215515, -0....
0.834464
0.780754
0.05371
Please write the following solution using Object Pascal: An integer has **monotone increasing digits** if and only if each pair of adjacent digits `x` and `y` satisfy `x <= y`. Given an integer `n`, return _the largest number that is less than or equal to_ `n` _with **monotone increasing digits**_. **Example 1:** **...
dolphin
[ 0.03684264421463013, 0.028609303757548332, -0.025858115404844284, -0.03587743639945984, 0.014990419149398804, -0.03174656257033348, -0.02505505084991455, 0.050252024084329605, 0.03251850977540016, 0.0075721582397818565, 0.03371525555849075, 0.04193853214383125, -0.060171715915203094, -0.00...
0.829961
0.76626
0.063702
Please write the following solution using Perl: 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 = \[3,2,3\] **Output:** 3 ...
dolphin
[ 0.013963659293949604, 0.023588130250573158, -0.04060203209519386, -0.023767171427607536, 0.03840402141213417, -0.02244667336344719, -0.017550433054566383, 0.05793406441807747, 0.02854851260781288, -0.0024670034181326628, 0.026651104912161827, 0.030268389731645584, -0.015980886295437813, -0...
0.836434
0.78267
0.053764
Please focus on the efficiency of this problem and provide code in ANSI C: A company is organizing a meeting and has a list of `n` employees, waiting to be invited. They have arranged for a large **circular** table, capable of seating **any number** of employees. The employees are numbered from `0` to `n - 1`. Each em...
dolphin
[ 0.02880011685192585, 0.03790859505534172, -0.024895865470170975, -0.011920919641852379, 0.014543803408741951, -0.027130980044603348, -0.04144010692834854, 0.052534546703100204, 0.0474560521543026, -0.014691684395074844, 0.05107703432440758, 0.026130616664886475, -0.024778524413704872, -0.0...
0.847198
0.793434
0.053765
Please explain the following problem in detail and provide code in ANSI C: Given a positive integer `n`, find _the smallest integer which has exactly the same digits existing in the integer_ `n` _and is greater in value than_ `n`. If no such positive integer exists, return `-1`. **Note** that the returned integer shou...
dolphin
[ 0.01721544750034809, 0.031208856031298637, -0.022843770682811737, -0.04022006317973137, 0.0320979580283165, -0.03154100850224495, -0.019444243982434273, 0.07888879626989365, 0.027290670201182365, -0.008669001050293446, 0.041805513203144073, 0.03548332303762436, -0.05535786971449852, -0.018...
0.836674
0.778432
0.058242
Please focus on the algorithm of this problem and provide code in Objective-C: 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_...
dolphin
[ 0.010365121066570282, 0.027198420837521553, -0.027428561821579933, -0.02965211682021618, 0.03772937133908272, -0.033604174852371216, -0.01621919311583042, 0.06402032822370529, 0.0293078925460577, -0.017464641481637955, 0.0360434465110302, 0.031570300459861755, -0.028110984712839127, -0.014...
0.842697
0.781379
0.061318
Please write the following solution using Objective-C: You are given an integer array `coins` representing coins of different denominations and an integer `amount` representing a total amount of money. Return _the fewest number of coins that you need to make up that amount_. If that amount of money cannot be made up b...
dolphin
[ 0.029010875150561333, 0.03636789321899414, -0.02240559458732605, -0.028245221823453903, 0.0388668067753315, -0.03700513392686844, -0.021065227687358856, 0.07091788202524185, 0.025862032547593117, -0.025108616799116135, 0.03606010600924492, 0.028399541974067688, -0.024135343730449677, -0.02...
0.84383
0.784572
0.059258
Please write the following solution using 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. **Example 2:** **Input:** n = 6 **Output:*...
dolphin
[ 0.011181825771927834, 0.03592728450894356, -0.02157852239906788, -0.033293429762125015, 0.04269985482096672, -0.025399863719940186, -0.02848953939974308, 0.07055968791246414, 0.03298681601881981, -0.018827617168426514, 0.0227495264261961, 0.0415365993976593, -0.02285553142428398, -0.038379...
0.829221
0.77214
0.057081
Please write the following solution using ANSI 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 `O(1)` space. **Ex...
dolphin
[ 0.01923983171582222, 0.03664899989962578, -0.014693474397063255, -0.0264743659645319, 0.023410264402627945, -0.020733898505568504, -0.03671104088425636, 0.07697743922472, 0.03186740353703499, -0.010631799697875977, 0.025899047031998634, -0.0025138952769339085, -0.03396091237664223, -0.0276...
0.83866
0.776892
0.061768
Please write the following solution using Visual Basic .NET: The **distance of a pair** of integers `a` and `b` is defined as the absolute difference between `a` and `b`. Given an integer array `nums` and an integer `k`, return _the_ `kth` _smallest **distance among all the pairs**_ `nums[i]` _and_ `nums[j]` _where_ `...
dolphin
[ 0.014996163547039032, 0.03650084510445595, -0.03442532941699028, -0.025647277012467384, 0.05536458268761635, -0.02559853158891201, -0.018308473750948906, 0.05962546542286873, 0.050618115812540054, -0.022624336183071136, 0.028481245040893555, 0.022796345874667168, -0.021123385056853294, -0....
0.844167
0.784089
0.060078
Please explain the following problem in detail and provide code in ANSI C: There is an undirected connected tree with `n` nodes labeled from `0` to `n - 1` and `n - 1` edges. You are given a **0-indexed** integer array `nums` of length `n` where `nums[i]` represents the value of the `ith` node. You are also given a 2D...
dolphin
[ 0.005871592555195093, 0.029531395062804222, -0.027436284348368645, -0.03466413915157318, 0.023612897843122482, -0.03693390637636185, -0.020672451704740524, 0.0791010856628418, 0.04150085151195526, 0.0038909895811229944, 0.030332259833812714, 0.014854805544018745, -0.04177594929933548, -0.0...
0.840434
0.78486
0.055573
Please explain the reasoning behind the following solution and provide code in ANSI C: Given a `m * n` matrix of ones and zeros, return how many **square** submatrices have all ones. **Example 1:** **Input:** matrix = \[ \[0,1,1,1\], \[1,1,1,1\], \[0,1,1,1\] \] **Output:** 15 **Explanation:** There are **10** ...
dolphin
[ 0.011027115397155285, 0.04081139340996742, -0.025313323363661766, -0.04584835469722748, 0.05055183544754982, -0.026667876169085503, -0.041902992874383926, 0.08467204123735428, 0.028171105310320854, -0.012198155745863914, 0.013359801843762398, 0.015958715230226517, -0.053822413086891174, -0...
0.839404
0.783967
0.055437
Please write the following solution using C#: Given a collection of candidate numbers (`candidates`) and a target number (`target`), find all unique combinations in `candidates` where the candidate numbers sum to `target`. Each number in `candidates` may only be used **once** in the combination. **Note:** The solutio...
dolphin
[ 0.02517806738615036, 0.027563780546188354, -0.018287507817149162, -0.01590622030198574, 0.04461819678544998, -0.020298879593610764, -0.018476353958249092, 0.05640659108757973, 0.043694306164979935, -0.007732104510068893, 0.017507733777165413, 0.015900179743766785, -0.03179562836885452, -0....
0.833225
0.775399
0.057825
Please explain the following problem in detail and provide code in python: You are given a 2D integer array `intervals` where `intervals[i] = [starti, endi]` represents all the integers from `starti` to `endi` inclusively. A **containing set** is an array `nums` where each interval from `intervals` has **at least two*...
dolphin
[ 0.02996305748820305, 0.039491407573223114, -0.024715514853596687, -0.019295277073979378, 0.029603030532598495, -0.027669833973050117, -0.03450436890125275, 0.053757455199956894, 0.02998923324048519, -0.016246246173977852, 0.024031862616539, 0.02468334324657917, -0.028041886165738106, -0.00...
0.851913
0.792372
0.059541
Please write the following solution using Erlang: Given an array of integers `nums` and an integer `k`, return _the number of **unique** k-diff pairs in the array_. A **k-diff** pair is an integer pair `(nums[i], nums[j])`, where the following are true: * `0 <= i, j < nums.length` * `i != j` * `nums[i] - nums[j...
dolphin
[ 0.010189303196966648, 0.03618205338716507, -0.019754067063331604, -0.04301057010889053, 0.047045376151800156, -0.012093626894056797, -0.022586213424801826, 0.06573370844125748, 0.05231742188334465, -0.0076517947018146515, 0.02332102507352829, 0.007241377141326666, -0.019129697233438492, 0....
0.840517
0.787252
0.053266
Please write the following solution using Ruby: Given an integer array `nums` and an integer `k`, return the maximum sum of a **non-empty** subsequence of that array such that for every two **consecutive** integers in the subsequence, `nums[i]` and `nums[j]`, where `i < j`, the condition `j - i <= k` is satisfied. A _...
dolphin
[ 0.021849343553185463, 0.03241109848022461, -0.04295577108860016, -0.04368621110916138, 0.04750175029039383, -0.008848334662616253, -0.031207028776407242, 0.05232331156730652, 0.03454166650772095, -0.024901991710066795, 0.04002764821052551, 0.03798818960785866, -0.03779754415154457, 0.01862...
0.844593
0.786187
0.058406
Please focus on the functionality of this problem and provide code in java: 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\] **Ex...
dolphin
[ 0.019841957837343216, 0.039460986852645874, -0.04931390658020973, -0.023158609867095947, 0.03666055202484131, -0.03770247474312782, -0.03660351037979126, 0.042014408856630325, 0.03731639310717583, -0.010091207921504974, 0.031406328082084656, 0.03640998527407646, -0.038211870938539505, -0.0...
0.836477
0.777628
0.058849
Please focus on the functionality of this problem and provide code in c++: You are given two positive integer arrays `nums` and `target`, of the same length. In one operation, you can choose any two **distinct** indices `i` and `j` where `0 <= i, j < nums.length` and: * set `nums[i] = nums[i] + 2` and * set `nums...
dolphin
[ 0.021098803728818893, 0.02589339390397072, -0.02535136602818966, -0.01567206345498562, 0.0486898273229599, -0.007187407463788986, -0.027833295986056328, 0.10386983305215836, 0.031371429562568665, -0.01843276619911194, 0.015252891927957535, 0.014950251206755638, -0.02444722130894661, -0.011...
0.855302
0.794464
0.060838
Please explain the following problem in detail and provide code in C#: You are given a **0-indexed** string `pattern` of length `n` consisting of the characters `'I'` meaning **increasing** and `'D'` meaning **decreasing**. A **0-indexed** string `num` of length `n + 1` is created using the following conditions: * ...
dolphin
[ 0.002389139262959361, 0.020664937794208527, -0.017726127058267593, -0.036876652389764786, 0.030646471306681633, -0.03510076180100441, -0.01246711052954197, 0.0839919000864029, 0.029386499896645546, -0.0041684554889798164, 0.021660642698407173, 0.019105127081274986, -0.0439266636967659, -0....
0.847222
0.789392
0.05783
Please write the following solution using Scheme: You are given a 2D integer array, `queries`. For each `queries[i]`, where `queries[i] = [ni, ki]`, find the number of different ways you can place positive integers into an array of size `ni` such that the product of the integers is `ki`. As the number of ways may be to...
dolphin
[ 0.03773561120033264, 0.030521197244524956, -0.020202016457915306, -0.02186158485710621, 0.03085283562541008, -0.0241637472063303, -0.028983356431126595, 0.04174967482686043, 0.04136272892355919, -0.01038980484008789, 0.024003641679883003, 0.028113869950175285, -0.041533637791872025, -0.017...
0.844673
0.789702
0.054971
Please explain the reasoning behind the following solution and provide code in Haskell: You are given two integers `n` and `maxValue`, which are used to describe an **ideal** array. A **0-indexed** integer array `arr` of length `n` is considered **ideal** if the following conditions hold: * Every `arr[i]` is a valu...
dolphin
[ 0.034866418689489365, 0.012743506580591202, -0.02140418253839016, -0.02812459133565426, 0.04527349770069122, -0.03703734278678894, -0.0424288734793663, 0.042302753776311874, 0.03424923121929169, -0.023453498259186745, 0.033687394112348557, 0.03154889866709709, -0.03877833113074303, -0.0303...
0.839404
0.783675
0.05573
Please explain the reasoning behind the following solution and provide code in java: Given an array of positive integers `nums`, return _an array_ `answer` _that consists of the digits of each integer in_ `nums` _after separating them in **the same order** they appear in_ `nums`. To separate the digits of an integer i...
dolphin
[ 0.04444614052772522, 0.017014985904097557, -0.04121352732181549, -0.03935463726520538, 0.03644906356930733, -0.03635651618242264, -0.024937031790614128, 0.022917676717042923, 0.023059474304318428, -0.014773431234061718, 0.016108956187963486, 0.019075807183980942, -0.04693979024887085, -0.0...
0.833719
0.777066
0.056653
Please write the following solution using Scala: You are given an array of integers `arr` and an integer `target`. You have to find **two non-overlapping sub-arrays** of `arr` each with a sum equal `target`. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays ...
dolphin
[ 0.017992286011576653, 0.02594219334423542, -0.03538769856095314, -0.03487202897667885, 0.06592868268489838, -0.011352337896823883, -0.03093111328780651, 0.03260906785726547, 0.03573700040578842, -0.02025669254362583, 0.024439632892608643, 0.02169739082455635, -0.021048080176115036, -0.0200...
0.841294
0.786451
0.054843
Please write the following solution using c++: Given a string `s`, return _the maximum number of unique substrings that the given string can be split into_. You can split string `s` into any list of **non-empty substrings**, where the concatenation of the substrings forms the original string. However, you must split t...
dolphin
[ 0.022346073761582375, 0.013448313809931278, -0.013526968657970428, -0.018491247668862343, 0.04758913815021515, -0.027877788990736008, -0.021259447559714317, 0.07445962727069855, 0.041085485368967056, -0.015699172392487526, 0.019873231649398804, 0.030784042552113533, -0.017526131123304367, ...
0.827657
0.770422
0.057235
Please write the following solution using java: Given an integer array `arr`, return _the length of a maximum size turbulent subarray of_ `arr`. A subarray is **turbulent** if the comparison sign flips between each adjacent pair of elements in the subarray. More formally, a subarray `[arr[i], arr[i + 1], ..., arr[j]]...
dolphin
[ 0.02038389816880226, 0.03232777863740921, -0.03622756153345108, -0.02094998210668564, 0.03017358109354973, -0.02896932139992714, -0.05365140736103058, 0.03954995051026344, 0.023062556982040405, -0.013270228169858456, 0.029099412262439728, 0.007116731256246567, -0.030315453186631203, -0.017...
0.847548
0.780922
0.066626
Please write the following solution using Haskell: In combinatorial mathematics, a **derangement** is a permutation of the elements of a set, such that no element appears in its original position. You are given an integer `n`. There is originally an array consisting of `n` integers from `1` to `n` in ascending order, ...
dolphin
[ 0.04437766224145889, 0.008365336805582047, -0.013500351458787918, -0.03292248398065567, 0.0340489000082016, -0.020863953977823257, -0.03223000466823578, 0.041821617633104324, 0.0253081563860178, -0.013877135701477528, 0.03382999077439308, 0.01714175008237362, -0.043157849460840225, -0.0318...
0.846282
0.784829
0.061453
Please explain the following problem in detail and provide code in Object Pascal: Given an array of integers arr, find the sum of `min(b)`, where `b` ranges over every (contiguous) subarray of `arr`. Since the answer may be large, return the answer **modulo** `109 + 7`. **Example 1:** **Input:** arr = \[3,1,2,4\] **O...
dolphin
[ 0.01790132373571396, 0.021213581785559654, -0.0200224407017231, -0.047128915786743164, 0.05252494290471077, -0.023626822978258133, -0.03240758925676346, 0.033465996384620667, 0.05328749120235443, 0.0007456064922735095, 0.03371595963835716, 0.02782377041876316, -0.030857639387249947, -0.001...
0.846568
0.783393
0.063175
Please explain the following problem in detail and provide code in c++: Given an integer `n`, return _the number of structurally unique **BST'**s (binary search trees) which has exactly_ `n` _nodes of unique values from_ `1` _to_ `n`. **Example 1:** **Input:** n = 3 **Output:** 5 **Example 2:** **Input:** n = 1 **O...
dolphin
[ 0.016912944614887238, 0.020616745576262474, -0.04765401780605316, -0.02519630268216133, 0.03510652855038643, -0.02673398330807686, -0.012703809887170792, 0.06965120136737823, 0.04510478675365448, -0.004464576952159405, 0.025662485510110855, 0.03572538122534752, -0.035779859870672226, 0.000...
0.842003
0.783846
0.058158
Please write the following solution using ANSI C: Alice and Bob take turns playing a game, with **Alice starting first**. There are `n` stones arranged in a row. On each player's turn, while the number of stones is **more than one**, they will do the following: 1. Choose an integer `x > 1`, and **remove** the leftmo...
dolphin
[ 0.034397851675748825, 0.024045711383223534, -0.03854139521718025, -0.03845587000250816, 0.01584944874048233, -0.03597559407353401, -0.032817061990499496, 0.07827632874250412, 0.048761360347270966, -0.023776214569807053, 0.04011349007487297, 0.02567320317029953, -0.04155249148607254, -0.014...
0.841675
0.781261
0.060415
Please explain the following problem in detail and provide code in Object Pascal: Given an integer array `nums` and an integer `k`, return `true` if it is possible to divide this array into `k` non-empty subsets whose sums are all equal. **Example 1:** **Input:** nums = \[4,3,2,3,5,2,1\], k = 4 **Output:** true **Exp...
dolphin
[ 0.013070577755570412, 0.02544209733605385, -0.027625957503914833, -0.033701006323099136, 0.05287756770849228, -0.018777580931782722, 0.01125367358326912, 0.0632721334695816, 0.02042865939438343, -0.005969410762190819, 0.027906326577067375, 0.017950963228940964, -0.026106026023626328, -0.00...
0.835379
0.773384
0.061996
Please write the following solution using Mojo: 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, ev...
dolphin
[ 0.025578975677490234, 0.026190035045146942, -0.023267924785614014, -0.021989190950989723, 0.0436922088265419, -0.014264054596424103, -0.052098099142313004, 0.03699637949466705, 0.0233786441385746, -0.003165622940286994, 0.021986372768878937, 0.011898855678737164, -0.0508665032684803, -0.02...
0.840246
0.771783
0.068463
Please explain the following problem in detail and provide code in javascript: You are given a **0-indexed** integer array `nums`. You can rearrange the elements of `nums` to **any order** (including the given order). Let `prefix` be the array containing the prefix sums of `nums` after rearranging it. In other words, ...
dolphin
[ 0.00798475369811058, 0.02163352072238922, -0.01276429183781147, -0.023079702630639076, 0.02695401944220066, -0.008070690557360649, -0.02617005631327629, 0.03926561772823334, 0.03245619684457779, 0.0035929963923990726, 0.013727026991546154, 0.019946901127696037, -0.041508618742227554, -0.00...
0.842907
0.785122
0.057785
Please write the following solution using Object Pascal: Given an integer n, return _the **largest palindromic integer** that can be represented as the product of two `n`\-digits integers_. Since the answer can be very large, return it **modulo** `1337`. **Example 1:** **Input:** n = 2 **Output:** 987 Explanation: 99...
dolphin
[ 0.02933640219271183, 0.03965189680457115, -0.0117013119161129, -0.04339146986603737, 0.022825155407190323, -0.019475987181067467, -0.02364818938076496, 0.047751929610967636, 0.02466641180217266, -0.010931151919066906, 0.0415351465344429, 0.04378042370080948, -0.03290862962603569, -0.013332...
0.833921
0.777572
0.056349
Please write the following solution using R: You want to build some obstacle courses. You are given a **0-indexed** integer array `obstacles` of length `n`, where `obstacles[i]` describes the height of the `ith` obstacle. For every index `i` between `0` and `n - 1` (**inclusive**), find the length of the **longest obs...
dolphin
[ 0.020981838926672935, 0.02876565046608448, -0.021608643233776093, -0.03575354442000389, 0.02563936822116375, -0.01563427224755287, -0.05917736142873764, 0.04345981031656265, 0.0455089695751667, -0.01521189697086811, 0.0015847093891352415, 0.019741838797926903, -0.029095498844981194, -0.020...
0.835565
0.77461
0.060955
Please explain the following problem in detail and provide code in PHP: Given a string `s`, return _the number of **palindromic substrings** in it_. A string is a **palindrome** when it reads the same backward as forward. A **substring** is a contiguous sequence of characters within the string. **Example 1:** **Inp...
dolphin
[ 0.004131772089749575, 0.010489209555089474, -0.023047666996717453, -0.023875992745161057, 0.039089448750019073, -0.030429614707827568, -0.00834096223115921, 0.057456787675619125, 0.03425736725330353, 0.010588518343865871, 0.030583733692765236, 0.03129374235868454, -0.04048663750290871, -0....
0.824856
0.771029
0.053827
Please write the following solution using ANSI C: **No-Zero integer** is a positive integer that **does not contain any `0`** in its decimal representation. Given an integer `n`, return _a list of two integers_ `[a, b]` _where_: * `a` and `b` are **No-Zero integers**. * `a + b = n` The test cases are generated s...
dolphin
[ 0.0465674102306366, 0.038193393498659134, -0.020563729107379913, -0.0493294894695282, 0.028506863862276077, 0.009611709974706173, -0.018789105117321014, 0.06373721361160278, 0.045034609735012054, -0.022783374413847923, 0.0446343757212162, 0.035139299929142, -0.03086225874722004, -0.0372666...
0.829348
0.768358
0.06099
Please focus on the functionality of this problem and provide code in R: The set `[1, 2, 3, ..., n]` contains a total of `n!` unique permutations. By listing and labeling all of the permutations in order, we get the following sequence for `n = 3`: 1. `"123 "` 2. `"132 "` 3. `"213 "` 4. `"231 "` 5. `"312 "` 6. `...
dolphin
[ 0.026782115921378136, 0.0447644479572773, -0.015757396817207336, -0.04064794257283211, 0.0437299869954586, -0.019774451851844788, -0.01253579743206501, 0.04788357764482498, 0.019285103306174278, -0.0051970272324979305, 0.025502193719148636, 0.030484583228826523, -0.049838289618492126, 0.00...
0.833755
0.776136
0.057618
Please explain the following problem in detail and provide code in PHP: You are given an integer array `nums`. We call a subset of `nums` **good** if its product can be represented as a product of one or more **distinct prime** numbers. * For example, if `nums = [1, 2, 3, 4]`: * `[2, 3]`, `[1, 2, 3]`, and `[1,...
dolphin
[ 0.031965240836143494, 0.020965514704585075, -0.027587419375777245, -0.025633767247200012, 0.035624779760837555, -0.031130755320191383, -0.0323207750916481, 0.06063452363014221, 0.045954395085573196, -0.006241202354431152, 0.026694580912590027, 0.017881164327263832, -0.033914607018232346, -...
0.841921
0.78335
0.058572
Please focus on the efficiency of this problem and provide code in Swift: You are given an array `nums` that consists of positive integers. The **GCD** of a sequence of numbers is defined as the greatest integer that divides **all** the numbers in the sequence evenly. * For example, the GCD of the sequence `[4,6,16...
dolphin
[ 0.018949223682284355, 0.02380215749144554, -0.017102448269724846, -0.030238516628742218, 0.03027338534593582, -0.02127833291888237, -0.034212443977594376, 0.06028486788272858, 0.032131653279066086, -0.01951669156551361, 0.02452000044286251, 0.013211860321462154, -0.033950306475162506, -0.0...
0.840223
0.784997
0.055227
Please write the following solution using Julia: Given an array of integers, return the maximum sum for a **non-empty** subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element le...
dolphin
[ 0.0267011821269989, 0.019764428958296776, -0.03123115748167038, -0.03572789579629898, 0.043013233691453934, -0.02000530995428562, -0.03140395134687424, 0.04676884412765503, 0.043568823486566544, -0.017294203862547874, 0.0184449702501297, 0.02374187484383583, -0.02609076164662838, -0.005624...
0.838172
0.776139
0.062034
Please write the following solution using Kotlin: Given two integers `left` and `right`, return _the **count** of numbers in the **inclusive** range_ `[left, right]` _having a **prime number of set bits** in their binary representation_. Recall that the **number of set bits** an integer has is the number of `1`'s pres...
dolphin
[ 0.023962777107954025, 0.023834113031625748, -0.017313405871391296, -0.02098710834980011, 0.035382065922021866, -0.025768037885427475, -0.019013382494449615, 0.06847045570611954, 0.0360066182911396, -0.017789257690310478, 0.02576529048383236, 0.022387783974409103, -0.01956397294998169, -0.0...
0.833673
0.780126
0.053547
Please explain the reasoning behind the following solution and provide code in Scheme: Given an integer `n`, return **any** array containing `n` **unique** integers such that they add up to `0`. **Example 1:** **Input:** n = 5 **Output:** \[-7,-1,1,3,4\] **Explanation:** These arrays also are accepted \[-5,-1,1,2,3\]...
dolphin
[ 0.024570876732468605, 0.038799989968538284, -0.01898552104830742, -0.032132331281900406, 0.04168471321463585, -0.0393134206533432, -0.01986086554825306, 0.04929303377866745, 0.040402743965387344, -0.0038451163563877344, 0.02117748185992241, 0.025462783873081207, -0.031236859038472176, -0.0...
0.837999
0.781496
0.056504
Please explain the following problem in detail and provide code in javascript: You are given an integer array `nums` of length `n` where `nums` is a permutation of the numbers in the range `[0, n - 1]`. You should build a set `s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... }` subjected to the following rule:...
dolphin
[ 0.0234401635825634, 0.027443792670965195, -0.031038206070661545, -0.008567257784307003, 0.03484980762004852, -0.03052111528813839, -0.03099418804049492, 0.05734461545944214, 0.03306958079338074, -0.013402472250163555, 0.0284956693649292, 0.012698981910943985, -0.03738037124276161, -0.00439...
0.844757
0.780857
0.0639
Please write the following solution using Elixir: Given an integer array `arr` and an integer `k`, modify the array by repeating it `k` times. For example, if `arr = [1, 2]` and `k = 3` then the modified array will be `[1, 2, 1, 2, 1, 2]`. Return the maximum sub-array sum in the modified array. Note that the length o...
dolphin
[ 0.03355739265680313, 0.03114476427435875, -0.013313782401382923, -0.0461047999560833, 0.03955567255616188, -0.029780803248286247, -0.02770470641553402, 0.035781130194664, 0.029635315760970116, -0.022736316546797752, 0.03512566164135933, 0.026868589222431183, -0.03836983069777489, 0.0057918...
0.842451
0.776405
0.066046
Please write the following solution using javascript: 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 digit after rotation....
dolphin
[ 0.018859419971704483, 0.014297311194241047, -0.0324847437441349, -0.016952915117144585, 0.012680761516094208, -0.023799477145075798, -0.031787142157554626, 0.03196914121508598, 0.017282657325267792, -0.013963693752884865, 0.0027222735807299614, 0.023547247052192688, -0.04225492849946022, -...
0.843091
0.786796
0.056295
Please explain the following problem in detail and provide code in Ruby: 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.024002326652407646, 0.03371715918183327, -0.044728681445121765, -0.05557853728532791, 0.023235060274600983, -0.029064172878861427, -0.038401663303375244, 0.06036074087023735, 0.030219167470932007, -0.036030977964401245, 0.027906151488423347, 0.007504680659621954, -0.020634528249502182, -...
0.838955
0.784106
0.054849
Please explain the following problem in detail and provide code in Visual Basic .NET: A **ramp** in an integer array `nums` is a pair `(i, j)` for which `i < j` and `nums[i] <= nums[j]`. The **width** of such a ramp is `j - i`. Given an integer array `nums`, return _the maximum width of a **ramp** in_ `nums`. If there...
dolphin
[ 0.020298583433032036, 0.03098444826900959, -0.027654225006699562, -0.011753076687455177, 0.04533052816987038, -0.017446506768465042, -0.038377340883016586, 0.08267366886138916, 0.03818415850400925, -0.025231683626770973, 0.025971949100494385, 0.031196247786283493, -0.03513753041625023, -0....
0.841386
0.778762
0.062624
Please explain the following problem in detail and provide code in Visual Basic .NET: 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 j...
dolphin
[ -0.004070853814482689, 0.024044586345553398, -0.015140890143811703, -0.032512396574020386, 0.04047802463173866, -0.0233861543238163, -0.0217119250446558, 0.06937315315008163, 0.04327709600329399, -0.0032864478416740894, 0.027314625680446625, 0.0310579314827919, -0.042748697102069855, -0.00...
0.85027
0.794179
0.056091
Please explain the following problem in detail and provide code in python: You are given an `m x n` integer array `grid` where `grid[i][j]` could be: * `1` representing the starting square. There is exactly one starting square. * `2` representing the ending square. There is exactly one ending square. * `0` repre...
dolphin
[ 0.01064702495932579, 0.02865752950310707, -0.01871502585709095, -0.03749103844165802, 0.04100313037633896, -0.02908080443739891, -0.04067216441035271, 0.04458797350525856, 0.03637996315956116, 0.003552620764821768, 0.020444562658667564, 0.02093532867729664, -0.013871069066226482, -0.029439...
0.843322
0.785559
0.057763
Please explain the following problem in detail and provide code in C#: 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 `nums1[i]` and `...
dolphin
[ 0.014287196099758148, 0.02110162191092968, -0.028168631717562675, -0.02838277257978916, 0.03366854786872864, -0.022267598658800125, -0.03601190820336342, 0.07949643582105637, 0.05447914078831673, -0.02034173533320427, 0.020280465483665466, 0.021777668967843056, -0.0002305754169356078, -0.0...
0.844887
0.782584
0.062303
Please write the following solution using Groovy: You are given an array `nums` of positive integers and a **positive** integer `k`. A subset of `nums` is **beautiful** if it does not contain two integers with an absolute difference equal to `k`. Return _the number of **non-empty beautiful** subsets of the array_ `nu...
dolphin
[ 0.01202311646193266, 0.042033422738313675, -0.031421296298503876, -0.027489179745316505, 0.049766622483730316, -0.02443569526076317, -0.03174907714128494, 0.03285335376858711, 0.046766526997089386, -0.009032487869262695, 0.03237992897629738, 0.02832440286874771, -0.030165456235408783, 0.00...
0.844424
0.784836
0.059588