messages listlengths 2 2 |
|---|
[
{
"role": "user",
"content": "Create a hash table in Python using a dictionary and implement a hash function to store and retrieve values."
},
{
"role": "system",
"content": "Sure! Here's an example of a hash table implemented using a dictionary in Python:\n\n```python\nclass HashTable:\n def... |
[
{
"role": "user",
"content": "Generate an array of random numbers with a size of 1000."
},
{
"role": "system",
"content": "Here is an array of 1000 random numbers:\n\n```python\nimport random\n\nrandom_numbers = [random.randint(1, 1000) for _ in range(1000)]\n```\n\nThis code uses the `random.ra... |
[
{
"role": "user",
"content": "Create a dictionary with three keys and a list of values assigned to each key. The values in each list should be sorted in ascending order. The dictionary should also support efficient lookup of the values based on their indices in the lists."
},
{
"role": "system",
... |
[
{
"role": "user",
"content": "Convert a decimal number to binary and hexadecimal.\n\nInput: A decimal number between 0 and 255.\n\nOutput: The binary and hexadecimal representation of the input number.\n\nExample:\nInput: 150\nOutput: Binary: 10010110, Hexadecimal: 96"
},
{
"role": "system",
"co... |
[
{
"role": "user",
"content": "Write Python code to print the last three prime numbers from a given list of integers. \nFor example, given the list [2, 4, 6, 8, 10, 12], the output should be [2]."
},
{
"role": "system",
"content": "Here is a Python code that can find the last three prime numbers ... |
[
{
"role": "user",
"content": "Delete every third character in a string, but with a time complexity of O(n) and a space complexity of O(1)."
},
{
"role": "system",
"content": "To delete every third character in a string with a time complexity of O(n) and a space complexity of O(1), we can use two... |
[
{
"role": "user",
"content": "Take the following string and read it into a list in Python. Each element in the list should be a tuple consisting of the word itself and its length. The tuple should be sorted based on the length of the word in descending order.\nExample: Input: \"apple, banana, peach, orange\... |
[
{
"role": "user",
"content": "How would you reverse the order of the elements in a given singly linked list in-place without using any extra space?"
},
{
"role": "system",
"content": "To reverse the order of the elements in a singly linked list in-place, you can follow the below steps:\n\n1. Ini... |
[
{
"role": "user",
"content": "Sum all the numbers divisible by 3 and 7 in the list and calculate the average of those numbers. Additionally, find the maximum and minimum values among the numbers divisible by 3 and 7. Finally, display the number of occurrences of each unique number divisible by 3 and 7 in th... |
[
{
"role": "user",
"content": "Given a dictionary with keys representing different space companies and values representing their respective slogans, sort the slogans alphabetically and return a list of tuples containing the company and its corresponding slogan.\n\nExample input:\n{\"SPACELINE\": \"Flight of ... |
[
{
"role": "user",
"content": "Write a function to print a user's name and age from a given dictionary. However, if the age is greater than or equal to 18, print \"Adult\" next to the name. If the age is less than 18, print \"Minor\" next to the name. If the age is less than or equal to 0, raise an exception... |
[
{
"role": "user",
"content": "Create a class in Python which models a bank account using the concept of class and object. The bank account should include the following functionalities:\n\n1. Ability to deposit and withdraw funds.\n2. Ability to check the current balance.\n3. Ability to calculate and apply i... |
[
{
"role": "user",
"content": "Write a function that takes in a JSON object as input and changes the value of a specific key to the sum of the values of two other keys. The function should have a time complexity of O(n), where n is the number of keys in the JSON object.\n\nThe input JSON object will have the... |
[
{
"role": "user",
"content": "Develop a program in Python that takes two array elements as input and finds their product.\nArray1: [1, 5, 8, 9]\nArray2: [2, 3, 4, 6]\n\nWrite a function named \"find_product\" that takes in two parameters: array1 and array2. The function should multiply each element in array... |
[
{
"role": "user",
"content": "Rank a list of integers from high to low, but with the following additional requirements:\n\n1. The sorting algorithm must be a modified version of quicksort.\n2. The modified quicksort algorithm must use a pivot element that is randomly selected from the input list.\n3. The so... |
[
{
"role": "user",
"content": "Create a regex pattern to identify alphanumeric characters that are followed by exactly three digits."
},
{
"role": "system",
"content": "The regex pattern to identify alphanumeric characters followed by exactly three digits is:\n\n```\n\\b\\w{1}\\d{3}\\b\n```\n\nEx... |
[
{
"role": "user",
"content": "Write an iterator in Python to iterate through the given list and output each element. Additionally, the iterator should only output elements that are of even length. myList = ['Hi', 'Bye', 'Hello', 'World']"
},
{
"role": "system",
"content": "Here is an iterator in... |
[
{
"role": "user",
"content": "Using the given linked list, find out the second last element. If the linked list is empty or contains only one element, return None. If the linked list contains two elements, return the first element."
},
{
"role": "system",
"content": "To find the second last elem... |
[
{
"role": "user",
"content": "Given a text string, modify it by capitalizing the letters after a period. However, if the letter following a period is already capitalized, change it to lowercase. \nFor example, given the text string \"hello world. This is from GPT\", the modified string would be \"hello worl... |
[
{
"role": "user",
"content": "Create an array of integers that contain all the prime numbers between 1 and 1000, using the Sieve of Eratosthenes algorithm."
},
{
"role": "system",
"content": "Here's the array of prime numbers between 1 and 1000, using the Sieve of Eratosthenes algorithm:\n\n```p... |
[
{
"role": "user",
"content": "Write a function that returns the larger number from two numbers provided. However, the function should also handle cases where the two numbers are equal and return an appropriate message. Additionally, the function should handle cases where one or both of the numbers are negat... |
[
{
"role": "user",
"content": "Build a finite-state machine in Python to process incoming keyboard events for a text-based adventure game. The state machine should have at least three states: \"Exploring\", \"Battle\", and \"Menu\". In the \"Exploring\" state, the player can move around a virtual world and i... |
[
{
"role": "user",
"content": "Generate a program to calculate the combination of n elements taken k at a time, where n and k are non-negative integers. Ensure that the program handles cases where n is smaller than k, and outputs an appropriate error message.\n\nExample:\nInput: n = 5, k = 3\nOutput: 10\n\nI... |
[
{
"role": "user",
"content": "Create a program that finds the second largest element in a list of integers.\narr = [1, 10, 4, 5, 6, 7, 9]"
},
{
"role": "system",
"content": "Here is a program in Python that finds the second largest element in a list of integers:\n\n```python\ndef find_second_lar... |
[
{
"role": "user",
"content": "Generate a function that takes an array of integers and rearranges the elements in a cyclical fashion, such that the element at index 0 comes last, the element at index 1 goes to the front, the element at index 2 is inserted after the element at the last index and so on. Additi... |
[
{
"role": "user",
"content": "Given a string, write an algorithm to remove all occurrences of a given letter that are followed by a digit.\nmy_string = \"Python is a popular programming language, version 3.9.2\"\nletter = 'o'"
},
{
"role": "system",
"content": "Here is one possible algorithm to ... |
[
{
"role": "user",
"content": "Create a Python function called split_string that takes a string and a delimiter as arguments and returns a list containing the string split by the delimiter. The function should also remove any leading or trailing whitespace from each split element in the resulting list. \n\nF... |
[
{
"role": "user",
"content": "How to retrieve the data of the third element in a nested JSON array within a nested JSON object?"
},
{
"role": "system",
"content": "To retrieve the data of the third element in a nested JSON array within a nested JSON object, you need to access the appropriate pro... |
[
{
"role": "user",
"content": "Write a program that reads a dictionary containing the names and ages of a group of people, and prints out the name and age of each person in the group in the format \"Name: age\"."
},
{
"role": "system",
"content": "Here's a Python program that reads a dictionary o... |
[
{
"role": "user",
"content": "Given a list of words, write a program to convert the list into a set while removing any duplicate elements. The program should also sort the resulting set in alphabetical order."
},
{
"role": "system",
"content": "Here's a Python program that takes a list of words,... |
[
{
"role": "user",
"content": "Given an array of integers, determine the maximum and minimum value of the array. The array can have duplicate values and can be of any length between 1 and 10^6."
},
{
"role": "system",
"content": "To solve this problem, we can initialize two variables, `maxValue` ... |
[
{
"role": "user",
"content": "Compare the two strings and report the index of the first mismatch. The strings should be case-sensitive and should only consist of lowercase letters. String 1 should have a maximum length of 10 characters, while String 2 should have a maximum length of 15 characters."
},
{... |
[
{
"role": "user",
"content": "Create a function that evaluates a mathematical expression stored as a string. The expression can contain the following operators: +, -, *, /, and ^. The expression may also include parentheses. The function should handle operator precedence correctly. For example, the expressi... |
[
{
"role": "user",
"content": "Augment an integer list with zeros after every 4 elements. However, if a zero is encountered in the original list, skip the next 3 elements and then add the zeros.\n\nOriginal List: [1, 2, 0, 4, 5, 6, 7, 8]\n\nAugmented List: [1, 2, 0, 0, 0, 0, 5, 6, 0, 0, 0, 0, 7, 8]\n\nNote: ... |
[
{
"role": "user",
"content": "Develop an algorithm to find the depth of a specific node in a binary tree."
},
{
"role": "system",
"content": "Here's an algorithm to find the depth of a specific node in a binary tree:\n\n1. Start from the root of the binary tree and set the current depth to 0.\n2... |
[
{
"role": "user",
"content": "You need to debug this code and ensure that it runs properly.\n\ndef cost_calc(products, quantity): \n total_cost = 0\n for product, q in zip(products, quantity):\n cost = product.cost * q \n total_cost = total_cost + cost \n return total_cost"
},
{
... |
[
{
"role": "user",
"content": "Write a function in Python to check if two lists have the same elements regardless of their order. The elements in the lists will be strings consisting of lowercase letters only, and each element will have a length between 1 and 10 characters inclusive. The lists can have a max... |
[
{
"role": "user",
"content": "Implement a queue following the classic FIFO (First-in-first-out) principle using Python. Your implementation should support the following additional requirement: If an element is removed from the queue, its value should be logged to a separate file named \"queue_logs.txt\"."
... |
[
{
"role": "user",
"content": "Given an array of strings and the task is to find the longest string from the given string array, but only considering strings that contain at least one uppercase letter."
},
{
"role": "system",
"content": "To find the longest string from the given string array, but... |
[
{
"role": "user",
"content": "Write a function to find the path from a source point to a destination point in a given 2D array.\nArray: [[0, 1, 0, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 1, 0], [0, 0, 0, 1, 0]]\nSource Point: [0, 0]\nDestination Point: [3, 4]\n\nHowever, the given array may contain obstacles repr... |
[
{
"role": "user",
"content": "Given an array of integers, create a code to return the second-largest number that is also a prime number. If there is no second-largest prime number in the array, return -1.\n[12, 45, 2, 41, 31, 10, 8, 6, 4]"
},
{
"role": "system",
"content": "Here is one possible ... |
[
{
"role": "user",
"content": "Given a list of positive and negative numbers, create a code to find the maximum product of three numbers, where the product must include at least one positive number and one negative number. Additionally, the code should be optimized to have a time complexity of O(n), where n ... |
[
{
"role": "user",
"content": "Given the following code, write a function to validate the input dates are in increasing order. The input dates should be in the format \"yyyy-mm-dd\" and should strictly adhere to the Gregorian calendar system. Additionally, the function should check for leap years and conside... |
[
{
"role": "user",
"content": "Write a function in Python to remove all 'null' values from a nested dictionary. The function should also remove any empty dictionaries or lists that are left behind after removing the 'null' values. The function should have a time complexity of O(n), where n is the total numbe... |
[
{
"role": "user",
"content": "Write a function to compare two strings and return the number of different characters in each string. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the longer string."
},
{
"role": "system",
"content": "H... |
[
{
"role": "user",
"content": "Write a Python function to calculate the power of a number raised to the nth power, considering that the number and power are both positive integers greater than zero."
},
{
"role": "system",
"content": "Here is a Python function that calculates the power of a numbe... |
[
{
"role": "user",
"content": "Write a function to generate all possible permutations of a given string. The input string will contain only lowercase alphabets and may contain duplicate characters.\n\nExample:\nInput: \"aba\"\nOutput: [\"aba\", \"aab\", \"baa\"]\n\nConstraints:\n- The length of the input str... |
[
{
"role": "user",
"content": "Design a function to create a secure password that meets the following requirements:\n- Contains at least one uppercase letter, one lowercase letter, and one digit\n- Does not contain any repeating characters\n- Must be at least 12 characters long\n- Must include at least one s... |
[
{
"role": "user",
"content": "Submit an optimized solution to the following leetcode problem.\nProblem: Given two binary trees, write a function to check if they are the same or not. The trees should have at most 1000 nodes each and the values of the nodes should be integers within the range of -1000 to 100... |
[
{
"role": "user",
"content": "Define a class in Python that represents a currency. The currency should have attributes for the name, symbol, and exchange rate to USD. The class should also have methods to convert an amount in the currency to USD and vice versa."
},
{
"role": "system",
"content":... |
[
{
"role": "user",
"content": "Write a Python function to convert a given Unix timestamp to a readable format like \"day, month, date, hours:minutes:seconds, year\". The function should also include the option to convert the timestamp to different time zones, taking into account daylight saving time if appli... |
[
{
"role": "user",
"content": "Create a class for constructing a new tree with the following methods:\n\n1. `add_node(value: int) -> None`: Adds a new node with the given value to the tree.\n - Time Complexity: O(log n) on average, where n is the number of nodes in the tree.\n - Space Complexity: O(1)\n ... |
[
{
"role": "user",
"content": "Build a script to print the words that have the most occurrences in a given string, excluding all common English stop words such as \"the\", \"and\", \"but\", \"or\", etc."
},
{
"role": "system",
"content": "Here's a Python script that prints the words with the most... |
[
{
"role": "user",
"content": "Given a string in Python, generate a new string with the same set of characters but in the reverse order. The input string will have at most 1000 characters and will only consist of lowercase letters. You are not allowed to use any built-in reverse functions or methods."
},
... |
[
{
"role": "user",
"content": "Given an array of integers, remove any duplicate numbers and sort the remaining elements in descending order. The final array should also include the count of each unique element. \n\nExample:\nInput: arr = [3, 9, 8, 4, 6, 7, 5, 4]\nOutput: sortedArr = [9, 8, 7, 6, 5, 4, 3], co... |
[
{
"role": "user",
"content": "Develop a program that finds the second highest value from a list of positive integers."
},
{
"role": "system",
"content": "Here's an example code in Python that finds the second highest value from a list of positive integers:\n\n```python\ndef find_second_highest(n... |
[
{
"role": "user",
"content": "Design a function to find the Fibonacci sequence numbers given n. The function should only use a single loop and no recursion. The function should also handle the edge case when n is negative or zero by returning an empty list. n = 5"
},
{
"role": "system",
"content... |
[
{
"role": "user",
"content": "Design a function to compute the sum of the squares of the first n natural numbers."
},
{
"role": "system",
"content": "Here is one possible implementation in Python:\n\n```python\ndef sum_of_squares(n):\n return sum([i**2 for i in range(1, n+1)])\n```\n\nThis fu... |
[
{
"role": "user",
"content": "Create a program that outputs a spiral array from the given input of a 2D array. The program should take into consideration that the input array can have any number of rows and columns.\n\nFor example:\nInput: \n[[ 1, 2, 3 ],\n [ 4, 5, 6 ],\n [ 7, 8, 9]]\n\nOutput:\n[1, 2, 3, 6... |
[
{
"role": "user",
"content": "Create a program that takes in two lists of numbers and computes the maximum absolute difference between the two lists. The absolute difference between two numbers is the absolute value of their difference.\nList 1: [20, 10, 4, 0]\nList 2: [17, 1, 10, 7, 8]\n\nProvide a piece o... |
[
{
"role": "user",
"content": "Implement the algorithm to reverse a singly linked list without using any additional data structures."
},
{
"role": "system",
"content": "To reverse a singly linked list without using any additional data structures, you can use the following algorithm:\n\n1. Initial... |
[
{
"role": "user",
"content": "Compute the sum of all the prime numbers and Fibonacci numbers in an array of numbers.\n[2, 3, 5, 7, 8, 13]"
},
{
"role": "system",
"content": "To find the sum of all the prime numbers and Fibonacci numbers in the given array, we need to iterate through each number ... |
[
{
"role": "user",
"content": "Design a function to parse the given URL and return its components. The function should handle URL encoding and decoding. The URL may contain special characters and non-ASCII characters. The function should also validate the URL format and throw an error if it is not a valid UR... |
[
{
"role": "user",
"content": "Write code using the NumPy random library to simulate the rolling of two fair six-sided dice. Additionally, your code should ensure that the sum of the two dice is less than or equal to 9."
},
{
"role": "system",
"content": "Here is the code to simulate rolling two ... |
[
{
"role": "user",
"content": "Write a code to delete white space from this sentence, while also keeping track of the number of words in the sentence. This is a sentence with extra white space."
},
{
"role": "system",
"content": "Here's a Python code snippet that removes extra white space from th... |
[
{
"role": "user",
"content": "Given a 2D array in Python, find the maximum value in each column and return a new 2D array where each element is replaced by its corresponding column's maximum value. The input array can have any number of rows and columns.\n\nFor example, given the input array:\narray = [[1, ... |
[
{
"role": "user",
"content": "Propose an algorithm in Python for sorting a given list of numbers in descending order, without using any built-in sorting functions or libraries."
},
{
"role": "system",
"content": "Here's a simple algorithm to sort a list of numbers in descending order using Pytho... |
[
{
"role": "user",
"content": "Explain in plain English the difference between the set() and list() methods in Python. Additionally, write a Python function that takes in a list of integers and returns a set containing only the even numbers, without using any built-in Python functions or methods."
},
{
... |
[
{
"role": "user",
"content": "Create a function in Python to find all pairs of distinct integers from two given lists that sum up to k, where the absolute difference between the integers in each pair should be greater than or equal to a given threshold value."
},
{
"role": "system",
"content": "... |
[
{
"role": "user",
"content": "Create a sorting algorithm to order a given array of integers in ascending order, without using any built-in sorting functions or libraries. The algorithm should have a time complexity of O(n^2) and should be implemented using a variation of the bubble sort algorithm. Additiona... |
[
{
"role": "user",
"content": "Design an algorithm in Python to retrieve all elements in a given array that occur only once. Your algorithm should have a time complexity of O(n) where n is the number of elements in the array.\n\n# Additional Information #\n- The given array can contain both positive and nega... |
[
{
"role": "user",
"content": "How can you use a function to determine whether a given array is strictly increasing, strictly decreasing, non-decreasing, non-increasing, or unordered?"
},
{
"role": "system",
"content": "To determine the order of an array using a function, you can follow these ste... |
[
{
"role": "user",
"content": "Write a Python function to generate a list of Fibonacci numbers up to the given limit n, where the time complexity of the function should be O(n)."
},
{
"role": "system",
"content": "Here's a Python function that generates a list of Fibonacci numbers up to a given l... |
[
{
"role": "user",
"content": "Implement a function that takes in a string and returns a dictionary where each character in the string is a key and the corresponding value is a list of indices where the character appears in the string. The dictionary should be sorted in alphabetical order by the characters."... |
[
{
"role": "user",
"content": "Given a list of positive integers, write a program to find three elements whose sum equals a given target value. Additionally, the program should return all possible combinations of these three elements.\n\nFor example, given the list [1, 2, 3, 4, 5] and the target value of 6, ... |
[
{
"role": "user",
"content": "Create a program that prints out a list of all prime numbers from 0 to 100, except for two and five."
},
{
"role": "system",
"content": "Here's a Python program that prints out a list of all prime numbers from 0 to 100, excluding 2 and 5:\n\n```python\ndef is_prime(... |
[
{
"role": "user",
"content": "You need to write a function to check if the given input is a palindrome string. The function should ignore any punctuation marks and spaces in the string. The function should also be case-insensitive, meaning that \"Level\" should be considered a palindrome."
},
{
"rol... |
[
{
"role": "user",
"content": "Create a program to find the largest common factor in two numbers within a given range.\nThe program should take three inputs: the two numbers (N1 and N2), and the range (R).\nThe program should find the largest common factor of N1 and N2 that is within the range of 1 to R.\nIf... |
[
{
"role": "user",
"content": "A function needs to be created that will take a list of strings and return a list of the same strings without duplicates. The function should also ignore case sensitivity when checking for duplicates. Additionally, the function should remove any leading or trailing whitespace f... |
[
{
"role": "user",
"content": "create a function to compare two strings and return a boolean depending on their equality or inequality. However, you cannot use any built-in string comparison methods or operators such as '=='. Instead, you must implement your own algorithm to compare the strings character by ... |
[
{
"role": "user",
"content": "Write a function that will format a given string in proper title case. The string may contain multiple sentences and punctuation marks. The function should correctly capitalize the first letter of each word in the string, except for certain words that should be lowercase (e.g.,... |
[
{
"role": "user",
"content": "In Python, write a script that prints out the elements of a list in reverse order, without using the built-in reverse function or any additional data structures. The list should be modified in-place. The time complexity of the algorithm should be O(n), where n is the length of ... |
[
{
"role": "user",
"content": "Write a function in a programming language of your choice that takes a list of strings as input and returns a string of HTML code to create an unordered bulleted list. Each string in the input list should be a separate bullet point in the output HTML code. The function should p... |
[
{
"role": "user",
"content": "Create a method that deletes all the empty elements from a given array of strings. The method should not use any built-in array manipulation methods such as `filter`, `reduce`, or `map`. The method should have a time complexity of O(n), where n is the length of the input array.... |
[
{
"role": "user",
"content": "Given a string and an int n, write a function to extract all possible subsequences of length n from the string. The function should return a list of all the subsequences.\n\ns = \"hello world\", n = 6"
},
{
"role": "system",
"content": "Here's one possible solution ... |
[
{
"role": "user",
"content": "Given a dataframe with integers, write a function that adds a new column that contains the results of a calculation between two columns, where the calculation is performed only if the value in column A is greater than the value in column B. If the calculation cannot be performe... |
[
{
"role": "user",
"content": "Given an integer N, write a code that finds the next palindrome of N. A palindrome is a number that reads the same forward and backward. If N is already a palindrome, find the next smallest palindrome greater than N.\n\nN = 187\n\n# Additional Steps #\n1. Check if N is a palind... |
[
{
"role": "user",
"content": "Design an algorithm for finding the frequency of occurrence of each vowel in a given string. The input string may contain uppercase and lowercase letters."
},
{
"role": "system",
"content": "Here is an algorithm for finding the frequency of occurrence of each vowel ... |
[
{
"role": "user",
"content": "Given a data table, write a function to select the columns. The function should also allow the user to specify a condition to filter the rows based on a given column and value. The selected columns should be returned as a new data table. The function should handle the case wher... |
[
{
"role": "user",
"content": "Define a function that takes a string as input and returns true if it is a valid IPv6 address.\n\nip_str = \"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"\n\nNote: IPv6 addresses are represented as eight groups of four hexadecimal digits, separated by colons. Each group can be abbr... |
[
{
"role": "user",
"content": "Generate code to return a fibonacci sequence up to n elements. However, the code should not use recursion or the golden ratio formula to calculate the fibonacci sequence. The code should use an iterative approach to generate the sequence.\n\nn = 10"
},
{
"role": "system... |
[
{
"role": "user",
"content": "Given a string, write a code that checks it for palindrome in O(1) space complexity and O(n) time complexity.\n\nstr = \"abba\""
},
{
"role": "system",
"content": "To check if a string is a palindrome, we need to compare the characters at the beginning and end of th... |
[
{
"role": "user",
"content": "Create a class that implements a polygon using an array of Point objects. The polygon should support the following operations:\n\n1. Calculate the perimeter of the polygon.\n2. Calculate the area of the polygon.\n3. Check if a given point lies inside the polygon.\n4. Check if a... |
[
{
"role": "user",
"content": "Create an algorithm that computes the sum of the maximum K (given) digits in a given array. The array may contain negative numbers and zero values. If K is greater than the length of the array, return -1.\n\n#Erroneous Reference Code#\n```python\ndef compute_sum_of_max_digits(a... |
[
{
"role": "user",
"content": "Given a list of integers, output the number of distinct elements in the list. \n\nExample:\nInput: [1, 2, 3, 4, 5, 2, 4]\nOutput: 5"
},
{
"role": "system",
"content": "Here is one possible solution in Python:\n\n```python\ndef count_distinct_elements(nums):\n ret... |
[
{
"role": "user",
"content": "Create a logic using Python that checks if a string contains only alphabetical characters and has a length of at least 5 characters or not."
},
{
"role": "system",
"content": "Here is a Python logic that checks if a string contains only alphabetical characters and h... |
[
{
"role": "user",
"content": "Write a code snippet to create an array filled with alternating 0s and 1s, where the number of 0s and 1s is equal. The array should start with 0.\nArray size: 10"
},
{
"role": "system",
"content": "Here's a code snippet in Python that creates an array filled with al... |
[
{
"role": "user",
"content": "Implement a function that takes in two integers and returns their bitwise AND, OR, and XOR results. The function should return a list containing the three results in the following order: AND, OR, XOR."
},
{
"role": "system",
"content": "Here is an implementation of ... |
[
{
"role": "user",
"content": "Write a function that reverses a string in place without using any additional data structures. The function should have a time complexity of O(n) and a space complexity of O(1).\nExample: \nInput: \"Hello world\"\nOutput: \"dlrow olleH\""
},
{
"role": "system",
"con... |
[
{
"role": "user",
"content": "Perform a binary search on the following list of integers, but ensure that the search algorithm also returns the index of the found element in addition to the element itself: [0, 1, 2, 3, 4, 5, 6, 7, 8]."
},
{
"role": "system",
"content": "To perform a binary search... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.