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 Mojo:
You are given an array of positive integers `nums` and want to erase a subarray containing **unique elements**. The **score** you get by erasing the subarray is equal to the **sum** of its elements.
Return _the **maximum score** you can get by er... | dolphin | [
0.016404032707214355,
0.02695631980895996,
-0.03154648095369339,
-0.025598768144845963,
0.03228029981255531,
-0.031553640961647034,
-0.033461641520261765,
0.049695178866386414,
0.0538046658039093,
-0.00778088066726923,
0.024183496832847595,
0.007707919459789991,
-0.023946285247802734,
-0.0... | 0.8461 | 0.791231 | 0.054869 |
Please explain the following problem in detail and provide code in R:
Given an integer array `nums`, return _the maximum result of_ `nums[i] XOR nums[j]`, where `0 <= i <= j < n`.
**Example 1:**
**Input:** nums = \[3,10,5,25,2,8\]
**Output:** 28
**Explanation:** The maximum result is 5 XOR 25 = 28.
**Example 2:**
*... | dolphin | [
0.029958782717585564,
0.02741258218884468,
-0.03158706799149513,
-0.011479990556836128,
0.017371300607919693,
-0.021354693919420242,
-0.04046265780925751,
0.05841502547264099,
0.039268266409635544,
0.002562834182754159,
0.011438068933784962,
0.030283069238066673,
-0.04070776328444481,
-0.0... | 0.842027 | 0.775822 | 0.066206 |
Please write the following solution using Go:
You are given an array `nums` of `n` positive integers.
You can perform two types of operations on any element of the array any number of times:
* If the element is **even**, **divide** it by `2`.
* For example, if the array is `[1,2,3,4]`, then you can do this op... | dolphin | [
0.008246563374996185,
0.024354346096515656,
-0.014609180390834808,
-0.02512936294078827,
0.035925012081861496,
-0.012574498541653156,
-0.057696692645549774,
0.04888462647795677,
0.043090712279081345,
-0.004700299818068743,
0.00225240015424788,
0.026102731004357338,
-0.026374751701951027,
-... | 0.841731 | 0.788346 | 0.053385 |
Please write the following solution using C#:
You are given a **0-indexed** 2D integer array `peaks` where `peaks[i] = [xi, yi]` states that mountain `i` has a peak at coordinates `(xi, yi)`. A mountain can be described as a right-angled isosceles triangle, with its base along the `x`\-axis and a right angle at its pea... | dolphin | [
0.02520948462188244,
0.033307988196611404,
-0.028207046911120415,
-0.028728216886520386,
0.02598499320447445,
-0.026365458965301514,
-0.027343783527612686,
0.094755157828331,
0.040333427488803864,
-0.010660389438271523,
0.017758218571543694,
0.011666813865303993,
-0.02307482250034809,
-0.0... | 0.839467 | 0.784616 | 0.054851 |
Please explain the reasoning behind the following solution and provide code in PHP:
Given an integer array `nums`, partition it into two (contiguous) subarrays `left` and `right` so that:
* Every element in `left` is less than or equal to every element in `right`.
* `left` and `right` are non-empty.
* `left` has... | dolphin | [
0.02397921122610569,
0.03040190413594246,
-0.03683753311634064,
-0.009237728081643581,
0.029513724148273468,
-0.006992904935032129,
-0.02533370815217495,
0.06846962869167328,
0.03538898751139641,
-0.0027632471174001694,
0.02020963467657566,
0.028287874534726143,
-0.029575902968645096,
-0.0... | 0.84399 | 0.785611 | 0.058379 |
Please explain the following problem in detail and provide code in Swift:
You are given two **0-indexed** integer arrays `nums1` and `nums2` of length `n`.
A range `[l, r]` (**inclusive**) where `0 <= l <= r < n` is **balanced** if:
* For every `i` in the range `[l, r]`, you pick either `nums1[i]` or `nums2[i]`.
* ... | dolphin | [
0.013309611938893795,
0.020628824830055237,
-0.031689319759607315,
-0.02542903646826744,
0.0505717433989048,
-0.01819435879588127,
-0.0269820187240839,
0.060355015099048615,
0.03882425278425217,
-0.018830053508281708,
0.02128123864531517,
0.026465805247426033,
-0.03687179088592529,
-0.0171... | 0.843365 | 0.787902 | 0.055463 |
Please explain the following problem in detail and provide code in Scheme:
You are given two **0-indexed** arrays `nums` and `cost` consisting each of `n` **positive** integers.
You can do the following operation **any** number of times:
* Increase or decrease **any** element of the array `nums` by `1`.
The cost o... | dolphin | [
0.018541643396019936,
0.03466618061065674,
-0.032451849430799484,
-0.024130186066031456,
0.03651457279920578,
-0.021942317485809326,
-0.019467860460281372,
0.06177379563450813,
0.03552128002047539,
-0.015697909519076347,
0.030839527025818825,
0.011224973946809769,
-0.030271116644144058,
-0... | 0.855151 | 0.795513 | 0.059637 |
Please write the following solution using ANSI C:
Given an integer array `nums`, return _the number of non-empty **subarrays** with the leftmost element of the subarray not larger than other elements in the subarray_.
A **subarray** is a **contiguous** part of an array.
**Example 1:**
**Input:** nums = \[1,4,2,5,3\]... | dolphin | [
0.022713331505656242,
0.0326690673828125,
-0.025877172127366066,
-0.03376249223947525,
0.03166519105434418,
-0.0013647486921399832,
-0.04515210539102554,
0.067999467253685,
0.022337695583701134,
-0.014419468119740486,
0.035469427704811096,
0.03537391871213913,
-0.054627493023872375,
-0.027... | 0.846669 | 0.780041 | 0.066628 |
Please explain the following problem in detail and provide code in python:
You are given a **positive** integer `num` consisting of exactly four digits. Split `num` into two new integers `new1` and `new2` by using the **digits** found in `num`. **Leading zeros** are allowed in `new1` and `new2`, and **all** the digits ... | dolphin | [
0.007465319242328405,
0.025870535522699356,
-0.028294846415519714,
-0.02957027032971382,
0.04781441017985344,
-0.009408152662217617,
-0.030274925753474236,
0.03709708899259567,
0.03825624659657478,
-0.000666452688165009,
0.018894696608185768,
0.03566738963127136,
-0.01607801578938961,
-0.0... | 0.840507 | 0.77747 | 0.063037 |
Please explain the following problem in detail and provide code in java:
Winston was given the above mysterious function `func`. He has an integer array `arr` and an integer `target` and he wants to find the values `l` and `r` that make the value `|func(arr, l, r) - target|` minimum possible.
Return _the minimum possi... | dolphin | [
0.01958533748984337,
0.03557613119482994,
-0.03420858830213547,
-0.02899966947734356,
0.054058484733104706,
-0.022935518994927406,
-0.041394900530576706,
0.038446445018053055,
0.03765686973929405,
-0.028463920578360558,
0.0340157076716423,
0.022468402981758118,
-0.022612974047660828,
-0.00... | 0.841891 | 0.783926 | 0.057965 |
Please explain the following problem in detail and provide code in Scala:
You are given an integer array of unique positive integers `nums`. Consider the following graph:
* There are `nums.length` nodes, labeled `nums[0]` to `nums[nums.length - 1]`,
* There is an undirected edge between `nums[i]` and `nums[j]` if ... | dolphin | [
0.027294036000967026,
0.04432464390993118,
-0.024384714663028717,
-0.02548610232770443,
0.032523512840270996,
-0.01425703801214695,
-0.023806478828191757,
0.04679048806428909,
0.020284034311771393,
-0.006704618688672781,
0.03167704865336418,
0.03311438858509064,
-0.01714303158223629,
-0.01... | 0.845257 | 0.78093 | 0.064326 |
Please explain the reasoning behind the following solution and provide code in R:
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** i... | dolphin | [
0.013959037140011787,
0.028033791109919548,
-0.025931628420948982,
-0.03251340240240097,
0.02556517906486988,
-0.008350757881999016,
-0.02307424135506153,
0.05401581525802612,
0.0322904959321022,
-0.008262315765023232,
0.02088250033557415,
0.03628212586045265,
-0.03536852449178696,
-0.0420... | 0.830802 | 0.773284 | 0.057518 |
Please write the following solution using PHP:
A sequence `x1, x2, ..., xn` is _Fibonacci-like_ if:
* `n >= 3`
* `xi + xi+1 == xi+2` for all `i + 2 <= n`
Given a **strictly increasing** array `arr` of positive integers forming a sequence, return _the **length** of the longest Fibonacci-like subsequence of_ `arr`.... | dolphin | [
0.022825036197900772,
0.02241617441177368,
-0.03479095548391342,
-0.03605778142809868,
0.033434465527534485,
-0.02831108495593071,
-0.05058099702000618,
0.08182059973478317,
0.04612485319375992,
-0.013477993197739124,
0.026351328939199448,
0.004595387261360884,
-0.03757569566369057,
-0.026... | 0.835301 | 0.769786 | 0.065515 |
Please write the following solution using Kotlin:
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**_.
**Example 1:**
**Input... | dolphin | [
0.014940434135496616,
0.026621637865900993,
-0.018069611862301826,
-0.030151497572660446,
0.046013243496418,
-0.018816454336047173,
-0.030626224353909492,
0.0616268515586853,
0.03137872368097305,
-0.026671575382351875,
0.03790436312556267,
0.034612949937582016,
-0.03761318698525429,
-0.007... | 0.848273 | 0.790168 | 0.058105 |
Please write the following solution using c++:
You have `n` bags numbered from `0` to `n - 1`. You are given two **0-indexed** integer arrays `capacity` and `rocks`. The `ith` bag can hold a maximum of `capacity[i]` rocks and currently contains `rocks[i]` rocks. You are also given an integer `additionalRocks`, the numb... | dolphin | [
0.05511597543954849,
0.04011647403240204,
-0.0242784321308136,
-0.011676530353724957,
0.02623916231095791,
-0.02567981369793415,
-0.03238555043935776,
0.09346836060285568,
0.026578521355986595,
-0.013644304126501083,
0.027179595082998276,
0.042119115591049194,
-0.034472621977329254,
-0.025... | 0.841023 | 0.7868 | 0.054223 |
Please write the following solution using R:
Given an integer array `nums` **(0-indexed)** and two integers `target` and `start`, find an index `i` such that `nums[i] == target` and `abs(i - start)` is **minimized**. Note that `abs(x)` is the absolute value of `x`.
Return `abs(i - start)`.
It is **guaranteed** that `... | dolphin | [
0.025831732898950577,
0.03360168635845184,
-0.030661098659038544,
-0.02409093827009201,
0.04912018030881882,
-0.01535039208829403,
-0.03779340162873268,
0.06237069517374039,
0.04471952095627785,
-0.014072846621274948,
0.017468441277742386,
0.014849110506474972,
-0.028794120997190475,
-0.01... | 0.839043 | 0.783599 | 0.055444 |
Please explain the reasoning behind the following solution and provide code in C#:
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 eq... | dolphin | [
0.02688296139240265,
0.03652331605553627,
-0.02442745864391327,
-0.014751868322491646,
0.03781120851635933,
-0.054877202957868576,
-0.016923975199460983,
0.0953059121966362,
0.03739336505532265,
-0.02447282336652279,
0.026014968752861023,
0.009391119703650475,
-0.043560102581977844,
-0.019... | 0.8395 | 0.783019 | 0.056481 |
Please explain the reasoning behind the following solution and provide code in Kotlin:
Given an array of `n` integers `nums` and an integer `target`, find the number of index triplets `i`, `j`, `k` with `0 <= i < j < k < n` that satisfy the condition `nums[i] + nums[j] + nums[k] < target`.
**Example 1:**
**Input:** n... | dolphin | [
0.00716632092371583,
0.011624128557741642,
-0.018159041181206703,
-0.02645309455692768,
0.05207178741693497,
-0.008452395908534527,
-0.03411704674363136,
0.050584498792886734,
0.021058257669210434,
0.0011771108256652951,
0.014192763715982437,
0.03287362679839134,
-0.044973477721214294,
-0.... | 0.84471 | 0.790287 | 0.054424 |
Please explain the reasoning behind the following solution and provide code in c++:
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**... | dolphin | [
0.02144513465464115,
0.014988086186349392,
-0.02078844979405403,
-0.02704990841448307,
0.02578531764447689,
-0.013868221081793308,
-0.04723246395587921,
0.07866764068603516,
0.04523031413555145,
-0.020247705280780792,
0.01792333833873272,
0.029394026845693588,
-0.022116029635071754,
-0.005... | 0.842117 | 0.782685 | 0.059432 |
Please focus on the algorithm of this problem and provide code in PHP:
You are given an integer array `nums` and two integers `minK` and `maxK`.
A **fixed-bound subarray** of `nums` is a subarray that satisfies the following conditions:
* The **minimum** value in the subarray is equal to `minK`.
* The **maximum**... | dolphin | [
0.013692572712898254,
0.035934869199991226,
-0.020962286740541458,
-0.008677120320498943,
0.040520936250686646,
-0.022804560139775276,
-0.036277495324611664,
0.06475991755723953,
0.03630514815449715,
0.0019687889143824577,
0.03443929925560951,
0.024003518745303154,
-0.029928145930171013,
0... | 0.843938 | 0.788076 | 0.055863 |
Please write the following solution using Elixir:
You are given an integer `n`. There is an **undirected** graph with `n` nodes, numbered from `0` to `n - 1`. You are given a 2D integer array `edges` where `edges[i] = [ai, bi]` denotes that there exists an **undirected** edge connecting nodes `ai` and `bi`.
Return _th... | dolphin | [
0.02889656089246273,
0.03907020017504692,
-0.011469513177871704,
-0.037974048405885696,
0.031057177111506462,
-0.028078146278858185,
-0.019398653879761696,
0.034542132169008255,
0.03237343952059746,
-0.001097032567486167,
0.034317903220653534,
0.030060993507504463,
-0.020869683474302292,
-... | 0.852247 | 0.794703 | 0.057543 |
Please focus on the algorithm of this problem and provide code in Object Pascal:
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 rema... | dolphin | [
0.010694531723856926,
0.01433518622070551,
-0.01914111338555813,
-0.020013028755784035,
0.00905410572886467,
-0.030089573934674263,
-0.023117439821362495,
0.04168175533413887,
0.022313127294182777,
-0.006523715797811747,
0.008695483207702637,
0.03572777658700943,
-0.03292979300022125,
-0.0... | 0.841765 | 0.786687 | 0.055078 |
Please explain the following problem in detail and provide code in ANSI C:
As the ruler of a kingdom, you have an army of wizards at your command.
You are given a **0-indexed** integer array `strength`, where `strength[i]` denotes the strength of the `ith` wizard. For a **contiguous** group of wizards (i.e. the wizard... | dolphin | [
0.03428300842642784,
0.045055776834487915,
-0.03313369303941727,
-0.06149100884795189,
0.049801718443632126,
-0.037545282393693924,
-0.04072406888008118,
0.07293642312288284,
0.04290110990405083,
-0.036608871072530746,
0.04118552431464195,
0.031107431277632713,
-0.06244581192731857,
-0.026... | 0.838233 | 0.783389 | 0.054844 |
Please write the following solution using Lua:
Given a binary array `nums` and an integer `k`, return _the maximum number of consecutive_ `1`_'s in the array if you can flip at most_ `k` `0`'s.
**Example 1:**
**Input:** nums = \[1,1,1,0,0,0,1,1,1,1,0\], k = 2
**Output:** 6
**Explanation:** \[1,1,1,0,0,**1**,1,1,1,1,*... | dolphin | [
0.003736355807632208,
0.048549652099609375,
-0.009458432905375957,
-0.04414885491132736,
0.04373926669359207,
-0.021487582474946976,
-0.03866170719265938,
0.03751669079065323,
0.025203578174114227,
-0.027762625366449356,
0.03585410118103027,
0.02607232704758644,
-0.026794183999300003,
-0.0... | 0.847102 | 0.793609 | 0.053493 |
Please explain the reasoning behind the following solution and provide code in Mojo:
You are given a 0-indexed integer array `nums`. You are allowed to permute `nums` into a new array `perm` of your choosing.
We define the **greatness** of `nums` be the number of indices `0 <= i < nums.length` for which `perm[i] > num... | dolphin | [
0.018167534843087196,
0.03382337465882301,
-0.0024130172096192837,
-0.034975551068782806,
0.022847715765237808,
-0.02191794663667679,
-0.042197778820991516,
0.05587082356214523,
0.026067737489938736,
-0.007674844935536385,
0.011919785290956497,
0.016698235645890236,
-0.04389605298638344,
-... | 0.844387 | 0.788773 | 0.055614 |
Please focus on the efficiency of this problem and provide code in R:
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` _ti... | dolphin | [
0.026181356981396675,
0.03164614364504814,
-0.032531559467315674,
-0.028907185420393944,
0.027895811945199966,
-0.014814279042184353,
-0.039949025958776474,
0.0780811458826065,
0.02597941644489765,
0.0026644279714673758,
0.015236083418130875,
0.019318057224154472,
-0.03126395493745804,
-0.... | 0.842565 | 0.779185 | 0.06338 |
Please explain the following problem in detail and provide code in ANSI C:
You are given a **0-indexed** integer array `nums` of length `n`.
The **average difference** of the index `i` is the **absolute** **difference** between the average of the **first** `i + 1` elements of `nums` and the average of the **last** `n ... | dolphin | [
0.009472413919866085,
0.042393095791339874,
-0.021296456456184387,
-0.029916947707533836,
0.03512143716216087,
-0.03752885386347771,
-0.05597871169447899,
0.06825718283653259,
0.032139234244823456,
-0.019103145226836205,
0.03604646399617195,
0.011463972739875317,
-0.05181214213371277,
0.00... | 0.82526 | 0.769495 | 0.055765 |
Please focus on the efficiency of this problem and provide code in Groovy:
A **subarray** of a **0-indexed** integer array is a contiguous **non-empty** sequence of elements within an array.
The **alternating subarray sum** of a subarray that ranges from index `i` to `j` (**inclusive**, `0 <= i <= j < nums.length`) is... | dolphin | [
0.018327128142118454,
0.026799693703651428,
-0.01975094899535179,
-0.023404281586408615,
0.022550107911229134,
-0.026143280789256096,
-0.04228238761425018,
0.04200896993279457,
0.04589657485485077,
-0.014828929677605629,
0.03295794501900673,
0.019504206255078316,
-0.04528757184743881,
0.00... | 0.834822 | 0.776595 | 0.058227 |
Please focus on the efficiency of this problem and provide code in PHP:
The **pair sum** of a pair `(a,b)` is equal to `a + b`. The **maximum pair sum** is the largest **pair sum** in a list of pairs.
* For example, if we have pairs `(1,5)`, `(2,3)`, and `(4,4)`, the **maximum pair sum** would be `max(1+5, 2+3, 4+4)... | dolphin | [
0.017984073609113693,
0.024188732728362083,
-0.042009755969047546,
-0.024790221825242043,
0.0399523489177227,
-0.002321684267371893,
-0.02215191163122654,
0.04228564351797104,
0.033032845705747604,
-0.01859806850552559,
0.019443294033408165,
0.039980098605155945,
-0.03480828180909157,
-0.0... | 0.841589 | 0.785445 | 0.056144 |
Please focus on the functionality of this problem and provide code in Rust:
You are given an integer array `nums` and an integer `k`.
Find the longest subsequence of `nums` that meets the following requirements:
* The subsequence is **strictly increasing** and
* The difference between adjacent elements in the sub... | dolphin | [
0.02560076303780079,
0.0375782772898674,
-0.014114000834524632,
-0.03774610534310341,
0.030397355556488037,
-0.016499975696206093,
-0.03896491974592209,
0.0765458419919014,
0.04604271054267883,
-0.01342563983052969,
0.02791348285973072,
0.0237606018781662,
-0.026954766362905502,
0.02050181... | 0.842864 | 0.788614 | 0.054249 |
Please explain the reasoning behind the following solution and provide code in R:
Given a **0-indexed** integer array `nums` of length `n` and an integer `k`, return _the **number of pairs**_ `(i, j)` _such that:_
* `0 <= i < j <= n - 1` _and_
* `nums[i] * nums[j]` _is divisible by_ `k`.
**Example 1:**
**Input:*... | dolphin | [
0.01553304959088564,
0.04495655372738838,
-0.04158078134059906,
-0.022821472957730293,
0.05876987800002098,
-0.016536934301257133,
-0.033992949873209,
0.071912981569767,
0.02485191449522972,
-0.0023689575027674437,
0.0064636338502168655,
0.025243263691663742,
-0.02520996890962124,
-0.02231... | 0.838209 | 0.781495 | 0.056714 |
Please write the following solution using Go:
You are given four integers `minLength`, `maxLength`, `oneGroup` and `zeroGroup`.
A binary string is **good** if it satisfies the following conditions:
* The length of the string is in the range `[minLength, maxLength]`.
* The size of each block of consecutive `1`'s i... | dolphin | [
0.009973065927624702,
0.020542820915579796,
-0.024162082001566887,
-0.04703180864453316,
0.06133395433425903,
-0.0465373732149601,
-0.04769078269600868,
0.054183315485715866,
0.038826197385787964,
-0.017788304015994072,
0.006466613616794348,
0.01931011863052845,
-0.03259672224521637,
-0.03... | 0.855153 | 0.800233 | 0.05492 |
Please focus on the efficiency of this problem and provide code in javascript:
Given an integer array `nums`, return _the **third distinct maximum** number in this array. If the third maximum does not exist, return the **maximum** number_.
**Example 1:**
**Input:** nums = \[3,2,1\]
**Output:** 1
**Explanation:**
The ... | dolphin | [
0.031494803726673126,
0.031244585290551186,
-0.034030813723802567,
-0.015942871570587158,
0.03212951868772507,
-0.018900062888860703,
-0.03316952660679817,
0.0554119274020195,
0.025104857981204987,
-0.012361162342131138,
0.03690284490585327,
0.021373536437749863,
-0.04368046298623085,
-0.0... | 0.835749 | 0.781607 | 0.054142 |
Please focus on the algorithm of this problem and provide code in Perl:
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 ... | dolphin | [
0.007578983902931213,
0.026059165596961975,
-0.02456631325185299,
-0.01952456869184971,
0.03785500302910805,
-0.010760637000203133,
-0.021179182454943657,
0.0547422431409359,
0.029121486470103264,
-0.007843895815312862,
0.0408187173306942,
0.05113065242767334,
-0.026044759899377823,
-0.020... | 0.838965 | 0.784889 | 0.054076 |
Please write the following solution using ANSI C:
You are given two **0-indexed** integer arrays `nums1` and `nums2` of length `n`.
A range `[l, r]` (**inclusive**) where `0 <= l <= r < n` is **balanced** if:
* For every `i` in the range `[l, r]`, you pick either `nums1[i]` or `nums2[i]`.
* The sum of the numbers... | dolphin | [
0.02215675823390484,
0.026038672775030136,
-0.03138788044452667,
-0.031000614166259766,
0.038551922887563705,
-0.014125102199614048,
-0.03469095751643181,
0.0779150053858757,
0.03454912081360817,
-0.027111291885375977,
0.02330806665122509,
0.03330260142683983,
-0.04446199908852577,
-0.0297... | 0.848519 | 0.780896 | 0.067623 |
Please write the following solution using Clojure:
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_ `n... | dolphin | [
0.011922838166356087,
0.05062394589185715,
-0.02971036732196808,
-0.03211558237671852,
0.04776517301797867,
-0.0269022099673748,
-0.02919105254113674,
0.036388594657182693,
0.046401139348745346,
-0.006990018766373396,
0.03285982087254524,
0.029310287907719612,
-0.026529928669333458,
-0.014... | 0.841684 | 0.786142 | 0.055542 |
Please focus on the functionality of this problem and provide code in C#:
Given 2 integers `n` and `start`. Your task is return **any** permutation `p` of `(0,1,2.....,2^n -1)` such that :
* `p[0] = start`
* `p[i]` and `p[i+1]` differ by only one bit in their binary representation.
* `p[0]` and `p[2^n -1]` must ... | dolphin | [
0.030158130452036858,
0.03355678915977478,
-0.013882262632250786,
-0.03035000152885914,
0.02640949748456478,
-0.03873499110341072,
-0.024881793186068535,
0.10373106598854065,
0.03684047982096672,
-0.023505190387368202,
0.03571834787726402,
0.01965300552546978,
-0.035092949867248535,
-0.023... | 0.837024 | 0.781093 | 0.055931 |
Please focus on the functionality of this problem and provide code in Julia:
Given an array `nums` of integers, return _the length of the longest arithmetic subsequence in_ `nums`.
**Note** that:
* A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing ... | dolphin | [
0.024325480684638023,
0.034723348915576935,
-0.030134227126836777,
-0.03428131714463234,
0.04092486575245857,
-0.015286154113709927,
-0.03781149163842201,
0.05667673423886299,
0.04483385384082794,
-0.00618042191490531,
0.012395597994327545,
0.027640938758850098,
-0.028841610997915268,
0.00... | 0.831702 | 0.773332 | 0.058371 |
Please write the following solution using F#:
Given an integer array `nums` and an integer `k`, find three non-overlapping subarrays of length `k` with maximum sum and return them.
Return the result as a list of indices representing the starting position of each interval (**0-indexed**). If there are multiple answers,... | dolphin | [
0.018528053537011147,
0.03415802866220474,
-0.02860882878303528,
-0.04173935577273369,
0.055905263870954514,
-0.010481538251042366,
-0.023897269740700722,
0.049654118716716766,
0.038764238357543945,
-0.010413985699415207,
0.04246221482753754,
0.03204981982707977,
-0.052293095737695694,
-0.... | 0.844901 | 0.788875 | 0.056026 |
Please focus on the algorithm of this problem and provide code in c++:
The **count-and-say** sequence is a sequence of digit strings defined by the recursive formula:
* `countAndSay(1) = "1 "`
* `countAndSay(n)` is the way you would "say " the digit string from `countAndSay(n-1)`, which is then converted into a di... | dolphin | [
0.015375128015875816,
0.01622115634381771,
-0.005488595459610224,
-0.04044298455119133,
0.028358696028590202,
-0.027850227430462837,
-0.033895786851644516,
0.10511375218629837,
0.01652439497411251,
-0.012893687933683395,
0.028800955042243004,
0.058085598051548004,
-0.040963951498270035,
-0... | 0.836734 | 0.781834 | 0.054901 |
Please explain the following problem in detail and provide code in Scheme:
**Balanced** strings are those that have an equal quantity of `'L'` and `'R'` characters.
Given a **balanced** string `s`, split it into some number of substrings such that:
* Each substring is balanced.
Return _the **maximum** number of ba... | dolphin | [
0.021885646507143974,
0.028337182477116585,
-0.03304532170295715,
-0.025005020201206207,
0.03905776888132095,
-0.02799753099679947,
-0.027930378913879395,
0.0439491868019104,
0.016264231875538826,
-0.03045833669602871,
0.016447966918349266,
0.03119695372879505,
-0.03782666474580765,
-0.020... | 0.83843 | 0.78192 | 0.056511 |
Please explain the reasoning behind the following solution and provide code in PHP:
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 giv... | dolphin | [
0.013871343806385994,
0.03583341836929321,
-0.02187218889594078,
-0.012064492329955101,
0.042947642505168915,
-0.01587378792464733,
-0.031220143660902977,
0.05676868185400963,
0.034638404846191406,
-0.006223269738256931,
0.03482174128293991,
0.04218634217977524,
-0.03568430617451668,
-0.01... | 0.840126 | 0.783478 | 0.056648 |
Please explain the reasoning behind the following solution and provide code in Object Pascal:
You are given an `n x n` integer `matrix`. You can do the following operation **any** number of times:
* Choose any two **adjacent** elements of `matrix` and **multiply** each of them by `-1`.
Two elements are considered *... | dolphin | [
0.027193814516067505,
0.024050097912549973,
-0.0277822595089674,
-0.0439700223505497,
0.060699716210365295,
-0.03045421838760376,
-0.011020254343748093,
0.05251149833202362,
0.03425269201397896,
-0.004283831920474768,
0.014883223921060562,
0.03487354889512062,
-0.03359748423099518,
-0.0206... | 0.838158 | 0.784906 | 0.053252 |
Please write the following solution using Julia:
You are given an array `arr` which consists of only zeros and ones, divide the array into **three non-empty parts** such that all of these parts represent the same binary value.
If it is possible, return any `[i, j]` with `i + 1 < j`, such that:
* `arr[0], arr[1], ..... | dolphin | [
0.021965600550174713,
0.03952210769057274,
-0.023954452946782112,
-0.039600443094968796,
0.04659082368016243,
-0.03190162032842636,
-0.030627138912677765,
0.06981649249792099,
0.03299793601036072,
-0.013279649429023266,
0.027056312188506126,
0.0018500159494578838,
-0.03727119415998459,
-0.... | 0.854057 | 0.798359 | 0.055698 |
Please write the following solution using python:
We are playing the Guessing Game. The game will work as follows:
1. I pick a number between `1` and `n`.
2. You guess a number.
3. If you guess the right number, **you win the game**.
4. If you guess the wrong number, then I will tell you whether the number I picke... | dolphin | [
0.0070184567011892796,
0.02371031604707241,
-0.03869067505002022,
-0.016017545014619827,
0.0412592850625515,
-0.03912550210952759,
-0.0388653464615345,
0.035068366676568985,
0.02525433897972107,
-0.026725545525550842,
0.03771403804421425,
0.04522686079144478,
-0.03771794214844704,
-0.01823... | 0.8416 | 0.788074 | 0.053525 |
Please explain the reasoning behind the following solution and provide code in javascript:
You are given an integer `n` representing the length of an unknown array that you are trying to recover. You are also given an array `sums` containing the values of all `2n` **subset sums** of the unknown array (in no particular ... | dolphin | [
0.010382728651165962,
0.022992704063653946,
-0.04019992798566818,
-0.03167647123336792,
0.041465938091278076,
-0.032871659845113754,
-0.012116796337068081,
0.04377033933997154,
0.02511119283735752,
-0.013882163912057877,
0.02252178080379963,
0.03437593951821327,
-0.033800024539232254,
-0.0... | 0.844184 | 0.790491 | 0.053693 |
Please focus on the efficiency of this problem and provide code in Dart:
You are given a binary array `nums` containing only the integers `0` and `1`. Return _the number of **subarrays** in nums that have **more**_ `1`'_s than_ `0`_'s. Since the answer may be very large, return it **modulo**_ `109 + 7`.
A **subarray**... | dolphin | [
0.008862688206136227,
0.026688965037465096,
-0.02159830741584301,
-0.01571628451347351,
0.035156674683094025,
-0.017692619934678078,
-0.050361961126327515,
0.05420661345124245,
0.031604453921318054,
-0.0092104347422719,
0.0209092665463686,
0.0224097091704607,
-0.032483041286468506,
-0.0243... | 0.848217 | 0.790719 | 0.057499 |
Please focus on the functionality of this problem and provide code in Julia:
You are given an integer array `values` where values\[i\] represents the value of the `ith` sightseeing spot. Two sightseeing spots `i` and `j` have a **distance** `j - i` between them.
The score of a pair (`i < j`) of sightseeing spots is `v... | dolphin | [
0.007395080290734768,
0.02165854722261429,
-0.03788771852850914,
-0.019506074488162994,
0.04952868074178696,
-0.020463978871703148,
-0.04597543179988861,
0.03909768909215927,
0.054262906312942505,
-0.010772707872092724,
0.03682612255215645,
0.04580558091402054,
-0.02773129940032959,
0.0086... | 0.833854 | 0.779338 | 0.054517 |
Please write the following solution using python:
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 p... | dolphin | [
0.009438053704798222,
0.0011431588791310787,
-0.02542044036090374,
-0.02624538727104664,
0.0314968004822731,
-0.03771187737584114,
-0.010351241566240788,
0.048225510865449905,
0.027820570394396782,
-0.013043886050581932,
0.02940690703690052,
0.02011082135140896,
-0.03703604266047478,
-0.02... | 0.829701 | 0.773452 | 0.056249 |
Please write the following solution using Kotlin:
Given an `m x n` integers `matrix`, return _the length of the longest increasing path in_ `matrix`.
From each cell, you can either move in four directions: left, right, up, or down. You **may not** move **diagonally** or move **outside the boundary** (i.e., wrap-around... | dolphin | [
0.016587190330028534,
0.02090967446565628,
-0.022153092548251152,
-0.042833514511585236,
0.034054946154356,
-0.04039109870791435,
-0.04043961688876152,
0.052784260362386703,
0.041071970015764236,
-0.022094611078500748,
0.025791550055146217,
0.021267691627144814,
-0.020079318434000015,
-0.0... | 0.834697 | 0.780211 | 0.054486 |
Please write the following solution using Swift:
Given an integer array `nums`, return _the maximum difference between two successive elements in its sorted form_. If the array contains less than two elements, return `0`.
You must write an algorithm that runs in linear time and uses linear extra space.
**Example 1:**... | dolphin | [
0.016975542530417442,
0.01923520490527153,
-0.02155749499797821,
-0.023078342899680138,
0.03899427503347397,
-0.004712664522230625,
-0.046149007976055145,
0.0719909593462944,
0.036840155720710754,
-0.02675950527191162,
0.03408655896782875,
0.03064734861254692,
-0.02744457870721817,
0.00273... | 0.842873 | 0.778511 | 0.064361 |
Please explain the following problem in detail and provide code in java:
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.... | dolphin | [
0.019420433789491653,
0.02277224138379097,
-0.021563341841101646,
-0.013231449760496616,
0.04532807320356369,
-0.04731617495417595,
-0.0181887149810791,
0.02692505344748497,
0.029879990965127945,
-0.015383835881948471,
0.026038523763418198,
0.023749548941850662,
-0.017987431958317757,
-0.0... | 0.831777 | 0.775951 | 0.055826 |
Please focus on the efficiency of this problem and provide code in Mojo:
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 is no **ramp... | dolphin | [
0.023564793169498444,
0.03131736442446709,
-0.024775970727205276,
-0.01579856127500534,
0.03883809596300125,
-0.01832820475101471,
-0.05334628000855446,
0.06692003458738327,
0.03235797584056854,
-0.02640804834663868,
0.02374860644340515,
0.0254961047321558,
-0.02977384254336357,
-0.0164040... | 0.846418 | 0.783881 | 0.062537 |
Please focus on the algorithm of this problem and provide code in c++:
Numbers can be regarded as the product of their factors.
* For example, `8 = 2 x 2 x 2 = 2 x 4`.
Given an integer `n`, return _all possible combinations of its factors_. You may return the answer in **any order**.
**Note** that the factors shou... | dolphin | [
0.04081631451845169,
0.03665313869714737,
-0.0013441769406199455,
-0.01738465391099453,
0.02983585186302662,
-0.0010615730425342917,
-0.030478062108159065,
0.09645543247461319,
0.04408746585249901,
-0.0036708402913063765,
0.01662439852952957,
0.04933224245905876,
-0.044749584048986435,
-0.... | 0.828318 | 0.764029 | 0.064289 |
Please explain the following problem in detail and provide code in Scala:
You are given an array of `n` pairs `pairs` where `pairs[i] = [lefti, righti]` and `lefti < righti`.
A pair `p2 = [c, d]` **follows** a pair `p1 = [a, b]` if `b < c`. A **chain** of pairs can be formed in this fashion.
Return _the length longes... | dolphin | [
0.037069451063871384,
0.03273613378405571,
-0.03085949830710888,
-0.028584890067577362,
0.023722505196928978,
-0.018016137182712555,
-0.022391146048903465,
0.046005018055438995,
0.010953247547149658,
-0.021747805178165436,
0.008763473480939865,
0.040852803736925125,
-0.013757528737187386,
... | 0.839258 | 0.785697 | 0.053561 |
Please write the following solution using Kotlin:
You are given an array of integers `stones` where `stones[i]` is the weight of the `ith` stone.
We are playing a game with the stones. On each turn, we choose the **heaviest two stones** and smash them together. Suppose the heaviest two stones have weights `x` and `y` ... | dolphin | [
0.03730602189898491,
0.031546588987112045,
-0.02508345991373062,
-0.04417549818754196,
0.035103898495435715,
-0.023854047060012817,
-0.025302650406956673,
0.06305558234453201,
0.03449777513742447,
-0.026052791625261307,
0.031046569347381592,
0.027574829757213593,
-0.031121263280510902,
-0.... | 0.84849 | 0.794456 | 0.054033 |
Please write the following solution using Lua:
Given a **0-indexed** integer array `nums` of size `n` and two integers `lower` and `upper`, return _the number of fair pairs_.
A pair `(i, j)` is **fair** if:
* `0 <= i < j < n`, and
* `lower <= nums[i] + nums[j] <= upper`
**Example 1:**
**Input:** nums = \[0,1,7,... | dolphin | [
0.0028973498847335577,
0.031444236636161804,
-0.03406575694680214,
-0.032011423259973526,
0.04610665142536163,
0.008268733508884907,
-0.02343457005918026,
0.05568517744541168,
0.030222034081816673,
-0.027443405240774155,
0.027856986969709396,
0.0352175235748291,
-0.03411189466714859,
-0.03... | 0.848918 | 0.790741 | 0.058177 |
Please explain the following problem in detail and provide code in Scala:
You are given a **0-indexed** integer array `arr` and an integer `k`. The array `arr` is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the previous element o... | dolphin | [
0.006795648485422134,
0.047579169273376465,
-0.027674686163663864,
-0.039632588624954224,
0.045946646481752396,
-0.025774190202355385,
-0.02779301255941391,
0.053904350847005844,
0.022684676572680473,
-0.004519416484981775,
0.027420276775956154,
0.004004233051091433,
-0.011904122307896614,
... | 0.851652 | 0.795041 | 0.056611 |
Please explain the following problem in detail and provide code in Julia:
Given an integer `n`, find a sequence that satisfies all of the following:
* The integer `1` occurs once in the sequence.
* Each integer between `2` and `n` occurs twice in the sequence.
* For every integer `i` between `2` and `n`, the **d... | dolphin | [
0.013390998356044292,
0.03207872435450554,
-0.024567611515522003,
-0.0457305982708931,
0.027527889236807823,
-0.029588967561721802,
-0.04278081655502319,
0.06793132424354553,
0.03379392996430397,
-0.018177563324570656,
0.027074050158262253,
0.037036746740341187,
-0.04143504053354263,
-0.00... | 0.852286 | 0.794519 | 0.057767 |
Please focus on the efficiency of this problem and provide code in c++:
You are given a **positive** integer `n`.
We call an integer `k` fair if the number of **even** digits in `k` is equal to the number of **odd** digits in it.
Return _the **smallest** fair integer that is **greater than or equal** to_ `n`.
**Exam... | dolphin | [
0.006260196678340435,
0.02861838974058628,
-0.014532488770782948,
-0.04991113021969795,
0.018807826563715935,
-0.00853460468351841,
-0.029846521094441414,
0.08798705786466599,
0.05034045875072479,
-0.011412348598241806,
0.02868049405515194,
0.03380555659532547,
-0.03167552873492241,
-0.024... | 0.833945 | 0.778069 | 0.055876 |
Please write the following solution using Scheme:
A **valid cut** in a circle can be:
* A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or
* A cut that is represented by a straight line that touches one point on the edge of the circle an... | dolphin | [
0.01473845262080431,
0.019721122458577156,
-0.0260042455047369,
-0.028046414256095886,
0.0360846221446991,
-0.008936487138271332,
-0.03184846043586731,
0.052547335624694824,
0.015244741924107075,
-0.008662712760269642,
0.028308749198913574,
0.024768417701125145,
-0.03424493595957756,
-0.01... | 0.822267 | 0.761266 | 0.061001 |
Please write the following solution using Lisp:
Given an integer array `nums`, return _an integer array_ `counts` _where_ `counts[i]` _is the number of smaller elements to the right of_ `nums[i]`.
**Example 1:**
**Input:** nums = \[5,2,6,1\]
**Output:** \[2,1,1,0\]
**Explanation:**
To the right of 5 there are **2** s... | dolphin | [
0.01368424016982317,
0.04476378858089447,
-0.021978134289383888,
-0.030836163088679314,
0.02976362034678459,
-0.0060372608713805676,
-0.016559293493628502,
0.05332736670970917,
0.04136322811245918,
-0.0024141198955476284,
0.0283461082726717,
0.029157204553484917,
-0.028563905507326126,
-0.... | 0.838424 | 0.78436 | 0.054064 |
Please focus on the algorithm of this problem and provide code in Haskell:
You are given an integer array `nums` and a **positive** integer `k`.
The **frequency score** of an array is the sum of the **distinct** values in the array raised to the power of their **frequencies**, taking the sum **modulo** `109 + 7`.
* ... | dolphin | [
0.004328766372054815,
0.018429765477776527,
-0.023456187918782234,
-0.018685918301343918,
0.035818979144096375,
-0.03775328770279884,
-0.01750408485531807,
0.03769230470061302,
0.026848888024687767,
-0.002920189406722784,
0.025913091376423836,
0.03293076530098915,
-0.022219201549887657,
0.... | 0.838178 | 0.781773 | 0.056404 |
Please focus on the efficiency of this problem and provide code in Scheme:
Given an integer array `arr` and a target value `target`, return the integer `value` such that when we change all the integers larger than `value` in the given array to be equal to `value`, the sum of the array gets as close as possible (in abso... | dolphin | [
0.02599399723112583,
0.03387265279889107,
-0.03156639635562897,
-0.034009192138910294,
0.0389736071228981,
-0.030056219547986984,
-0.04760032519698143,
0.025660088285803795,
0.04498822242021561,
-0.02106095477938652,
0.0325782336294651,
0.0225912407040596,
-0.03656528890132904,
-0.00067472... | 0.840468 | 0.780288 | 0.06018 |
Please explain the following problem in detail and provide code in Object Pascal:
There is an undirected tree with `n` nodes labeled from `0` to `n - 1`.
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 integer array `edges... | dolphin | [
0.013697008602321148,
0.027268826961517334,
-0.022747861221432686,
-0.027757568284869194,
0.041623931378126144,
-0.02530861832201481,
0.008323872461915016,
0.05568026751279831,
0.04388808831572533,
0.002996909199282527,
0.039547767490148544,
0.016948098316788673,
-0.02214205451309681,
-0.0... | 0.847381 | 0.792778 | 0.054603 |
Please write the following solution using python:
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 combinations are:
2,3,4 (usin... | dolphin | [
0.02032277174293995,
0.02977314032614231,
-0.01961551606655121,
-0.012035632506012917,
0.035423364490270615,
-0.016673125326633453,
-0.03242724388837814,
0.04764198884367943,
0.020851144567131996,
0.00994668249040842,
0.03741347789764404,
0.03444051370024681,
-0.03003835119307041,
-0.03380... | 0.823626 | 0.767012 | 0.056614 |
Please explain the following problem in detail and provide code in Kotlin:
_(This problem is an **interactive problem**.)_
You may recall that an array `arr` is a **mountain array** if and only if:
* `arr.length >= 3`
* There exists some `i` with `0 < i < arr.length - 1` such that:
* `arr[0] < arr[1] < ... ... | dolphin | [
0.024015922099351883,
0.034645192325115204,
-0.018803412094712257,
-0.04795519635081291,
0.02986665815114975,
-0.043867725878953934,
-0.039859361946582794,
0.061276741325855255,
0.031605739146471024,
-0.018700813874602318,
0.018045496195554733,
0.009970827028155327,
-0.023152068257331848,
... | 0.848913 | 0.790772 | 0.058141 |
Please write the following solution using Lua:
You are given two **0-indexed** integer arrays `nums1` and `nums2` of equal length `n` and a positive integer `k`. You must choose a **subsequence** of indices from `nums1` of length `k`.
For chosen indices `i0`, `i1`, ..., `ik - 1`, your **score** is defined as:
* The... | dolphin | [
0.005110636353492737,
0.04158872365951538,
-0.025670897215604782,
-0.039265554398298264,
0.049286674708127975,
-0.021982477977871895,
-0.034551091492176056,
0.04063672572374344,
0.032188259065151215,
-0.016040077432990074,
0.034794148057699203,
0.029357314109802246,
-0.03048018552362919,
-... | 0.849177 | 0.795386 | 0.053791 |
Please write the following solution using Julia:
You are given a **0-indexed** integer array `nums` of length `n`. You are initially standing at index `0`. You can jump from index `i` to index `j` where `i < j` if:
* `nums[i] <= nums[j]` and `nums[k] < nums[i]` for all indexes `k` in the range `i < k < j`, or
* `n... | dolphin | [
0.006362170446664095,
0.029851553961634636,
-0.026575975120067596,
-0.012698120437562466,
0.03636711835861206,
-0.010758999735116959,
-0.031297724694013596,
0.06542979180812836,
0.04100622981786728,
0.0016950215213000774,
0.025030560791492462,
0.027408365160226822,
-0.02864469587802887,
-0... | 0.856481 | 0.799163 | 0.057319 |
Please explain the reasoning behind the following solution and provide code in Swift:
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... | dolphin | [
0.013944779522716999,
0.024498090147972107,
-0.024428334087133408,
-0.028564145788550377,
0.03263099119067192,
-0.01391672994941473,
-0.02060929499566555,
0.05038302764296532,
0.032683126628398895,
-0.013759619556367397,
0.034509990364313126,
0.02239699475467205,
-0.030237652361392975,
-0.... | 0.836891 | 0.783232 | 0.053659 |
Please write the following solution using Lua:
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:**
**Input:** target = 7, nums = \[... | dolphin | [
0.009468440897762775,
0.024135418236255646,
-0.03158944100141525,
-0.03731916472315788,
0.05337384715676308,
-0.007879098877310753,
-0.03095247969031334,
0.03739715367555618,
0.03536625951528549,
-0.013200279325246811,
0.021972429007291794,
0.023783957585692406,
-0.034425247460603714,
-0.0... | 0.851952 | 0.795014 | 0.056938 |
Please explain the following problem in detail and provide code in C#:
You are given a **0-indexed** integer array `nums`.
* The **low** score of `nums` is the minimum value of `|nums[i] - nums[j]|` over all `0 <= i < j < nums.length`.
* The **high** score of `nums` is the maximum value of `|nums[i] - nums[j]|` ov... | dolphin | [
0.0016604101983830333,
0.018725426867604256,
-0.025207187980413437,
-0.013394271954894066,
0.041319988667964935,
-0.044336047023534775,
-0.03720949962735176,
0.08710116147994995,
0.04561741277575493,
-0.008753747679293156,
0.01498781330883503,
0.02193644642829895,
-0.04128953069448471,
-0.... | 0.843228 | 0.780506 | 0.062722 |
Please explain the reasoning behind the following solution and provide code in Visual Basic .NET:
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... | dolphin | [
0.016549427062273026,
0.027242958545684814,
-0.03269821032881737,
-0.034198351204395294,
0.0381559357047081,
-0.029458235949277878,
-0.0063508604653179646,
0.0692325308918953,
0.043199386447668076,
-0.014641476795077324,
0.032425347715616226,
0.04206477105617523,
-0.03320121765136719,
-0.0... | 0.847087 | 0.787081 | 0.060006 |
Please explain the following problem in detail and provide code in python:
You are given a string `s` of length `n` where `s[i]` is either:
* `'D'` means decreasing, or
* `'I'` means increasing.
A permutation `perm` of `n + 1` integers of all the integers in the range `[0, n]` is called a **valid permutation** if... | dolphin | [
0.008661691099405289,
0.019566182047128677,
-0.019978174939751625,
-0.03802298754453659,
0.034817151725292206,
-0.036173973232507706,
-0.024717701599001884,
0.056817829608917236,
0.02042143978178501,
-0.006723544094711542,
0.027597768232226372,
0.026557689532637596,
-0.034478992223739624,
... | 0.853385 | 0.791336 | 0.062049 |
Please write the following solution using ANSI C:
You are given two positive integers `left` and `right` with `left <= right`. Calculate the **product** of all integers in the **inclusive** range `[left, right]`.
Since the product may be very large, you will **abbreviate** it following these steps:
1. Count all **tr... | dolphin | [
0.02937300130724907,
0.04133392497897148,
-0.030154837295413017,
-0.0306293573230505,
0.03247395530343056,
-0.02694956213235855,
-0.026220934465527534,
0.08601053804159164,
0.04350448027253151,
-0.014681736007332802,
0.014923042617738247,
0.029811082407832146,
-0.035653386265039444,
-0.044... | 0.839349 | 0.78167 | 0.057679 |
Please focus on the efficiency of this problem and provide code in javascript:
Given an array of positive integers `arr` (not necessarily distinct), return _the_ _lexicographically_ _largest permutation that is smaller than_ `arr`, that can be **made with exactly one swap**. If it cannot be done, then return the same a... | dolphin | [
0.022339988499879837,
0.04159281775355339,
-0.01839325949549675,
-0.027330240234732628,
0.03055724874138832,
-0.021181978285312653,
-0.03256641700863838,
0.04124603420495987,
0.03031057119369507,
-0.04493454471230507,
0.029633639380335808,
0.008859921246767044,
-0.0337870717048645,
-0.0171... | 0.836621 | 0.783184 | 0.053437 |
Please write the following solution using C#:
You are given an array `nums` of non-negative integers. `nums` is considered **special** if there exists a number `x` such that there are **exactly** `x` numbers in `nums` that are **greater than or equal to** `x`.
Notice that `x` **does not** have to be an element in `num... | dolphin | [
0.014071926474571228,
0.026082105934619904,
-0.01993214152753353,
-0.018708258867263794,
0.03570609539747238,
-0.034692659974098206,
-0.023842353373765945,
0.08844739943742752,
0.04622964188456535,
-0.01709217205643654,
0.02369004115462303,
0.023178281262516975,
-0.044412724673748016,
-0.0... | 0.846446 | 0.793155 | 0.053291 |
Please write the following solution using F#:
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. However, we only care about th... | dolphin | [
0.017445608973503113,
0.043609414249658585,
-0.009220913052558899,
-0.04765724763274193,
0.04168163612484932,
-0.03198859468102455,
-0.021088527515530586,
0.04724949225783348,
0.04569678008556366,
-0.011810259893536568,
0.026830298826098442,
0.016588667407631874,
-0.03270430117845535,
-0.0... | 0.850015 | 0.795916 | 0.054099 |
Please explain the following problem in detail and provide code in Objective-C:
You are given an integer array `nums`. The _value_ of this array is defined as the sum of `|nums[i] - nums[i + 1]|` for all `0 <= i < nums.length - 1`.
You are allowed to select any subarray of the given array and reverse it. You can perfo... | dolphin | [
0.021920127794146538,
0.045972105115652084,
-0.01901194080710411,
-0.0158273596316576,
0.036757662892341614,
-0.02992900460958481,
-0.029739560559391975,
0.06671275198459625,
0.031822703778743744,
-0.0038994967471808195,
0.03296433016657829,
0.031792644411325455,
-0.04671880602836609,
-0.0... | 0.836194 | 0.773766 | 0.062428 |
Please write the following solution using java:
Given a string `s`, return _the number of **homogenous** substrings of_ `s`_._ Since the answer may be too large, return it **modulo** `109 + 7`.
A string is **homogenous** if all the characters of the string are the same.
A **substring** is a contiguous sequence of cha... | dolphin | [
0.02064647153019905,
0.008051406592130661,
-0.03393511846661568,
-0.030582085251808167,
0.0504273995757103,
-0.050961125642061234,
-0.011941146105527878,
0.040451645851135254,
0.02324160560965538,
-0.019006967544555664,
0.019949179142713547,
0.029675010591745377,
-0.038320645689964294,
-0.... | 0.830066 | 0.773669 | 0.056397 |
Please focus on the efficiency of this problem and provide code in Objective-C:
Given an integer array `arr` and an integer `difference`, return the length of the longest subsequence in `arr` which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals `difference`.
A **... | dolphin | [
0.036620043218135834,
0.020237494260072708,
-0.025154704228043556,
-0.038195714354515076,
0.03003685735166073,
-0.025917695835232735,
-0.043958261609077454,
0.07273318618535995,
0.04996209591627121,
-0.01908043958246708,
0.031274426728487015,
0.005349479150027037,
-0.03118896484375,
0.0065... | 0.835627 | 0.77274 | 0.062887 |
Please explain the reasoning behind the following solution and provide code in R:
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 beaut... | dolphin | [
0.006793169770389795,
0.04552920535206795,
-0.03245266154408455,
-0.03151958808302879,
0.048056431114673615,
-0.02338983863592148,
-0.04137985035777092,
0.05121832340955734,
0.04722394049167633,
0.0010363045148551464,
0.017894554883241653,
0.032360076904296875,
-0.03522059693932533,
-0.004... | 0.836272 | 0.780515 | 0.055758 |
Please explain the following problem in detail and provide code in Fortran:
Given an integer array `nums` and an integer `k`, return _the number of **good** subarrays of_ `nums`.
A subarray `arr` is **good** if it there are **at least** `k` pairs of indices `(i, j)` such that `i < j` and `arr[i] == arr[j]`.
A **subar... | dolphin | [
0.019616322591900826,
0.025014806538820267,
-0.037255849689245224,
-0.026237450540065765,
0.04207487031817436,
-0.01552265603095293,
-0.030586501583456993,
0.04193369299173355,
0.029814092442393303,
0.0035270238295197487,
0.015270273201167583,
0.02745535969734192,
-0.01603715866804123,
-0.... | 0.838192 | 0.783707 | 0.054484 |
Please write the following solution using ANSI C:
Given two integers `num1` and `num2`, return _the **sum** of the two integers_.
**Example 1:**
**Input:** num1 = 12, num2 = 5
**Output:** 17
**Explanation:** num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.
**Example 2:**
**Input:** num1 = -10... | dolphin | [
0.006213610526174307,
0.00662402156740427,
-0.01507951132953167,
-0.0385359451174736,
0.038896866142749786,
0.0017201084410771728,
-0.021472422406077385,
0.06806871294975281,
0.03691580519080162,
-0.016536645591259003,
0.016820194199681282,
0.039642974734306335,
-0.053793080151081085,
-0.0... | 0.799347 | 0.743125 | 0.056222 |
Please explain the following problem in detail and provide code in Kotlin:
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 app... | dolphin | [
0.022215450182557106,
0.02689594030380249,
-0.013689391314983368,
-0.017141392454504967,
0.040410786867141724,
-0.01595759391784668,
-0.016290584579110146,
0.0519835464656353,
0.03171543776988983,
0.008339188061654568,
0.0211621280759573,
0.02195090614259243,
-0.012880127876996994,
-0.0015... | 0.839888 | 0.778325 | 0.061564 |
Please write the following solution using Fortran:
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`, choose four **distinct** indices `w... | dolphin | [
0.03385306894779205,
0.03581641614437103,
-0.0181037075817585,
-0.022538747638463974,
0.06151939928531647,
-0.007949662394821644,
-0.051371823996305466,
0.058762747794389725,
0.04685518890619278,
-0.009464237838983536,
0.022180795669555664,
0.041203487664461136,
-0.035223059356212616,
-0.0... | 0.844683 | 0.785508 | 0.059175 |
Please explain the reasoning behind the following solution and provide code in java:
Given a **0-indexed** integer array `nums` of size `n`, find the **maximum difference** between `nums[i]` and `nums[j]` (i.e., `nums[j] - nums[i]`), such that `0 <= i < j < n` and `nums[i] < nums[j]`.
Return _the **maximum difference*... | dolphin | [
0.027196576818823814,
0.024842320010066032,
-0.029435595497488976,
-0.01679631695151329,
0.04662884399294853,
-0.031892843544483185,
-0.041601069271564484,
0.04651821404695511,
0.036115121096372604,
-0.027719072997570038,
0.0378839373588562,
0.025463657453656197,
-0.042142223566770554,
0.0... | 0.840349 | 0.77859 | 0.061759 |
Please write the following solution using Julia:
You are given two integer arrays `nums1` and `nums2` of equal length `n` and an integer `k`. You can perform the following operation on `nums1`:
* Choose two indexes `i` and `j` and increment `nums1[i]` by `k` and decrement `nums1[j]` by `k`. In other words, `nums1[i]... | dolphin | [
0.013746186159551144,
0.03588219732046127,
-0.03580598905682564,
-0.0410204716026783,
0.03892352059483528,
-0.025544116273522377,
-0.011188941076397896,
0.08519335091114044,
0.045179374516010284,
-0.02405506931245327,
0.017637761309742928,
-0.0009394221124239266,
-0.026394618675112724,
0.0... | 0.853977 | 0.799222 | 0.054756 |
Please explain the following problem in detail and provide code in c++:
You are given a positive integer **0-indexed** array `nums`.
A subset of the array `nums` is **square-free** if the product of its elements is a **square-free integer**.
A **square-free integer** is an integer that is divisible by no square numbe... | dolphin | [
0.026892978698015213,
0.03963571786880493,
-0.03447777032852173,
-0.030296746641397476,
0.058955758810043335,
-0.013831033371388912,
-0.02754978835582733,
0.09424243867397308,
0.0482269786298275,
-0.012495220638811588,
0.027555303648114204,
0.01494425255805254,
-0.03853033110499382,
-0.032... | 0.845819 | 0.779983 | 0.065836 |
Please write the following solution using Julia:
Given two integer arrays `nums1` and `nums2`, return _the maximum length of a subarray that appears in **both** arrays_.
**Example 1:**
**Input:** nums1 = \[1,2,3,2,1\], nums2 = \[3,2,1,4,7\]
**Output:** 3
**Explanation:** The repeated subarray with maximum length is \... | dolphin | [
0.010794191621243954,
0.020210837945342064,
-0.02836526744067669,
-0.029301842674613,
0.03812069445848465,
-0.013910654932260513,
-0.042151372879743576,
0.041321102529764175,
0.04515175148844719,
-0.029093042016029358,
0.024799451231956482,
0.02197650820016861,
-0.027416424825787544,
-0.00... | 0.83117 | 0.768447 | 0.062723 |
Please explain the reasoning behind the following solution and provide code in python:
Given an array of integers `nums` and an integer `k`. A continuous subarray is called **nice** if there are `k` odd numbers on it.
Return _the number of **nice** sub-arrays_.
**Example 1:**
**Input:** nums = \[1,1,2,1,1\], k = 3
*... | dolphin | [
0.013644509948790073,
0.03864545375108719,
-0.03999553620815277,
-0.018558116629719734,
0.04367939382791519,
-0.016685036942362785,
-0.033611591905355453,
0.03814423456788063,
0.03011380508542061,
0.001169758033938706,
0.032631851732730865,
0.00753801828250289,
-0.03825920820236206,
-0.001... | 0.837395 | 0.780708 | 0.056687 |
Please focus on the efficiency of this problem and provide code in Kotlin:
Given an array of integers `arr`, return `true` if we can partition the array into three **non-empty** parts with equal sums.
Formally, we can partition the array if we can find indexes `i + 1 < j` with `(arr[0] + arr[1] + ... + arr[i] == arr[i... | dolphin | [
0.024976469576358795,
0.017210258170962334,
-0.025632962584495544,
-0.029052140191197395,
0.03332489728927612,
-0.019241293892264366,
-0.013772493228316307,
0.0641011893749237,
0.017833296209573746,
-0.021273566409945488,
0.01802782528102398,
0.012929290533065796,
-0.03641480952501297,
-0.... | 0.843903 | 0.78748 | 0.056423 |
Please write the following solution using ANSI C:
You are given two integer arrays `nums1` and `nums2` sorted in **ascending order** and an integer `k`.
Define a pair `(u, v)` which consists of one element from the first array and one element from the second array.
Return _the_ `k` _pairs_ `(u1, v1), (u2, v2), ..., (... | dolphin | [
0.015905557200312614,
0.05138001963496208,
-0.01043428760021925,
-0.04550696164369583,
0.03952997177839279,
-0.007195574231445789,
-0.02076868712902069,
0.07953307032585144,
0.03648003563284874,
-0.0225081667304039,
0.03938288614153862,
0.02689283713698387,
-0.02738850750029087,
-0.0120602... | 0.846506 | 0.781427 | 0.065079 |
Please explain the following problem in detail and provide code in Elixir:
You are given a **0-indexed** integer array `nums` and an integer `value`.
In one operation, you can add or subtract `value` from any element of `nums`.
* For example, if `nums = [1,2,3]` and `value = 2`, you can choose to subtract `value` f... | dolphin | [
0.03604893013834953,
0.026704125106334686,
-0.01932581700384617,
-0.028910795226693153,
0.03825445845723152,
-0.023275865241885185,
-0.023129144683480263,
0.050717759877443314,
0.03923700377345085,
-0.0201711542904377,
0.024930234998464584,
0.03592221438884735,
-0.02565780095756054,
-0.011... | 0.854279 | 0.800643 | 0.053637 |
Please explain the following problem in detail and provide code in Go:
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.020283393561840057,
0.02282261662185192,
-0.022938396781682968,
-0.006838512606918812,
0.03134645149111748,
-0.029315439984202385,
-0.03518500179052353,
0.05653119087219238,
0.051930803805589676,
-0.01274976134300232,
0.02973063290119171,
0.018026940524578094,
-0.04055660590529442,
-0.01... | 0.841172 | 0.78494 | 0.056232 |
Please write the following solution using Mojo:
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:**
**Inp... | dolphin | [
0.014168365858495235,
0.031161637976765633,
-0.030647175386548042,
-0.03206612914800644,
0.048139918595552444,
-0.007941276766359806,
-0.03121647611260414,
0.04056110605597496,
0.03825121000409126,
-0.0026968789752572775,
0.029915085062384605,
0.025554312393069267,
-0.03282805532217026,
-0... | 0.83927 | 0.775467 | 0.063803 |
Please write the following solution using Dart:
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.010255926288664341,
0.023094628006219864,
-0.029613159596920013,
-0.02439403347671032,
0.035239748656749725,
-0.022836551070213318,
-0.031028905883431435,
0.05463926121592522,
0.03233011066913605,
-0.003104578470811248,
0.01960575580596924,
0.022411882877349854,
-0.017856651917099953,
0.... | 0.843451 | 0.784833 | 0.058618 |
Please focus on the algorithm of this problem and provide code in PHP:
You are given a **0-indexed** integer array `nums`. In one operation, you may do the following:
* Choose **two** integers in `nums` that are **equal**.
* Remove both integers from `nums`, forming a **pair**.
The operation is done on `nums` as ... | dolphin | [
0.014804530888795853,
0.030737854540348053,
-0.023261575028300285,
-0.01452761609107256,
0.03510411083698273,
-0.03142452985048294,
-0.025657564401626587,
0.08957815915346146,
0.048384152352809906,
-0.02164873480796814,
0.01605709083378315,
0.024428825825452805,
-0.02791057527065277,
-0.02... | 0.853901 | 0.798304 | 0.055597 |
Please write the following solution using Swift:
You are given a **0-indexed** integer array `nums` consisting of `n` non-negative integers.
You are also given an array `queries`, where `queries[i] = [xi, yi]`. The answer to the `ith` query is the sum of all `nums[j]` where `xi <= j < n` and `(j - xi)` is divisible by... | dolphin | [
0.010967236012220383,
0.021797820925712585,
-0.03828442096710205,
-0.028297701850533485,
0.04652266949415207,
-0.02372795157134533,
-0.03057684376835823,
0.055424947291612625,
0.048272375017404556,
-0.015164859592914581,
0.030375607311725616,
0.01760309562087059,
-0.05203996226191521,
-0.0... | 0.850877 | 0.797605 | 0.053272 |
Please write the following solution using java:
A sequence of numbers is called an **arithmetic progression** if the difference between any two consecutive elements is the same.
Given an array of numbers `arr`, return `true` _if the array can be rearranged to form an **arithmetic progression**. Otherwise, return_ `fal... | dolphin | [
0.04418712481856346,
0.029504302889108658,
-0.01320758555084467,
-0.04276421293616295,
0.01901511661708355,
-0.015544502064585686,
0.0003135294537059963,
0.08365600556135178,
0.02591528557240963,
-0.037976305931806564,
0.012291974388062954,
-0.004298248793929815,
-0.028803719207644463,
-0.... | 0.825636 | 0.768077 | 0.057558 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.