Dataset Viewer
Auto-converted to Parquet Duplicate
conversations
listlengths
3
3
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a Python function to find the shortest substring that contains all the characters of a given set. If there is no such substring, return an empty string." }, { "from": "gpt...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function that takes a string as input and returns a list of unique integers that are found in the string. The function should ignore duplicates and return the integers in...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Given a 2D list of integers where each row is sorted in ascending order and each column is also sorted in ascending order, write a function that returns True if a target integer is pres...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the symmetric difference between two given sets.\nThe symmetric difference of two sets is the set of elements which are in either of the sets but not in their i...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the number of extra characters needed to make the second string a subsequence of the first string." }, { "from": "gpt", "value": "Here is the...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find and return the upper case letters in a given string." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef find_upp...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of numbers as an argument and returns a new list containing only the even numbers from the original list." }, { "from": "gpt", "value": "H...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of integers and returns the length of the longest harmonious subsequence within the list. A harmonious subsequence is defined as a subsequence where t...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to check if a number is a self-dividing number. A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-divid...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of strings, where each string represents a line of text. The function should return a new list of strings where each line is reversed. However, the or...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of integers and returns a list of tuples. Each tuple contains two elements: the original integer and a boolean value indicating whether the integer is...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that finds the maximum product of two adjacent elements in a list of integers. The function should return the maximum product found." }, { "from": "gpt", "v...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to generate all possible combinations of phone number digits to letters, given the mapping of digits to letters as follows:\n2: ['a', 'b', 'c']\n3: ['d', 'e', 'f']\n4: ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes two lists of integers as input and checks if it's possible to exchange elements between the lists to make the first list consist only of even numbers. You ca...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Create a function that takes a list of numbers and returns a new list with each number's absolute value." }, { "from": "gpt", "value": "Here is the code to solve this proble...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the smallest positive number that is evenly divisible (without remainder) by all of the numbers from 1 to n." }, { "from": "gpt", "value": "H...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of numbers as an argument and returns a new list with the numbers sorted in descending order using a custom sort algorithm." }, { "from": "gpt...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the number of distinct subsequences of a given string. A subsequence of a string is a new string that is formed from the original string by deleting some (can b...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the maximum length of a subarray with a given sum." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef max...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that checks whether a given string is a valid password. A valid password must satisfy the following conditions:\n1. It must be at least 8 characters long.\n2. It must c...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the two numbers in a list that add up to a target number and return their indices. Assume that each input has exactly one solution, and the same element cannot ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of integers and returns a new list with the integers reversed and each integer converted to its absolute value." }, { "from": "gpt", "valu...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the missing number in a given sequence of integers from 1 to n." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```py...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the number of ways to decode a message encoded using the following mapping:\n'A' -> 1\n'B' -> 2\n...\n'Z' -> 26\n\nA message containing letters from A-Z ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the number of ways to reach the target sum using elements from the given list. You can add or subtract the elements. Each element in the list may be used an unl...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of strings and returns a new list with the strings that have a length greater than 3 and are in uppercase." }, { "from": "gpt", "value": "...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the number of times an element appears consecutively in a list." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\nd...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the longest subarray with equal number of 0's and 1's." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to generate all possible next moves in the Flip Game II given a string that contains only '+' and '-' characters. The function should return a list of all possib...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to calculate the postfix expression. The function should take a string as input, which is the postfix expression, and return the result of the expression. The st...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of numbers as input and returns the largest number in the list." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n``...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the sum of all even Fibonacci numbers up to a given limit." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef su...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the second highest number in a given list." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef find_Second...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the length of the longest consecutive sequence of non-zero elements in a list. Your function should return the length of this sequence." }, { "from": "g...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to add two large numbers represented as strings." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef add_large_numbers(nu...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the most common item in a list." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\nfrom collections import Counter\n...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the total number of ways to reach the top of a staircase, given that you can either climb 1 or 2 steps at a time." }, { "from": "gpt", "value": "Her...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the maximum area of a rectangle that can be formed by the histogram given the height of each bar in the histogram." }, { "from": "gpt", "valu...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of strings and returns a list of all possible anagrams formed by concatenating the strings together in any order.\n\nFor example, given ['cat', 'dog']...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the largest number in a list that is divisible by 3." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef find_lar...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Create a function that accepts a string and converts all alphabetical characters to their corresponding ASCII values. The function should ignore any non-alphabetical characters." }, ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the intersection of two lists, where each element in the lists is a tuple of integers. The function should return a list of tuples that are common to both input...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to check if a number is a power of five." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef is_power_of_five(n: 'int') -...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the sum of all the elements in a given subarray of an array." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that accepts a string and replaces all occurrences of a vowel with a specified character." }, { "from": "gpt", "value": "Here is the code to solve this prob...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to calculate the minimum path sum from top to bottom in a triangle. Each step you may move to adjacent numbers on the row below." }, { "from": "gpt", ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to check whether a given string is a palindrome or not. A palindrome is a word, phrase, number, or other sequence of characters that reads the same backward as f...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to check if a given list is a valid sawtooth array. A valid sawtooth array starts with the smallest number, then increases to the largest number, and then decrea...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function that checks whether a given number is horrible or not. A horrible number is a number that can be divided by 2, 3, or 5 only once at a time until it becomes 1. If...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the maximum number of elements that can be selected from a list such that the sum of those elements is less than or equal to a given limit." }, { "from"...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the minimum k numbers in the given list.\n\nThe function should take two arguments: a list of integers and an integer k. The function should return a list of th...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the maximum score by removing boxes with the same color until there are no boxes left. Each time you can choose some continuous boxes with the same color...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the maximum length of a subarray with a given sum." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef max...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the number of trailing zeros in the factorial of a given number." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```p...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that accepts a list of integers. The function should return the product of all the elements in the list. If the list is empty, the function should return 1." }, { ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the number of times a given number appears in a list." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef count_n...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the number of occurrences of an element in a list and return the modified list with the element replaced by the number of occurrences." }, { "from": "gp...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Design a python function to calculate the number of binary trees possible with N distinct nodes." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```p...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the maximum product of three numbers in a given list." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the concatenation of two given strings in the order of their length." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the maximum number of consecutive vowels in a given string." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef m...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes two arrays of integers, arr1 and arr2, and returns a new array that contains the intersection of the two arrays (i.e., elements that are present in both arra...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to check if a string is a palindrome after applying backspace operations. A backspace operation is represented by the '#' character.\n\nA string is considered a palindr...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the maximum product from cutting a rope into integer lengths. The function should return the maximum product possible." }, { "from": "gpt", "value":...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to determine if a given string is a valid word based on a custom dictionary. A valid word is defined as a word that can be formed by rearranging the letters of one or m...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the sum of numbers in a list that are divisible by 3." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef sum_div...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the sum of the first n natural numbers." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef sum_of_natural...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to convert a given 2D list into a dictionary where each key is a tuple representing the coordinates (row, column) of the corresponding value." }, { "from...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to reverse the rows and columns of a given 2D matrix." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef reverse_matrix(...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of integers and returns a list of tuples. Each tuple should contain two elements: the original integer and a boolean value indicating whether the inte...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to convert string representation of a list of floats into an actual list of floats." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to check if a given string matches a given wildcard pattern. The pattern can contain '?' and '*' wildcard characters. '?' matches any single character, while '*' matche...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the number of steps required for a document at a specific location to be printed, where the printer always prints the document with the highest priority....
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a string representing a simplified canonical path in a Unix-style file system and returns the original absolute path. The simplified canonical path will cons...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the maximum of three numbers." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef max_of_three(a, b, c):\n retur...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the n-th Fibonacci number using recursion." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef fibonaccii(...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the smallest palindrome larger than the given integer.\n\nA palindromic number reads the same both ways. The smallest 6 digit palindromic number is 100001, whic...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function that takes a list of integers as an argument and returns a list of their corresponding binary representations as strings." }, { "from": "gpt", "value...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the length of the longest subsequence such that elements in the subsequence are consecutive integers. Elements may appear more than once in the array." ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding the numb...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to compress a binary string, merging consecutive zeros into a single zero." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n``...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to convert a decimal number to binary, octal and hexadecimal." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the intersection of two sets." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef find_set_intersection(se...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the sum of cubes of first n odd natural numbers." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef sum_o...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to calculate the number of trailing zeroes in the factorial of a number." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```p...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function that takes a list of integers and returns the sum of the squares of the even numbers in the list." }, { "from": "gpt", "value": "Here is the code to ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the median of two sorted arrays." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef find_Median_Sorted_Ar...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the node with the maximum degree in a given list of edges representing an undirected graph. The degree of a node is the number of edges it is connected t...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the frequency of a given pattern in a text string. A pattern is considered to be a sequence of characters that appears in the text string. The function should r...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to remove all occurrences of a given sublist from a list." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef remo...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the number of ways to express a given number as a sum of consecutive positive integers." }, { "from": "gpt", "value": "Here is the code to so...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function that finds the minimum number of operations required to convert a given number of pages into a single page by repeatedly dividing it into two equal parts. If the...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to check if the given string is a valid parentheses sequence." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef check_p...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to check if a number is a majority element in a sorted list. A majority element is an element that appears more than n/2 times in the list of length n." }, { "f...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function that takes a positive integer n as a parameter and returns the smallest prime number greater than n." }, { "from": "gpt", "value": "Here is the code ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function that takes a list of integers as input and returns a dictionary where the keys are the odd numbers from the list and the values are their respective squares." }, { ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a function to find the maximum product of three numbers in a given array." }, { "from": "gpt", "value": "Here is the code to solve this problem:\n```python\ndef find_m...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to check if a given square matrix is a Toeplitz matrix. A Toeplitz matrix is a matrix where all elements on the same diagonal (from top-left to bottom-right) are...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Write a python function to find the subarray with the maximum difference between any two elements in a given array." }, { "from": "gpt", "value": "Here is the code to solve ...
[ { "from": "system", "value": "You are an assistant that responds to the user." }, { "from": "human", "value": "Create a function in Python that takes a 2D list as an argument and returns the diagonal elements of that list." }, { "from": "gpt", "value": "Here is the code to solve this...
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
2