instruction_seed stringlengths 308 3.48k | source stringclasses 1
value | embeddings listlengths 1.02k 1.02k | mean_positive_score float64 0.8 0.86 | mean_negative_score float64 0.74 0.8 | difference_score float64 0.05 0.07 |
|---|---|---|---|---|---|
Please explain the following problem in detail and provide code in ANSI C:
You are given a positive integer `num`. You may swap any two digits of `num` that have the same **parity** (i.e. both odd digits or both even digits).
Return _the **largest** possible value of_ `num` _after **any** number of swaps._
**Example ... | dolphin | [
0.0352504700422287,
0.027721574530005455,
-0.014206609688699245,
-0.039214156568050385,
0.0027079798746854067,
-0.014148854650557041,
-0.038428712636232376,
0.056162405759096146,
0.025413785129785538,
-0.017674339935183525,
0.030794933438301086,
0.030868083238601685,
-0.057505637407302856,
... | 0.834231 | 0.770732 | 0.063499 |
Please write the following solution using java:
You are given an integer array `nums` and an integer `k`. You want to find a **subsequence** of `nums` of length `k` that has the **largest** sum.
Return _**any** such subsequence as an integer array of length_ `k`.
A **subsequence** is an array that can be derived from... | dolphin | [
0.02416297420859337,
0.045977916568517685,
-0.028275081887841225,
-0.04230785742402077,
0.04660214111208916,
-0.00662663858383894,
-0.02014737017452717,
0.03432361036539078,
0.02741459384560585,
-0.019812200218439102,
0.03653866797685623,
0.03276894986629486,
-0.043855033814907074,
0.00346... | 0.83018 | 0.761623 | 0.068557 |
Please write the following solution using Swift:
You are given an array of integers `nums` **(0-indexed)** and an integer `k`.
The **score** of a subarray `(i, j)` is defined as `min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1)`. A **good** subarray is a subarray where `i <= k <= j`.
Return _the maximum possible *... | dolphin | [
0.011292035691440105,
0.03129906579852104,
-0.03475033864378929,
-0.03278724104166031,
0.053489167243242264,
-0.025653492659330368,
-0.04040206968784332,
0.044918425381183624,
0.03535552695393562,
-0.0051898593083024025,
0.021686023101210594,
0.014934001490473747,
-0.02355770207941532,
0.0... | 0.846663 | 0.781523 | 0.06514 |
Please explain the reasoning behind the following solution and provide code in PHP:
You are given an integer array `nums`. The **range** of a subarray of `nums` is the difference between the largest and smallest element in the subarray.
Return _the **sum of all** subarray ranges of_ `nums`_._
A subarray is a contiguo... | dolphin | [
0.00564839830622077,
0.03643234819173813,
-0.040729865431785583,
-0.01621568202972412,
0.05398394912481308,
-0.017812080681324005,
-0.04738950356841087,
0.04843313246965408,
0.037824857980012894,
-0.0002665231004357338,
0.027271421626210213,
0.04229726269841194,
-0.05163361132144928,
-0.01... | 0.831961 | 0.774424 | 0.057537 |
Please write the following solution using Swift:
You are given an integer array `nums` of `2 * n` integers. You need to partition `nums` into **two** arrays of length `n` to **minimize the absolute difference** of the **sums** of the arrays. To partition `nums`, put each element of `nums` into **one** of the two arrays... | dolphin | [
0.023181654512882233,
0.019000183790922165,
-0.023699715733528137,
-0.01987837255001068,
0.034676387906074524,
-0.008599787019193172,
-0.029501963406801224,
0.03851344808936119,
0.05469478666782379,
-0.020300056785345078,
0.019725129008293152,
0.02068173512816429,
-0.03975103050470352,
0.0... | 0.836058 | 0.781805 | 0.054253 |
Please write the following solution using Scheme:
You are given two integer arrays `nums1` and `nums2` both of the same length. The **advantage** of `nums1` with respect to `nums2` is the number of indices `i` for which `nums1[i] > nums2[i]`.
Return _any permutation of_ `nums1` _that maximizes its **advantage** with r... | dolphin | [
0.02676250971853733,
0.023831646889448166,
-0.017402246594429016,
-0.028607971966266632,
0.02826123684644699,
-0.021961931139230728,
-0.038339562714099884,
0.06194920837879181,
0.0389864444732666,
-0.021256616339087486,
0.012738390825688839,
0.021179120987653732,
-0.04223429411649704,
-0.0... | 0.830059 | 0.758368 | 0.07169 |
Please write the following solution using Scala:
You are given a 2D `matrix` of size `m x n`, consisting of non-negative integers. You are also given an integer `k`.
The **value** of coordinate `(a, b)` of the matrix is the XOR of all `matrix[i][j]` where `0 <= i <= a < m` and `0 <= j <= b < n` **(0-indexed)**.
Find ... | dolphin | [
0.04333820939064026,
0.04230816662311554,
-0.028170902281999588,
-0.04021758213639259,
0.04755396395921707,
-0.03968115523457527,
-0.01924939826130867,
0.04502781853079796,
0.03467130288481712,
-0.016862569376826286,
0.025900116190314293,
0.023939575999975204,
-0.0246182382106781,
-0.00376... | 0.842729 | 0.786412 | 0.056317 |
Please focus on the efficiency of this problem and provide code in python:
The **array-form** of an integer `num` is an array representing its digits in left to right order.
* For example, for `num = 1321`, the array form is `[1,3,2,1]`.
Given `num`, the **array-form** of an integer, and an integer `k`, return _the... | dolphin | [
0.03626522049307823,
0.05402981862425804,
-0.03573461249470711,
-0.05670462176203728,
0.031218010932207108,
-0.02216411754488945,
-0.021138465031981468,
0.049843981862068176,
0.03417306765913963,
0.00009937539289239794,
0.03313605114817619,
0.03226552903652191,
-0.04424719884991646,
-0.015... | 0.8361 | 0.777511 | 0.05859 |
Please explain the following problem in detail and provide code in Visual Basic .NET:
Given an array `nums` of **distinct** positive integers, return _the number of tuples_ `(a, b, c, d)` _such that_ `a * b = c * d` _where_ `a`_,_ `b`_,_ `c`_, and_ `d` _are elements of_ `nums`_, and_ `a != b != c != d`_._
**Example 1:... | dolphin | [
0.02765999361872673,
0.030036427080631256,
-0.026618825271725655,
-0.02118999883532524,
0.04427091032266617,
-0.03128557279706001,
-0.006934538949280977,
0.08657927811145782,
0.04174775630235672,
-0.013185149058699608,
0.013631688430905342,
0.023737341165542603,
-0.04126201197504997,
-0.03... | 0.846194 | 0.791834 | 0.05436 |
Please explain the following problem in detail and provide code in R:
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
**Explanation:** ... | dolphin | [
0.013587403111159801,
0.02745232731103897,
-0.03268909454345703,
-0.035695191472768784,
0.05152326822280884,
-0.01730845682322979,
0.0013135425979271531,
0.06797604262828827,
0.018245980143547058,
-0.004815913736820221,
0.021644368767738342,
0.01903444156050682,
-0.02954523079097271,
-0.00... | 0.830048 | 0.767405 | 0.062643 |
Please focus on the efficiency of this problem and provide code in Scheme:
The **array-form** of an integer `num` is an array representing its digits in left to right order.
* For example, for `num = 1321`, the array form is `[1,3,2,1]`.
Given `num`, the **array-form** of an integer, and an integer `k`, return _the... | dolphin | [
0.035621605813503265,
0.05522976443171501,
-0.028665877878665924,
-0.05780138447880745,
0.036410484462976456,
-0.027967039495706558,
-0.024791527539491653,
0.04480074346065521,
0.0413021482527256,
-0.0021223491057753563,
0.02938329614698887,
0.030990449711680412,
-0.04507032409310341,
-0.0... | 0.835587 | 0.775735 | 0.059852 |
Please explain the following problem in detail and provide code in R:
You are given a **0-indexed** integer array `nums` and an integer `value`.
In one operation, you can add or subtract `value` from any element of `nums`.
* For example, if `nums = [1,2,3]` and `value = 2`, you can choose to subtract `value` from `... | dolphin | [
0.032593242824077606,
0.028897853568196297,
-0.030273832380771637,
-0.019625406712293625,
0.05189182236790657,
-0.014552687294781208,
-0.03361982852220535,
0.06282556056976318,
0.04452648386359215,
-0.014733507297933102,
0.010873210616409779,
0.03752777352929115,
-0.03553641587495804,
-0.0... | 0.840525 | 0.784273 | 0.056252 |
Please write the following solution using Scheme:
There are `n` students in a class numbered from `0` to `n - 1`. The teacher will give each student a problem starting with the student number `0`, then the student number `1`, and so on until the teacher reaches the student number `n - 1`. After that, the teacher will r... | dolphin | [
0.03686727583408356,
0.045693155378103256,
-0.014430736191570759,
-0.04704129695892334,
0.040337491780519485,
-0.046866800636053085,
-0.026546195149421692,
0.06227856129407883,
0.027023326605558395,
-0.02163580060005188,
0.03384159505367279,
0.01961173117160797,
-0.03467670828104019,
-0.00... | 0.854649 | 0.799753 | 0.054896 |
Please explain the following problem in detail and provide code in ANSI C:
You are given an **integer** array `pref` of size `n`. Find and return _the array_ `arr` _of size_ `n` _that satisfies_:
* `pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]`.
Note that `^` denotes the **bitwise-xor** operation.
It can be proven tha... | dolphin | [
0.03448772057890892,
0.040073737502098083,
-0.006764686666429043,
-0.03588389232754707,
0.011073392815887928,
-0.043388575315475464,
-0.0163953248411417,
0.08708737045526505,
0.04342586547136307,
-0.02809632197022438,
0.03238058090209961,
0.010637475177645683,
-0.04250037670135498,
-0.0423... | 0.843273 | 0.788127 | 0.055146 |
Please explain the following problem in detail and provide code in javascript:
Given an integer `n`, break it into the sum of `k` **positive integers**, where `k >= 2`, and maximize the product of those integers.
Return _the maximum product you can get_.
**Example 1:**
**Input:** n = 2
**Output:** 1
**Explanation:**... | dolphin | [
0.03186918422579765,
0.03243812173604965,
-0.03193124383687973,
-0.029000218957662582,
0.03253887593746185,
-0.009921954944729805,
-0.018609659746289253,
0.061788011342287064,
0.03340141102671623,
-0.006190482527017593,
0.025983406230807304,
0.03603346273303032,
-0.04202407971024513,
-0.01... | 0.841555 | 0.785411 | 0.056143 |
Please write the following solution using Swift:
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** integers in `nums`.
* ... | dolphin | [
0.025066541507840157,
0.03409014269709587,
-0.024437615647912025,
-0.021698664873838425,
0.03728724271059036,
-0.025266971439123154,
-0.035387832671403885,
0.061854615807533264,
0.042897969484329224,
-0.021076930686831474,
0.028884166851639748,
0.023955432698130608,
-0.02519301511347294,
-... | 0.849818 | 0.791953 | 0.057865 |
Please write the following solution using Go:
The **alternating sum** of a **0-indexed** array is defined as the **sum** of the elements at **even** indices **minus** the **sum** of the elements at **odd** indices.
* For example, the alternating sum of `[4,2,5,3]` is `(4 + 5) - (2 + 3) = 4`.
Given an array `nums`, ... | dolphin | [
0.006947067100554705,
0.02308434247970581,
-0.007690618745982647,
-0.025258038192987442,
0.02655833773314953,
-0.02362080104649067,
-0.03548280894756317,
0.05079948902130127,
0.05015292763710022,
-0.010502313263714314,
0.011934390291571617,
0.009693506173789501,
-0.05635295808315277,
-0.00... | 0.833897 | 0.77349 | 0.060407 |
Please focus on the efficiency of this problem and provide code in Julia:
You are given an integer array `banned` and two integers `n` and `maxSum`. You are choosing some number of integers following the below rules:
* The chosen integers have to be in the range `[1, n]`.
* Each integer can be chosen **at most onc... | dolphin | [
0.028591083362698555,
0.02561499923467636,
-0.03414836898446083,
-0.02111872285604477,
0.026659822091460228,
-0.028966868296265602,
-0.04021315276622772,
0.04377090930938721,
0.03271084278821945,
-0.005388154648244381,
0.01679818145930767,
0.03268768638372421,
-0.038513824343681335,
-0.014... | 0.848206 | 0.794491 | 0.053715 |
Please explain the following problem in detail and provide code in python:
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, `pre... | dolphin | [
0.012261567637324333,
0.02503979578614235,
-0.014582542702555656,
-0.02569158375263214,
0.024431245401501656,
-0.01140625774860382,
-0.0318835973739624,
0.031173743307590485,
0.02509707398712635,
0.006613276433199644,
0.011193862184882164,
0.02072637900710106,
-0.042327284812927246,
0.0020... | 0.84288 | 0.783928 | 0.058952 |
Please write the following solution using java:
You are given a 2D integer array `intervals` where `intervals[i] = [lefti, righti]` represents the **inclusive** interval `[lefti, righti]`.
You have to divide the intervals into one or more **groups** such that each interval is in **exactly** one group, and no two inter... | dolphin | [
0.040817029774188995,
0.024847064167261124,
-0.03906533122062683,
-0.019885381683707237,
0.045027557760477066,
-0.017151465639472008,
-0.03399552032351494,
0.04167893901467323,
0.02212812565267086,
-0.02470855414867401,
0.02315707504749298,
0.004456049762666225,
-0.030143188312649727,
-0.0... | 0.840597 | 0.780838 | 0.059758 |
Please write the following solution using R:
You are given an integer array `nums` and a **positive** integer `k`.
The **frequency score** of an array is the sum of the **distinct** values in the array raised to the power of their **frequencies**, taking the sum **modulo** `109 + 7`.
* For example, the frequency sc... | dolphin | [
0.012379859574139118,
0.03408984839916229,
-0.03577744588255882,
-0.03117183782160282,
0.03833245486021042,
-0.02862768992781639,
-0.03413324058055878,
0.03297171741724014,
0.021606430411338806,
0.004888191819190979,
0.021287886425852776,
0.029469966888427734,
-0.03600461781024933,
0.01294... | 0.827012 | 0.762407 | 0.064605 |
Please explain the following problem in detail and provide code in java:
Given a **directed acyclic graph**, with `n` vertices numbered from `0` to `n-1`, and an array `edges` where `edges[i] = [fromi, toi]` represents a directed edge from node `fromi` to node `toi`.
Find _the smallest set of vertices from which all n... | dolphin | [
0.0174272358417511,
0.03870930150151253,
-0.01819435879588127,
-0.024447515606880188,
0.033190131187438965,
-0.044343702495098114,
-0.016906613484025,
0.03878692910075188,
0.03142260015010834,
-0.013030724599957466,
0.030250167474150658,
0.022028950974345207,
-0.01384434849023819,
-0.00851... | 0.843181 | 0.784938 | 0.058242 |
Please explain the reasoning behind the following solution and provide code in java:
Given an `m x n` binary matrix `mat`, return _the length of the longest line of consecutive one in the matrix_.
The line could be horizontal, vertical, diagonal, or anti-diagonal.
**Example 1:**
**Input:** mat = \[\[0,1,1,0\],\[0,1,... | dolphin | [
0.01648683287203312,
0.009429926052689552,
-0.028198394924402237,
-0.05378923937678337,
0.04252893850207329,
-0.03396852687001228,
-0.04845357686281204,
0.05921776592731476,
0.042939335107803345,
-0.026069993153214455,
0.02832743339240551,
0.01885843463242054,
-0.020400885492563248,
-0.018... | 0.834732 | 0.779257 | 0.055476 |
Please write the following solution using c++:
Given an array `nums` of positive integers, return the longest possible length of an array prefix of `nums`, such that it is possible to remove **exactly one** element from this prefix so that every number that has appeared in it will have the same number of occurrences.
... | dolphin | [
0.023404570296406746,
0.01497843861579895,
-0.027663156390190125,
-0.029339978471398354,
0.028523840010166168,
-0.02200368605554104,
-0.038072776049375534,
0.08492191880941391,
0.042858343571424484,
-0.015651335939764977,
0.012196976691484451,
0.010596712119877338,
-0.010293720290064812,
-... | 0.84659 | 0.776561 | 0.070029 |
Please focus on the algorithm of this problem and provide code in c++:
You are in a city that consists of `n` intersections numbered from `0` to `n - 1` with **bi-directional** roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there ... | dolphin | [
0.022134754806756973,
0.009530605748295784,
-0.011832878924906254,
-0.008062316104769707,
0.03188903257250786,
0.006545381620526314,
-0.04976310580968857,
0.0858410894870758,
0.049532465636730194,
-0.00816567987203598,
0.025180047377943993,
0.04878975450992584,
-0.011094875633716583,
-0.02... | 0.838434 | 0.78291 | 0.055523 |
Please write the following solution using Scheme:
You are given two strings `firstString` and `secondString` that are **0-indexed** and consist only of lowercase English letters. Count the number of index quadruples `(i,j,a,b)` that satisfy the following conditions:
* `0 <= i <= j < firstString.length`
* `0 <= a <... | dolphin | [
0.009923985227942467,
0.019849497824907303,
-0.018473008647561073,
-0.025383641943335533,
0.051235754042863846,
-0.026607010513544083,
-0.022436516359448433,
0.05416347086429596,
0.04072409123182297,
-0.020497983321547508,
0.0193476602435112,
0.0003588435356505215,
-0.03095811977982521,
-0... | 0.844908 | 0.790295 | 0.054612 |
Please focus on the efficiency of this problem and provide code in Go:
You are given an integer `n`. You roll a fair 6-sided dice `n` times. Determine the total number of **distinct** sequences of rolls possible such that the following conditions are satisfied:
1. The **greatest common divisor** of any **adjacent** v... | dolphin | [
0.014057951048016548,
0.023446086794137955,
-0.009432184509932995,
-0.032488513737916946,
0.026722388342022896,
-0.025205647572875023,
-0.03822961822152138,
0.0662756934762001,
0.03611744940280914,
-0.008053961209952831,
0.03254517912864685,
0.020532216876745224,
-0.03355979919433594,
-0.0... | 0.84185 | 0.787091 | 0.054759 |
Please write the following solution using Dart:
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 for all valid `i`:
* If... | dolphin | [
0.003405250608921051,
0.01713559962809086,
-0.013565564528107643,
-0.038207292556762695,
0.03540351986885071,
-0.028044050559401512,
-0.0288307573646307,
0.06588970124721527,
0.034223347902297974,
-0.015056374482810497,
0.02311212755739689,
0.027859073132276535,
-0.03230469301342964,
-0.01... | 0.8582 | 0.800544 | 0.057656 |
Please focus on the algorithm of this problem and provide code in javascript:
The **score** of an array is defined as the **product** of its sum and its length.
* For example, the score of `[1, 2, 3, 4, 5]` is `(1 + 2 + 3 + 4 + 5) * 5 = 75`.
Given a positive integer array `nums` and an integer `k`, return _the **nu... | dolphin | [
-0.009331055916845798,
0.026577191427350044,
-0.025468088686466217,
-0.012374348007142544,
0.047242213040590286,
-0.018536966294050217,
-0.03333533555269241,
0.050394028425216675,
0.016862083226442337,
0.0028371692169457674,
0.024054378271102905,
0.01636255346238613,
-0.03890480473637581,
... | 0.840012 | 0.782748 | 0.057264 |
Please focus on the efficiency of this problem and provide code in C#:
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 the smallest... | dolphin | [
0.027647625654935837,
0.02361486665904522,
-0.0420844703912735,
-0.011327924206852913,
0.012986602261662483,
-0.016211995854973793,
-0.02752421237528324,
0.08584164083003998,
0.03743978589773178,
-0.008939831517636776,
0.020338362082839012,
0.025276387110352516,
-0.028859330341219902,
-0.0... | 0.847494 | 0.785555 | 0.061939 |
Please focus on the functionality of this problem and provide code in Objective-C:
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 cha... | dolphin | [
0.03668990358710289,
0.03291182592511177,
-0.024728193879127502,
-0.028757749125361443,
0.041638005524873734,
-0.021012989804148674,
-0.041973307728767395,
0.06477174907922745,
0.031105130910873413,
-0.013781724497675896,
0.019445957615971565,
0.0171288400888443,
-0.03914607688784599,
-0.0... | 0.826687 | 0.764854 | 0.061832 |
Please write the following solution using Ruby:
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 `nums[i] - nums[i+1] + num... | dolphin | [
0.022609606385231018,
0.03578713908791542,
-0.027660053223371506,
-0.04090730473399162,
0.032659053802490234,
-0.022738512605428696,
-0.0340532548725605,
0.050315771251916885,
0.04250415787100792,
-0.025525594130158424,
0.039500053972005844,
0.014926968142390251,
-0.04824603721499443,
-0.0... | 0.832107 | 0.777869 | 0.054238 |
Please write the following solution using Scheme:
Given an integer array `arr`, and an integer `target`, return the number of tuples `i, j, k` such that `i < j < k` and `arr[i] + arr[j] + arr[k] == target`.
As the answer can be very large, return it **modulo** `109 + 7`.
**Example 1:**
**Input:** arr = \[1,1,2,2,3,3... | dolphin | [
0.0357542522251606,
0.02714245207607746,
-0.03910278528928757,
-0.030821263790130615,
0.04970303177833557,
-0.0152738681063056,
-0.042619988322257996,
0.047342415899038315,
0.023993518203496933,
-0.008808985352516174,
0.02469176985323429,
0.019517673179507256,
-0.041807349771261215,
-0.015... | 0.848284 | 0.786864 | 0.06142 |
Please write the following solution using Scheme:
Given an array `nums` sorted in **non-decreasing** order, return _the maximum between the number of positive integers and the number of negative integers._
* In other words, if the number of positive integers in `nums` is `pos` and the number of negative integers is ... | dolphin | [
0.028661251068115234,
0.007924465462565422,
-0.035134244710206985,
-0.012880298309028149,
0.021127257496118546,
-0.016550879925489426,
-0.05339905619621277,
0.03433268517255783,
0.03100830689072609,
-0.009735872969031334,
0.019084922969341278,
0.04117060452699661,
-0.027663791552186012,
-0... | 0.839739 | 0.77648 | 0.063259 |
Please write the following solution using Kotlin:
You are given a **0-indexed** integer array `nums`. You are also given an integer `key`, which is present in `nums`.
For every unique integer `target` in `nums`, **count** the number of times `target` immediately follows an occurrence of `key` in `nums`. In other words... | dolphin | [
0.030848590657114983,
0.024120889604091644,
-0.027307037264108658,
-0.01671399176120758,
0.03876461833715439,
-0.013418540358543396,
-0.037524666637182236,
0.059431739151477814,
0.026635507121682167,
-0.013297973200678825,
0.01988045684993267,
0.01404266245663166,
-0.027437971904873848,
0.... | 0.852716 | 0.790128 | 0.062589 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
Given an array of integers `arr`, return `true` _if the number of occurrences of each value in the array is **unique** or_ `false` _otherwise_.
**Example 1:**
**Input:** arr = \[1,2,2,1,1,3\]
**Output:** true
**Explanation:** The v... | dolphin | [
0.0085455859079957,
0.020619049668312073,
-0.028593648225069046,
-0.02052575908601284,
0.0445549376308918,
-0.03244444727897644,
-0.015878884121775627,
0.08478835970163345,
0.035384103655815125,
-0.027970749884843826,
0.017275841906666756,
-0.004319386091083288,
-0.018840843811631203,
-0.0... | 0.831362 | 0.773436 | 0.057926 |
Please explain the following problem in detail and provide code in PHP:
Given an integer array `nums` of **unique** elements, return _all possible_ _subsets_ _(the power set)_.
The solution set **must not** contain duplicate subsets. Return the solution in **any order**.
**Example 1:**
**Input:** nums = \[1,2,3\]
**... | dolphin | [
0.03741420805454254,
0.03138958662748337,
-0.012589619494974613,
-0.010186596773564816,
0.04448562115430832,
-0.037325385957956314,
-0.012034161947667599,
0.056567877531051636,
0.059218645095825195,
-0.01250503771007061,
0.03812294080853462,
0.022320641204714775,
-0.04723074659705162,
-0.0... | 0.837243 | 0.779361 | 0.057882 |
Please explain the following problem in detail and provide code in PHP:
Given an integer `numRows`, return the first numRows of **Pascal's triangle**.
In **Pascal's triangle**, each number is the sum of the two numbers directly above it as shown:
**Example 1:**
**Input:** numRows = 5
**Output:** \[\[1\],\[1,1\],\[1,... | dolphin | [
0.023284632712602615,
0.04159126430749893,
-0.03142967447638512,
-0.0323818065226078,
0.04133090749382973,
-0.016435330733656883,
-0.010855085216462612,
0.06572088599205017,
0.04693349823355675,
0.006130133289843798,
0.03403808921575546,
0.028202706947922707,
-0.034661807119846344,
-0.0227... | 0.830502 | 0.776322 | 0.05418 |
Please explain the following problem in detail and provide code in java:
You are given an integer array `nums`.
In one move, you can choose one element of `nums` and change it to **any value**.
Return _the minimum difference between the largest and smallest value of `nums` **after performing at most three moves**_.
... | dolphin | [
0.01750188134610653,
0.029230792075395584,
-0.027812369167804718,
-0.025342723354697227,
0.04075484350323677,
-0.027715075761079788,
-0.03161926195025444,
0.052796538919210434,
0.027085984125733376,
-0.024391980841755867,
0.04374239221215248,
0.025972630828619003,
-0.040741704404354095,
-0... | 0.847484 | 0.784773 | 0.062711 |
Please write the following solution using java:
An **alphabetical continuous string** is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string `"abcdefghijklmnopqrstuvwxyz "`.
* For example, `"abc "` is an alphabetical continuous string, while `"acb "` and `"za... | dolphin | [
0.017773063853383064,
0.018419742584228516,
-0.004564378876239061,
-0.03508765622973442,
0.04575169086456299,
-0.046125274151563644,
-0.025959402322769165,
0.036873720586299896,
0.026714053004980087,
-0.03661607950925827,
0.029790222644805908,
0.016322607174515724,
-0.026424378156661987,
-... | 0.816601 | 0.762893 | 0.053709 |
Please write the following solution using R:
Given a rectangle of size `n` x `m`, return _the minimum number of integer-sided squares that tile the rectangle_.
**Example 1:**
**Input:** n = 2, m = 3
**Output:** 3
**Explanation:** `3` squares are necessary to cover the rectangle.
`2` (squares of `1x1`)
`1` (square of ... | dolphin | [
0.02132958546280861,
0.04400350898504257,
-0.026847822591662407,
-0.043175313621759415,
0.04059910029172897,
-0.01881646364927292,
-0.029192635789513588,
0.05422911420464516,
0.028293143957853317,
0.008217878639698029,
0.023338453844189644,
0.031334660947322845,
-0.03646078333258629,
-0.03... | 0.823982 | 0.767937 | 0.056045 |
Please write the following solution using c++:
You are given an undirected graph. You are given an integer `n` which is the number of nodes in the graph and an array `edges`, where each `edges[i] = [ui, vi]` indicates that there is an undirected edge between `ui` and `vi`.
A **connected trio** is a set of **three** no... | dolphin | [
0.015557387843728065,
0.018977737054228783,
-0.021983424201607704,
-0.034312404692173004,
0.04151511937379837,
-0.017178747802972794,
-0.02190319634974003,
0.0751689225435257,
0.022421224042773247,
0.005093102343380451,
0.04007547348737717,
0.0303870290517807,
-0.015782667323946953,
-0.032... | 0.835293 | 0.77629 | 0.059003 |
Please explain the following problem in detail and provide code in ANSI C:
There are two mice and `n` different types of cheese, each type of cheese should be eaten by exactly one mouse.
A point of the cheese with index `i` (**0-indexed**) is:
* `reward1[i]` if the first mouse eats it.
* `reward2[i]` if the secon... | dolphin | [
0.016817543655633926,
0.03942598029971123,
-0.006668929010629654,
-0.028902385383844376,
0.014785687439143658,
-0.010881740599870682,
-0.030483584851026535,
0.07167423516511917,
0.025836104527115822,
-0.020717084407806396,
0.034366022795438766,
0.03282710164785385,
-0.044129740446805954,
-... | 0.847496 | 0.78403 | 0.063466 |
Please explain the following problem in detail and provide code in Scheme:
Given an integer `n`, your task is to count how many strings of length `n` can be formed under the following rules:
* Each character is a lower case vowel (`'a'`, `'e'`, `'i'`, `'o'`, `'u'`)
* Each vowel `'a'` may only be followed by an `'e... | dolphin | [
0.027565093711018562,
0.02672111988067627,
-0.005996380932629108,
-0.02662155218422413,
0.03431946784257889,
-0.03663591668009758,
-0.025685805827379227,
0.06301886588335037,
0.02103874459862709,
-0.007019050419330597,
0.03127974644303322,
0.031007898971438408,
-0.022451797500252724,
-0.03... | 0.848003 | 0.790989 | 0.057014 |
Please explain the following problem in detail and provide code in java:
Given `n` points on a 1-D plane, where the `ith` point (from `0` to `n-1`) is at `x = i`, find the number of ways we can draw **exactly** `k` **non-overlapping** line segments such that each segment covers two or more points. The endpoints of each... | dolphin | [
0.012956822291016579,
0.03735194355249405,
-0.03324848413467407,
-0.03204448148608208,
0.024808362126350403,
-0.020911194384098053,
-0.02065451815724373,
0.042551714926958084,
0.0351271778345108,
-0.02834598906338215,
0.036634862422943115,
0.048492394387722015,
-0.018100153654813766,
-0.01... | 0.844675 | 0.786749 | 0.057926 |
Please write the following solution using PHP:
You are given an `m x n` integer matrix `matrix` with the following two properties:
* Each row is sorted in non-decreasing order.
* The first integer of each row is greater than the last integer of the previous row.
Given an integer `target`, return `true` _if_ `targ... | dolphin | [
0.027645381167531013,
0.023285942152142525,
-0.031445395201444626,
-0.03509862348437309,
0.051632482558488846,
-0.027234116569161415,
-0.022947320714592934,
0.07791230827569962,
0.03545700013637543,
-0.02695142850279808,
0.01438254863023758,
0.013439741916954517,
-0.030627908185124397,
-0.... | 0.844643 | 0.79127 | 0.053373 |
Please explain the reasoning behind the following solution and provide code in PHP:
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.008024634793400764,
0.028965886682271957,
-0.029069606214761734,
-0.022672485560178757,
0.050474099814891815,
-0.019487038254737854,
-0.033457089215517044,
0.055852629244327545,
0.04384348541498184,
-0.004640479106456041,
0.01572829857468605,
0.0260059405118227,
-0.03743154555559158,
-0.... | 0.850532 | 0.796705 | 0.053827 |
Please focus on the efficiency of this problem and provide code in Go:
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** subs... | dolphin | [
0.004466493148356676,
0.041546549648046494,
-0.024596549570560455,
-0.025058021768927574,
0.03952348604798317,
-0.026600705459713936,
-0.039699044078588486,
0.053926318883895874,
0.0550072006881237,
-0.001688014017418027,
0.026619810611009598,
0.023425107821822166,
-0.031204713508486748,
-... | 0.84608 | 0.792388 | 0.053692 |
Please write the following solution using Mojo:
Given an array of integers `arr`, a **lucky integer** is an integer that has a frequency in the array equal to its value.
Return _the largest **lucky integer** in the array_. If there is no **lucky integer** return `-1`.
**Example 1:**
**Input:** arr = \[2,2,3,4\]
**Ou... | dolphin | [
0.03357015550136566,
0.05002836138010025,
-0.02261294238269329,
-0.03992796316742897,
0.022594889625906944,
0.0012806665617972612,
-0.04454062506556511,
0.042685139924287796,
0.025578847154974937,
-0.02807539887726307,
0.024112101644277573,
0.026189805939793587,
-0.025043904781341553,
-0.0... | 0.82542 | 0.762018 | 0.063402 |
Please explain the reasoning behind the following solution and provide code in Groovy:
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... | dolphin | [
0.016394490376114845,
0.012372858822345734,
-0.026578491553664207,
-0.0348169207572937,
0.03794087842106819,
-0.030207274481654167,
-0.0382252037525177,
0.048207126557826996,
0.04248365759849548,
-0.025912482291460037,
0.027488818392157555,
0.03284510225057602,
-0.030727656558156013,
0.009... | 0.837568 | 0.782103 | 0.055465 |
Please write the following solution using Swift:
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
**Output:** 1
**Constrain... | dolphin | [
0.018443942070007324,
0.024109866470098495,
-0.04855252057313919,
-0.026988252997398376,
0.040396567434072495,
-0.03176400437951088,
-0.014137247577309608,
0.038872960954904556,
0.04301457852125168,
-0.009780011139810085,
0.02408774197101593,
0.02462146058678627,
-0.03576093167066574,
-0.0... | 0.835834 | 0.776899 | 0.058936 |
Please focus on the functionality of this problem and provide code in C#:
Given an array `nums` of size `n`, return _the majority element_.
The majority element is the element that appears more than `⌊n / 2⌋` times. You may assume that the majority element always exists in the array.
**Example 1:**
**Input:** nums =... | dolphin | [
0.010584352537989616,
0.02793486975133419,
-0.035932011902332306,
-0.016115035861730576,
0.034747615456581116,
-0.0382450632750988,
-0.0236846711486578,
0.08585141599178314,
0.03347071632742882,
-0.004650156479328871,
0.020434971898794174,
0.02149214781820774,
-0.02217119000852108,
-0.0086... | 0.844343 | 0.785754 | 0.058589 |
Please explain the following problem in detail and provide code in Swift:
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:... | dolphin | [
0.026186248287558556,
0.03815464675426483,
-0.02111685834825039,
-0.03325929865241051,
0.05367127060890198,
-0.02882128767669201,
-0.030162369832396507,
0.06464821100234985,
0.029561297968029976,
-0.01962617225944996,
0.03352375701069832,
-0.003899873699992895,
-0.03664759173989296,
-0.029... | 0.845601 | 0.792338 | 0.053262 |
Please explain the following problem in detail and provide code in COBOL:
You have a graph of `n` nodes. You are given an integer `n` and an array `edges` where `edges[i] = [ai, bi]` indicates that there is an edge between `ai` and `bi` in the graph.
Return _the number of connected components in the graph_.
**Example... | dolphin | [
0.028234461322426796,
0.02088571898639202,
-0.03994172438979149,
-0.021026598289608955,
0.020410412922501564,
-0.023485897108912468,
-0.012042573653161526,
0.04704452306032181,
0.0346439853310585,
0.0036338032223284245,
0.030843036249279976,
0.013224916532635689,
-0.023647820577025414,
-0.... | 0.8428 | 0.779708 | 0.063092 |
Please write the following solution using Groovy:
The **frequency** of an element is the number of times it occurs in an array.
You are given an integer array `nums` and an integer `k`. In one operation, you can choose an index of `nums` and increment the element at that index by `1`.
Return _the **maximum possible f... | dolphin | [
0.017567060887813568,
0.03666991367936134,
-0.020638732239603996,
-0.03277340531349182,
0.03956995904445648,
-0.014776648953557014,
-0.01858014613389969,
0.055129729211330414,
0.019828978925943375,
-0.0013180467067286372,
0.030684497207403183,
0.020900750532746315,
-0.029273752123117447,
0... | 0.840469 | 0.786939 | 0.05353 |
Please write the following solution using Dart:
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 longest chain which can be forme... | dolphin | [
0.039092767983675,
0.02587945945560932,
-0.03149973973631859,
-0.035088300704956055,
0.017960507422685623,
-0.009153163991868496,
-0.031827282160520554,
0.05263350531458855,
0.027733054012060165,
-0.024299342185258865,
0.005551252514123917,
0.03549762815237045,
-0.01641848497092724,
-0.012... | 0.841034 | 0.784242 | 0.056791 |
Please explain the following problem in detail and provide code in Scheme:
You are painting a fence of `n` posts with `k` different colors. You must paint the posts following these rules:
* Every post must be painted **exactly one** color.
* There **cannot** be three or more **consecutive** posts with the same col... | dolphin | [
0.018729317933321,
0.03859952092170715,
-0.011157060042023659,
-0.02430349960923195,
0.03300775587558746,
-0.03830985352396965,
-0.031180916354060173,
0.06018292158842087,
0.03341667726635933,
-0.01091024186462164,
0.044450946152210236,
0.050259195268154144,
-0.008187610656023026,
-0.00502... | 0.840043 | 0.786656 | 0.053387 |
Please write the following solution using ANSI C:
There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of `n` nodes numbered from `0` to `n - 1` and exactly `n - 1` edges. Each node has a value associated with it, and the **root** of the tree is node `0`.
To represent this tree, you are ... | dolphin | [
0.025851894170045853,
0.039574019610881805,
-0.022565383464097977,
-0.03349289670586586,
0.01875033788383007,
-0.027966495603322983,
0.00195319508202374,
0.08465457707643509,
0.03370581567287445,
-0.021708615124225616,
0.039673589169979095,
0.008960473351180553,
-0.02534669078886509,
-0.01... | 0.848748 | 0.786793 | 0.061955 |
Please write the following solution using C#:
You are given two positive integers `n` and `k`. A factor of an integer `n` is defined as an integer `i` where `n % i == 0`.
Consider a list of all factors of `n` sorted in **ascending order**, return _the_ `kth` _factor_ in this list or return `-1` if `n` has less than `k... | dolphin | [
0.03500823304057121,
0.05521054565906525,
-0.023466743528842926,
-0.030690830200910568,
0.02990545704960823,
-0.02283037267625332,
-0.008960568346083164,
0.07792866230010986,
0.03779825568199158,
-0.009549406357109547,
0.015963565558195114,
0.030572429299354553,
-0.04589255899190903,
-0.01... | 0.836502 | 0.778869 | 0.057633 |
Please write the following solution using python:
A **square triple** `(a,b,c)` is a triple where `a`, `b`, and `c` are **integers** and `a2 + b2 = c2`.
Given an integer `n`, return _the number of **square triples** such that_ `1 <= a, b, c <= n`.
**Example 1:**
**Input:** n = 5
**Output:** 2
**Explanation**: The sq... | dolphin | [
0.02399475686252117,
0.0359601229429245,
-0.03997064754366875,
-0.03745340183377266,
0.035890646278858185,
-0.008426541462540627,
-0.026026658713817596,
0.04478026553988457,
0.006269566249102354,
0.013517128303647041,
0.018543923273682594,
0.032155077904462814,
-0.060732029378414154,
-0.03... | 0.824303 | 0.765186 | 0.059117 |
Please write the following solution using Swift:
Given an array `nums` of positive integers, return the longest possible length of an array prefix of `nums`, such that it is possible to remove **exactly one** element from this prefix so that every number that has appeared in it will have the same number of occurrences.... | dolphin | [
0.02228098176419735,
0.01995857246220112,
-0.0316232331097126,
-0.030970850959420204,
0.03306414186954498,
-0.031574662774801254,
-0.04014214873313904,
0.05508287996053696,
0.04082074388861656,
-0.01416552159935236,
0.0135862547904253,
0.0003101314650848508,
-0.012551209889352322,
-0.01944... | 0.845916 | 0.780234 | 0.065681 |
Please explain the following problem in detail and provide code in Rust:
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]... | dolphin | [
0.022002074867486954,
0.03177613392472267,
-0.014502852223813534,
-0.02902194857597351,
0.03523588553071022,
-0.01227647252380848,
-0.041879016906023026,
0.05071486532688141,
0.027811594307422638,
0.0017085629515349865,
0.020956678315997124,
0.018702086061239243,
-0.03686903417110443,
-0.0... | 0.84199 | 0.788218 | 0.053772 |
Please focus on the functionality of this problem and provide code in ANSI C:
Given a **(0-indexed)** integer array `nums` and two integers `low` and `high`, return _the number of **nice pairs**_.
A **nice pair** is a pair `(i, j)` where `0 <= i < j < nums.length` and `low <= (nums[i] XOR nums[j]) <= high`.
**Example... | dolphin | [
0.012193822301924229,
0.020500263199210167,
-0.03842166066169739,
-0.00836924184113741,
0.03304356336593628,
-0.010685339570045471,
-0.044314607977867126,
0.06426749378442764,
0.029605943709611893,
-0.012177111580967903,
0.025960424914956093,
0.02566663734614849,
-0.049287330359220505,
-0.... | 0.846032 | 0.782676 | 0.063356 |
Please explain the following problem in detail and provide code in Haskell:
An array is **squareful** if the sum of every pair of adjacent elements is a **perfect square**.
Given an integer array nums, return _the number of permutations of_ `nums` _that are **squareful**_.
Two permutations `perm1` and `perm2` are dif... | dolphin | [
0.0074171749874949455,
0.03766779229044914,
-0.016651306301355362,
-0.03154037147760391,
0.04732534661889076,
-0.024194734171032906,
-0.013698865659534931,
0.054778803139925,
0.030732719227671623,
-0.016142992302775383,
0.01457451656460762,
0.012392501346766949,
-0.03126092255115509,
-0.03... | 0.839414 | 0.785464 | 0.05395 |
Please write the following solution using ANSI C:
The **XOR sum** of a list is the bitwise `XOR` of all its elements. If the list only contains one element, then its **XOR sum** will be equal to this element.
* For example, the **XOR sum** of `[1,2,3,4]` is equal to `1 XOR 2 XOR 3 XOR 4 = 4`, and the **XOR sum** of ... | dolphin | [
0.012468709610402584,
0.032562777400016785,
-0.025691403076052666,
-0.03922607749700546,
0.0314861461520195,
-0.016764063388109207,
-0.03398403897881508,
0.07669422030448914,
0.04148268699645996,
-0.01776394248008728,
0.014377908781170845,
0.01683296635746956,
-0.03668026626110077,
-0.0285... | 0.832672 | 0.770693 | 0.061979 |
Please write the following solution using python:
Given an array `nums` and an integer `target`, return _the maximum number of **non-empty** **non-overlapping** subarrays such that the sum of values in each subarray is equal to_ `target`.
**Example 1:**
**Input:** nums = \[1,1,1,1,1\], target = 2
**Output:** 2
**Expl... | dolphin | [
0.03133261576294899,
0.01915818639099598,
-0.04157521575689316,
-0.020430872216820717,
0.05602218210697174,
0.00846872292459011,
-0.03608905151486397,
0.02140801027417183,
0.014386383816599846,
-0.011907557025551796,
0.03213512524962425,
0.03315284848213196,
-0.03612809628248215,
-0.022620... | 0.838247 | 0.773523 | 0.064724 |
Please explain the reasoning behind the following solution and provide code in ANSI C:
Given two integer arrays `arr1` and `arr2`, and the integer `d`, _return the distance value between the two arrays_.
The distance value is defined as the number of elements `arr1[i]` such that there is not any element `arr2[j]` wher... | dolphin | [
0.0177820585668087,
0.029206037521362305,
-0.025075053796172142,
-0.04320334270596504,
0.03928094357252121,
-0.027164513245224953,
-0.04758179187774658,
0.07413530349731445,
0.05039486289024353,
-0.031182080507278442,
0.02944277599453926,
0.028349975124001503,
-0.04201122745871544,
-0.0023... | 0.826132 | 0.772631 | 0.053501 |
Please write the following solution using Julia:
You are given an array `nums` consisting of **positive** integers.
We call a subarray of `nums` **nice** if the bitwise **AND** of every pair of elements that are in **different** positions in the subarray is equal to `0`.
Return _the length of the **longest** nice sub... | dolphin | [
0.012036322616040707,
0.015588990412652493,
-0.04105770215392113,
-0.016748813912272453,
0.04099813848733902,
-0.025769773870706558,
-0.04543164744973183,
0.039900071918964386,
0.031376417726278305,
-0.006221116986125708,
0.03686930984258652,
0.025237422436475754,
-0.036918554455041885,
-0... | 0.849595 | 0.782028 | 0.067567 |
Please write the following solution using Scala:
Given a string `s`, find _the longest palindromic **subsequence**'s length in_ `s`.
A **subsequence** is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
**Example 1:**
**Input:*... | dolphin | [
0.014807237312197685,
0.008694875985383987,
-0.014174990355968475,
-0.032401517033576965,
0.02788742259144783,
-0.04122455045580864,
-0.006768738850951195,
0.03474768251180649,
0.030996182933449745,
-0.014419916085898876,
0.02456883154809475,
0.028013063594698906,
-0.02003185637295246,
-0.... | 0.830149 | 0.774847 | 0.055301 |
Please write the following solution using Dart:
Given an integer array `nums`, return _the **maximum possible sum** of elements of the array such that it is divisible by three_.
**Example 1:**
**Input:** nums = \[3,6,5,1,8\]
**Output:** 18
**Explanation:** Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divis... | dolphin | [
0.015013978816568851,
0.020283512771129608,
-0.01987425796687603,
-0.035091519355773926,
0.05417327955365181,
-0.02748924493789673,
-0.02897343412041664,
0.03894151747226715,
0.028266170993447304,
0.004668969660997391,
0.030378585681319237,
0.04193917661905289,
-0.04052861034870148,
-0.023... | 0.82822 | 0.772203 | 0.056018 |
Please focus on the efficiency of this problem and provide code in Swift:
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**._ If no s... | dolphin | [
0.02737683802843094,
0.023648014292120934,
-0.024897562339901924,
-0.016640448942780495,
0.04578443989157677,
-0.022593418136239052,
-0.05010209605097771,
0.05808889865875244,
0.04952473193407059,
-0.029048554599285126,
0.03940354287624359,
0.020509708672761917,
-0.03945029526948929,
0.007... | 0.840318 | 0.783369 | 0.056949 |
Please focus on the efficiency of this problem and provide code in ANSI C:
You are given two integer arrays `nums1` and `nums2` both of the same length. The **advantage** of `nums1` with respect to `nums2` is the number of indices `i` for which `nums1[i] > nums2[i]`.
Return _any permutation of_ `nums1` _that maximizes... | dolphin | [
0.021207859739661217,
0.03283443674445152,
-0.01795625127851963,
-0.02703234925866127,
0.011823026463389397,
-0.02056986838579178,
-0.04798182100057602,
0.08334276080131531,
0.03945900872349739,
-0.032384391874074936,
0.025719862431287766,
0.023847101256251335,
-0.04078178480267525,
-0.022... | 0.83865 | 0.77326 | 0.06539 |
Please explain the following problem in detail and provide code in c++:
You have `n` `tiles`, where each tile has one letter `tiles[i]` printed on it.
Return _the number of possible non-empty sequences of letters_ you can make using the letters printed on those `tiles`.
**Example 1:**
**Input:** tiles = "AAB "
**Ou... | dolphin | [
0.03048076666891575,
0.01806497387588024,
0.009069586172699928,
-0.013950925320386887,
0.03830510377883911,
-0.018884899094700813,
-0.024066152051091194,
0.09490755945444107,
0.029636016115546227,
-0.006348207127302885,
0.04253939166665077,
0.03878672793507576,
-0.04003380984067917,
-0.018... | 0.831929 | 0.771512 | 0.060417 |
Please focus on the algorithm of this problem and provide code in PHP:
You are given an integer array `nums` and an integer `k`. You may partition `nums` into one or more **subsequences** such that each element in `nums` appears in **exactly** one of the subsequences.
Return _the **minimum** number of subsequences nee... | dolphin | [
0.019711997359991074,
0.01865454576909542,
-0.02547389641404152,
0.0008673521806485951,
0.031235119327902794,
-0.011832953430712223,
-0.03051074966788292,
0.07594171911478043,
0.03074321337044239,
-0.0053705135360360146,
0.0336797721683979,
0.02992790937423706,
-0.028452077880501747,
0.010... | 0.845285 | 0.783614 | 0.061671 |
Please explain the following problem in detail and provide code in java:
Given an integer array `nums` and an integer `k`, return _the_ `k` _most frequent elements_. You may return the answer in **any order**.
**Example 1:**
**Input:** nums = \[1,1,1,2,2,3\], k = 2
**Output:** \[1,2\]
**Example 2:**
**Input:** nums... | dolphin | [
0.023284005001187325,
0.0441865399479866,
-0.03182430565357208,
-0.017229823395609856,
0.04240168631076813,
-0.03151141107082367,
-0.022218184545636177,
0.045147426426410675,
0.020252462476491928,
-0.007899060845375061,
0.03740963712334633,
0.00722153065726161,
-0.01390092819929123,
0.0069... | 0.833899 | 0.768422 | 0.065476 |
Please explain the following problem in detail and provide code in C#:
You are given `n` `points` in the plane that are all **distinct**, where `points[i] = [xi, yi]`. A **boomerang** is a tuple of points `(i, j, k)` such that the distance between `i` and `j` equals the distance between `i` and `k` **(the order of the ... | dolphin | [
0.008062684908509254,
0.03404778242111206,
-0.02560623362660408,
-0.02918478660285473,
0.02630169317126274,
-0.025942150503396988,
-0.0261261984705925,
0.07955550402402878,
0.05033888295292854,
-0.003138936823233962,
0.004202030133455992,
0.04201354458928108,
-0.02682083658874035,
-0.02433... | 0.843313 | 0.784813 | 0.0585 |
Please explain the following problem in detail and provide code in Swift:
You are given three positive integers: `n`, `index`, and `maxSum`. You want to construct an array `nums` (**0-indexed**) that satisfies the following conditions:
* `nums.length == n`
* `nums[i]` is a **positive** integer where `0 <= i < n`.
... | dolphin | [
0.026014868170022964,
0.023979129269719124,
-0.02755453996360302,
-0.027239196002483368,
0.05294346809387207,
-0.023541854694485664,
-0.045085418969392776,
0.046788353472948074,
0.03879106789827347,
-0.012935290113091469,
0.041587602347135544,
0.02955147996544838,
-0.0438416451215744,
-0.0... | 0.837806 | 0.777492 | 0.060314 |
Please write the following solution using Objective-C:
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 the smallest possible size.
... | dolphin | [
0.02812948077917099,
0.02918766811490059,
-0.03614082187414169,
-0.01826062612235546,
0.025723794475197792,
-0.009725693613290787,
-0.03108523227274418,
0.06652515381574631,
0.02949567884206772,
-0.00997306127101183,
0.026718709617853165,
0.02217625081539154,
-0.029006578028202057,
-0.0216... | 0.843523 | 0.776803 | 0.06672 |
Please focus on the efficiency of this problem and provide code in Scala:
You have an array `arr` of length `n` where `arr[i] = (2 * i) + 1` for all valid values of `i` (i.e., `0 <= i < n`).
In one operation, you can select two indices `x` and `y` where `0 <= x, y < n` and subtract `1` from `arr[x]` and add `1` to `ar... | dolphin | [
0.028391335159540176,
0.025128183886408806,
-0.031739458441734314,
-0.04296046122908592,
0.028013484552502632,
-0.03707338497042656,
-0.02326001040637493,
0.06309690326452255,
0.02296774834394455,
-0.026109959930181503,
0.023206466808915138,
0.0208281259983778,
-0.010970281437039375,
-0.02... | 0.846453 | 0.792168 | 0.054284 |
Please focus on the efficiency of this problem and provide code in Scheme:
A permutation `perm` of `n + 1` integers of all the integers in the range `[0, n]` can be represented as a string `s` of length `n` where:
* `s[i] == 'I'` if `perm[i] < perm[i + 1]`, and
* `s[i] == 'D'` if `perm[i] > perm[i + 1]`.
Given a ... | dolphin | [
0.022715048864483833,
0.021037045866250992,
-0.009612858295440674,
-0.03213054686784744,
0.010700144805014133,
-0.04528263211250305,
-0.02334788627922535,
0.0525716170668602,
0.026213468983769417,
-0.013996190391480923,
0.03363107517361641,
0.01670295000076294,
-0.028800111263990402,
-0.01... | 0.843197 | 0.784986 | 0.058211 |
Please explain the reasoning behind the following solution and provide code in Visual Basic .NET:
Given a set of **distinct** positive integers `nums`, return the largest subset `answer` such that every pair `(answer[i], answer[j])` of elements in this subset satisfies:
* `answer[i] % answer[j] == 0`, or
* `answer... | dolphin | [
0.036389898508787155,
0.025416936725378036,
-0.034123118966817856,
-0.02561548724770546,
0.03676098212599754,
-0.02804347686469555,
0.000708749343175441,
0.08190497010946274,
0.046546366065740585,
-0.016565464437007904,
0.03288590908050537,
0.02467448264360428,
-0.0354636125266552,
-0.0174... | 0.849115 | 0.789334 | 0.059781 |
Please write the following solution using javascript:
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] - nu... | dolphin | [
0.005034183617681265,
0.03379957750439644,
-0.030925709754228592,
-0.02630625292658806,
0.0539352186024189,
-0.009367496706545353,
-0.022545278072357178,
0.06226794049143791,
0.050008874386548996,
-0.007503559347242117,
0.021410174667835236,
-0.00591073464602232,
-0.024121085181832314,
0.0... | 0.83678 | 0.777505 | 0.059275 |
Please write the following solution using Swift:
The **min-product** of an array is equal to the **minimum value** in the array **multiplied by** the array's **sum**.
* For example, the array `[3,2,5]` (minimum value is `2`) has a min-product of `2 * (3+2+5) = 2 * 10 = 20`.
Given an array of integers `nums`, return... | dolphin | [
0.0246935673058033,
0.028538599610328674,
-0.02960561215877533,
-0.02408568188548088,
0.06501682847738266,
-0.018240265548229218,
-0.04159341752529144,
0.054863445460796356,
0.03563293069601059,
-0.014529149048030376,
0.02558548003435135,
0.01693599857389927,
-0.02664552442729473,
-0.02632... | 0.834411 | 0.777071 | 0.05734 |
Please explain the following problem in detail and provide code in ANSI C:
You are given an integer array `digits`, where each element is a digit. The array may contain duplicates.
You need to find **all** the **unique** integers that follow the given requirements:
* The integer consists of the **concatenation** of... | dolphin | [
0.013586609624326229,
0.02552010305225849,
-0.008857952430844307,
-0.03441491350531578,
0.020509030669927597,
-0.019775772467255592,
-0.02407904714345932,
0.06296354532241821,
0.022292718291282654,
-0.01060018315911293,
0.01859576813876629,
0.01860070414841175,
-0.04483465477824211,
-0.033... | 0.839355 | 0.782182 | 0.057173 |
Please explain the reasoning behind the following solution and provide code in java:
Given an integer array `nums`, reorder it such that `nums[0] < nums[1] > nums[2] < nums[3]...`.
You may assume the input array always has a valid answer.
**Example 1:**
**Input:** nums = \[1,5,1,1,6,4\]
**Output:** \[1,6,1,5,1,4\]
*... | dolphin | [
0.020174013450741768,
0.04186443239450455,
-0.018522849306464195,
-0.013919656164944172,
0.029302839189767838,
-0.02991247922182083,
-0.028758596628904343,
0.05151095986366272,
0.027100488543510437,
-0.007919013500213623,
0.014663145877420902,
0.004311792086809874,
-0.040405578911304474,
-... | 0.836813 | 0.783163 | 0.05365 |
Please write the following solution using Scala:
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:
* The first element in `s[... | dolphin | [
0.02500128000974655,
0.02763211354613304,
-0.023150024935603142,
-0.014138426631689072,
0.0363955944776535,
-0.03672754019498825,
-0.033172138035297394,
0.054511044174432755,
0.023733189329504967,
-0.01906752958893776,
0.024113817140460014,
0.02126569114625454,
-0.02165195718407631,
-0.009... | 0.850571 | 0.786728 | 0.063843 |
Please write the following solution using Mojo:
Given an integer array `nums` of **unique** elements, return _all possible_ _subsets_ _(the power set)_.
The solution set **must not** contain duplicate subsets. Return the solution in **any order**.
**Example 1:**
**Input:** nums = \[1,2,3\]
**Output:** \[\[\],\[1\],\... | dolphin | [
0.04725012555718422,
0.026315080001950264,
-0.012293881736695766,
-0.013795556500554085,
0.04738559573888779,
-0.039271146059036255,
-0.01479134988039732,
0.05118701234459877,
0.060218583792448044,
-0.01715233363211155,
0.032490767538547516,
0.01951664499938488,
-0.051700860261917114,
-0.0... | 0.832304 | 0.770389 | 0.061915 |
Please focus on the functionality of this problem and provide code in C#:
You are given an integer array `cards` where `cards[i]` represents the **value** of the `ith` card. A pair of cards are **matching** if the cards have the **same** value.
Return _the **minimum** number of **consecutive** cards you have to pick u... | dolphin | [
0.011084969155490398,
0.017184574156999588,
-0.04496632143855095,
-0.0250620786100626,
0.022873325273394585,
-0.019735366106033325,
-0.025049325078725815,
0.0757908895611763,
0.027409762144088745,
-0.030359288677573204,
0.014570173807442188,
0.01561658550053835,
-0.027626825496554375,
-0.0... | 0.842734 | 0.788316 | 0.054419 |
Please explain the reasoning behind the following solution and provide code in PHP:
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 subarra... | dolphin | [
0.01224108599126339,
0.04039241373538971,
-0.027314644306898117,
-0.017719805240631104,
0.03302450850605965,
-0.02422342263162136,
-0.054765522480010986,
0.05997634306550026,
0.030262839049100876,
-0.004578922875225544,
0.022772395983338356,
0.01484659407287836,
-0.030448799952864647,
-0.0... | 0.843868 | 0.788899 | 0.054969 |
Please write the following solution using R:
You are given an integer array `nums`. You want to maximize the number of points you get by performing the following operation any number of times:
* Pick any `nums[i]` and delete it to earn `nums[i]` points. Afterwards, you must delete **every** element equal to `nums[i]... | dolphin | [
0.019244901835918427,
0.020897742360830307,
-0.0249895341694355,
-0.026226643472909927,
0.026946330443024635,
-0.031054778024554253,
-0.03569274768233299,
0.05086454376578331,
0.04924286901950836,
-0.001260177232325077,
0.0007282521110028028,
0.027875252068042755,
-0.03613482788205147,
-0.... | 0.842695 | 0.781159 | 0.061536 |
Please explain the following problem in detail and provide code in PHP:
You are given two **non-increasing 0-indexed** integer arrays `nums1` and `nums2`.
A pair of indices `(i, j)`, where `0 <= i < nums1.length` and `0 <= j < nums2.length`, is **valid** if both `i <= j` and `nums1[i] <= nums2[j]`. The **d... | dolphin | [
0.014366425573825836,
0.036539848893880844,
-0.020999155938625336,
-0.017606765031814575,
0.037800900638103485,
-0.013937053270637989,
-0.040448520332574844,
0.06975040584802628,
0.038466937839984894,
-0.016037896275520325,
0.0259286779910326,
0.0195333119481802,
-0.03570004552602768,
-0.0... | 0.84803 | 0.784997 | 0.063033 |
Please explain the following problem in detail and provide code in c++:
You are given a square `board` of characters. You can move on the board starting at the bottom right square marked with the character `'S'`.
You need to reach the top left square marked with the character `'E'`. The rest of the squares are labeled... | dolphin | [
0.028588559478521347,
0.0007533231400884688,
-0.020340340211987495,
-0.04480496793985367,
0.03220326080918312,
-0.007022544275969267,
-0.015896158292889595,
0.09166066348552704,
0.040563490241765976,
-0.02082095853984356,
0.03753345459699631,
0.058619946241378784,
-0.01939879171550274,
-0.... | 0.842261 | 0.780684 | 0.061577 |
Please write the following solution using Objective-C:
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_ `0 <= i... | dolphin | [
0.019105777144432068,
0.03955914452672005,
-0.03149424493312836,
-0.0264559555798769,
0.058275382965803146,
-0.025963112711906433,
-0.029562002047896385,
0.05098039284348488,
0.04063495993614197,
-0.02410796843469143,
0.031112851575016975,
0.01426017563790083,
-0.01892039179801941,
0.00222... | 0.839395 | 0.777136 | 0.06226 |
Please write the following solution using Mojo:
Given an array of distinct integers `arr`, where `arr` is sorted in **ascending order**, return the smallest index `i` that satisfies `arr[i] == i`. If there is no such index, return `-1`.
**Example 1:**
**Input:** arr = \[-10,-5,0,3,7\]
**Output:** 3
**Explanation:** F... | dolphin | [
0.026950733736157417,
0.02831149287521839,
-0.025746634230017662,
-0.03132498264312744,
0.0387309305369854,
-0.030492903664708138,
-0.030863186344504356,
0.05466543510556221,
0.03926737606525421,
-0.030588431283831596,
0.026202598586678505,
-0.008104071952402592,
-0.03586158901453018,
-0.0... | 0.841068 | 0.780218 | 0.06085 |
Please focus on the functionality of this problem and provide code in javascript:
Given a string `s` and an integer `k`, return _the length of the longest substring of_ `s` _such that the frequency of each character in this substring is greater than or equal to_ `k`.
**Example 1:**
**Input:** s = "aaabb ", k = 3
**O... | dolphin | [
0.021364478394389153,
0.031527020037174225,
-0.02947731502354145,
-0.038681212812662125,
0.032506611198186874,
-0.029969552531838417,
-0.011648332700133324,
0.05012053996324539,
0.012831277213990688,
-0.014219705946743488,
0.036297693848609924,
0.025916501879692078,
-0.02148113027215004,
0... | 0.831127 | 0.77787 | 0.053257 |
Please write the following solution using ANSI C:
There are `n` soldiers standing in a line. Each soldier is assigned a **unique** `rating` value.
You have to form a team of 3 soldiers amongst them under the following rules:
* Choose 3 soldiers with index (`i`, `j`, `k`) with rating (`rating[i]`, `rating[j]`, `rati... | dolphin | [
0.01944684609770775,
0.025760851800441742,
-0.03013879805803299,
-0.029155563563108444,
0.04305114597082138,
-0.028569787740707397,
-0.026334792375564575,
0.0806756317615509,
0.027778105810284615,
-0.017633235082030296,
0.02521010860800743,
0.02127436175942421,
-0.052641645073890686,
-0.03... | 0.854739 | 0.796736 | 0.058003 |
Please explain the following problem in detail and provide code in Objective-C:
Given an array `nums` of integers and integer `k`, return the maximum `sum` such that there exists `i < j` with `nums[i] + nums[j] = sum` and `sum < k`. If no `i`, `j` exist satisfying this equation, return `-1`.
**Example 1:**
**Input:**... | dolphin | [
0.007097793743014336,
0.029742103070020676,
-0.03228054195642471,
-0.03207395225763321,
0.05499018728733063,
-0.010759604163467884,
-0.025196632370352745,
0.07032617926597595,
0.020228063687682152,
-0.009175942279398441,
0.037887509912252426,
0.032237306237220764,
-0.03809063881635666,
0.0... | 0.834247 | 0.774591 | 0.059656 |
Please explain the following problem in detail and provide code in Dart:
Given an integer array `nums`, return _the largest integer that only occurs once_. If no integer occurs once, return `-1`.
**Example 1:**
**Input:** nums = \[5,7,3,9,4,9,8,3,1\]
**Output:** 8
**Explanation:** The maximum integer in the array is ... | dolphin | [
0.013515463098883629,
0.02958887442946434,
-0.020741045475006104,
-0.02748957648873329,
0.028652649372816086,
-0.019982289522886276,
-0.02818647399544716,
0.05833453685045242,
0.02590431272983551,
-0.014151579700410366,
0.02884950116276741,
0.016957812011241913,
-0.02971574105322361,
-0.00... | 0.840476 | 0.784477 | 0.055999 |
Please write the following solution using Groovy:
Given an integer array `nums` that may contain duplicates, return _all possible_ _subsets_ _(the power set)_.
The solution set **must not** contain duplicate subsets. Return the solution in **any order**.
**Example 1:**
**Input:** nums = \[1,2,2\]
**Output:** \[\[\],... | dolphin | [
0.03963971138000488,
0.02198975533246994,
-0.011745446361601353,
-0.020418081432580948,
0.04639014974236488,
-0.03953986242413521,
-0.0035741589963436127,
0.04101425036787987,
0.05489763617515564,
-0.03155100718140602,
0.03582039102911949,
0.023243730887770653,
-0.042156390845775604,
-0.03... | 0.837376 | 0.77982 | 0.057557 |
Please write the following solution using Haskell:
You are given an `m x n` binary matrix `matrix`.
You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from `0` to `1` or vice versa).
Return _the maximum number of rows that have all values equal af... | dolphin | [
0.01013056468218565,
0.006271742284297943,
-0.020092621445655823,
-0.056355103850364685,
0.04206901416182518,
-0.029405269771814346,
-0.02145366370677948,
0.04698644205927849,
0.02557601034641266,
-0.03600909188389778,
0.010293394327163696,
0.02278466336429119,
-0.020812755450606346,
-0.03... | 0.838791 | 0.784035 | 0.054755 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.