messages listlengths 2 2 | source stringclasses 1
value |
|---|---|
[
{
"content": "Create a function that takes a string, a keyword, and a replacement word, then delete all the occurrences of the keyword in the given string and replace them with the replacement word. The function should be case-sensitive and should also count and return the total number of occurrences of the key... | codefeedback |
[
{
"content": "Implement a search algorithm to search for a node in a binary search tree with a time complexity of O(log n). The algorithm should also keep track of the number of comparisons made during the search process.",
"role": "user"
},
{
"content": "Here's an implementation of a search algorit... | codefeedback |
[
{
"content": "Write a code to traverse a matrix in spiral form while keeping track of the sum of all the elements.",
"role": "user"
},
{
"content": "Here is an example code in Python to traverse a matrix in spiral form and calculate the sum of all the elements:\n\n```python\ndef spiral_matrix(matrix... | codefeedback |
[
{
"content": "Given a string and two words, write a program to find the shortest subsequence containing both words. A subsequence is defined as a sequence of characters that appears in the same order as they do in the original string, but not necessarily consecutively. The program should return the subsequence ... | codefeedback |
[
{
"content": "Create a switch statement to convert an RGB value to HEX. The RGB value should be limited to values between 0 and 255, and an error message should be displayed if any of the values are outside this range. The HEX value should be formatted as a 6-digit string preceded by a '#' symbol. Additionally,... | codefeedback |
[
{
"content": "Suggest a way to generate random passwords using Python with the following requirements:\n1. The password must be at least 12 characters long.\n2. The password must contain a combination of uppercase and lowercase letters, numbers, and special characters.\n3. The password must not contain any repe... | codefeedback |
[
{
"content": "Implement a random number generator in Python that returns a random prime number in the range of 1-100.",
"role": "user"
},
{
"content": "Here's an implementation of a random prime number generator in Python that returns a random prime number in the range of 1-100:\n\n```python\nimport... | codefeedback |
[
{
"content": "Create a program that assigns a unique ID to each element of an array. The ID should be a combination of a randomly generated alphanumeric string and a timestamp. The alphanumeric string should be at least 10 characters long and should contain a combination of uppercase letters, lowercase letters,... | codefeedback |
[
{
"content": "Implement a function in programming that demonstrates the concept of polymorphism. The function should take in two parameters: a list of shapes (each shape represented as a dictionary with attributes such as \"type\" and \"area\") and a string indicating the operation to be performed on the shapes... | codefeedback |
[
{
"content": "You are given two strings, A and B. Write a function to delete the characters in A that also appear in B. Additionally, the function should also delete any characters in A that appear more than once consecutively. \n\nA = 'abcbbdef'\nB = 'abcdc'\n\nAfter applying the function, A should be modified... | codefeedback |
[
{
"content": "Write a dynamic programming algorithm to solve the following problem:\n\nGiven an array of positive integers, find the maximum sum of a subsequence with the constraint that no two numbers in the sequence are adjacent to each other. For example, for the input array [1, 2, 3, 4, 5], the maximum sum ... | codefeedback |
[
{
"content": "Create a sorting algorithm in Python that will sort an array of numbers in ascending order.\n\nThe time complexity of the algorithm should be O(nlogn) or better. You are not allowed to use any built-in sorting functions or libraries.\n\nThe algorithm should be stable, meaning that the relative ord... | codefeedback |
[
{
"content": "Create an array of length n, containing all even numbers starting from 0, where each number is the sum of its previous two even numbers in the array.",
"role": "user"
},
{
"content": "To create an array of length n containing all even numbers starting from 0, where each number is the s... | codefeedback |
[
{
"content": "Describe the working of a set in Python, including how to implement set operations such as union, intersection, and difference, and provide an example code that demonstrates the usage of sets in a real-life scenario.",
"role": "user"
},
{
"content": "In Python, a set is an unordered co... | codefeedback |
[
{
"content": "Implement an algorithm to find all the sets of three distinct numbers in an array which adds up to a given number. The array will contain positive integers only and can have duplicate values. The output should be in ascending order and should not contain any duplicate sets.\nArray: [2, 5, 8, 2, 3,... | codefeedback |
[
{
"content": "Code a function in Python to calculate the nth value of the Fibonacci sequence.\n\n#Hints#\n- You can use recursion or iteration to solve this problem.\n- Think about how you can store previously calculated Fibonacci numbers to avoid redundant calculations.\n- Test your solution with different inp... | codefeedback |
[
{
"content": "Visit the official API documentation for a web service of your choice and create a Python code that makes a POST request with a JSON payload. The payload should contain at least three different data fields, with each field having specific requirements. Additionally, the code should handle any poss... | codefeedback |
[
{
"content": "Develop a program to spell a given word using only vowels.\n\"Hello\"",
"role": "user"
},
{
"content": "Here's an example program in Python that spells a given word using only vowels:\n\n```python\ndef spell_with_vowels(word):\n vowels = \"aeiou\"\n spelled_word = \"\"\n\n for... | codefeedback |
[
{
"content": "Get all permutations of a string.\nstring = \"abc\"\n\n# Erroneous Code #\n```python\ndef get_permutations(string):\n if len(string) <= 1:\n return [string]\n \n permutations = []\n for i in range(len(string)):\n for perm in get_permutations(string[:i] + string[i+1:]):\n ... | codefeedback |
[
{
"content": "Modify the following code so that it takes a string as a parameter, reverses it and prints out the reversed string. Additionally, the solution should be implemented using recursion instead of iteration. The input string will always be alphanumeric and can have a maximum length of 100 characters.",... | codefeedback |
[
{
"content": "Implement a method that reverses a doubly linked list.\n\nclass Node:\n def __init__(self, data=None):\n self.data = data\n self.next = None\n self.prev = None\n\ndef reverse_linked_list(head):\n # Reverses the doubly linked list and returns the new head\n pass\n\nhea... | codefeedback |
[
{
"content": "Write a function to find the smallest subarray with a given sum.\n\nThe input to the function is an array of positive integers and a target sum. The function should return the length of the smallest subarray in the input array that has a sum greater than or equal to the target sum. If no such suba... | codefeedback |
[
{
"content": "Create a function that takes in two strings and determines if the strings are anagrams, but with the additional constraint that the function must be case-insensitive.",
"role": "user"
},
{
"content": "To create a function that determines if two strings are anagrams, with the additional... | codefeedback |
[
{
"content": "Find the number of different words in a string of unlimited length, while also considering case sensitivity and punctuation marks.\n\n# Explanation #\nIn this test, you need to count the number of unique words in a given string. However, unlike the previous test, you also need to consider case sen... | codefeedback |
[
{
"content": "Create a Python program that finds the highest number in a list of numbers. Additionally, if the list is empty, the program should display an error message indicating that the list is empty.",
"role": "user"
},
{
"content": "Here is a Python program that finds the highest number in a l... | codefeedback |
[
{
"content": "Create a function in Python that takes two integers N and M and prints out all possible combinations of numbers that add up to N and are at most M. Additionally, implement a check to ensure that each combination is unique. \nFor example, given N=8 and M=3, the function should print out the followi... | codefeedback |
[
{
"content": "Convert an array of tuples of 2 numbers into an array of complex numbers, while also sorting the resulting array based on the magnitude of the complex numbers in descending order.\ntuple_array = [(3,4), (5,6), (7,8)]",
"role": "user"
},
{
"content": "You can convert the array of tuples... | codefeedback |
[
{
"content": "Create a python program that takes a string as input and prints the length of the longest substring without repeating characters. The program should also print the actual longest substring.\n\nFor example, if the input string is \"abcabcbb\", the program should output:\nLongest substring without r... | codefeedback |
[
{
"content": "Implement a class hierarchy for a zoo simulation. The hierarchy should include a base class called \"Animal\" with subclasses such as \"Mammal,\" \"Reptile,\" and \"Bird.\" Each subclass should have at least two unique properties and one unique method. Additionally, the \"Animal\" class should hav... | codefeedback |
[
{
"content": "Write a program that calculates the average and standard deviation of a given set of survey results. The program should then display the results in an HTML table.\n\nInput:\n- An array of survey results in percentage format. The array can have any number of elements.\n\nOutput:\n- An HTML table th... | codefeedback |
[
{
"content": "Construct a dictionary from the provided list of tuples such that the keys and values are switched. The tuples will contain strings and integers. The keys in the original tuples will have unique values. The dictionary should be sorted in ascending order based on the original values in the tuples. ... | codefeedback |
[
{
"content": "Create a function that filters the numbers in the given list and returns a new list containing prime numbers only. The function should also exclude any negative numbers and raise a ValueError if the list is empty or contains any non-integer values. The output list should be sorted in descending or... | codefeedback |
[
{
"content": "Provide an example of a Python class and its elements, ensuring that the class has at least two methods, each with a different parameter and return type. Additionally, implement a class variable that is accessible by all instances of the class, and a class method that modifies the class variable."... | codefeedback |
[
{
"content": "Replace each character of a string with the next character in alphabetic order, taking into consideration uppercase and lowercase letters.",
"role": "user"
},
{
"content": "Here's a Python function that replaces each character of a string with the next character in alphabetical order, ... | codefeedback |
[
{
"content": "Create a class named 'Shape' which has a method 'getArea' that takes in a length and width as parameters and returns the area of the shape. The length and width should both be positive integers.",
"role": "user"
},
{
"content": "Here's the implementation of the 'Shape' class in Python:... | codefeedback |
[
{
"content": "Create an array of length 1000 and set the values to the first 1000 prime numbers.",
"role": "user"
},
{
"content": "To create an array of length 1000 and set the values to the first 1000 prime numbers, you can write a code in a programming language such as Python. Here's an example co... | codefeedback |
[
{
"content": "Generate code to remove duplicate characters from a string and return the resulting string sorted in reverse order.\n\nstring = \"google\"",
"role": "user"
},
{
"content": "Here's the code in Python to remove duplicate characters from a string and return the resulting string sorted in ... | codefeedback |
[
{
"content": "Implement a recursive binary search algorithm to find the index of a given target value in a sorted array. The algorithm should return -1 if the target value is not present in the array. Your implementation should have a time complexity of O(log n).",
"role": "user"
},
{
"content": "He... | codefeedback |
[
{
"content": "Design a function that takes in a positive integer greater than 1 and prints the multiplication table for that input number. The function should exclude all multiples of 3 from the table.",
"role": "user"
},
{
"content": "Here is a Python implementation of the function that takes in a ... | codefeedback |
[
{
"content": "How to efficiently check if a given number is an Armstrong number in Python, using a time complexity of O(log n)?",
"role": "user"
},
{
"content": "To efficiently check if a given number is an Armstrong number in Python, using a time complexity of O(log n), you can follow these steps:\... | codefeedback |
[
{
"content": "Generate a code to reverse a string without using any loop or recursion.\nInput String = \"Hello World!\"",
"role": "user"
},
{
"content": "You can reverse a string without using any loop or recursion by using the built-in `slice()` function. Here's the code:\n\n```python\ninput_string... | codefeedback |
[
{
"content": "Parse the following text and remove all non-alphanumeric characters. Then, count the occurrences of each word in the text and display them in descending order of frequency.\n\nInput: \"Hello$#@, this is a te*x&t\"\n\nOutput: \n- \"Hello\" : 1\n- \"this\" : 1\n- \"is\" : 1\n- \"a\" : 1\n- \"te\" : ... | codefeedback |
[
{
"content": "Change the given array to a singly linked list without using a loop and in reverse order.\narray = [5, 4, 3, 2, 1]",
"role": "user"
},
{
"content": "To convert the given array to a singly linked list in reverse order without using a loop, we can use a recursive approach. Here is the im... | codefeedback |
[
{
"content": "Complete the following function to output a reversed string, but you are not allowed to use any built-in string reversal functions or methods.",
"role": "user"
},
{
"content": "Here is one possible solution:\n\n```python\ndef reverse_string(input_str):\n # Convert the string into a ... | codefeedback |
[
{
"content": "Increase the difficulty of the given programming test question by introducing a new requirement:\n\n- Modify the given code to set the third parameter to 0 without using any conditional statements (e.g., if, else, switch) or arithmetic operators (e.g., +, -, *, /, %).",
"role": "user"
},
{... | codefeedback |
[
{
"content": "Compose a program to reverse a list of numbers without using any built-in functions or methods. The program should only use a single loop and a constant amount of extra space. The time complexity should be O(n), where n is the length of the input list.",
"role": "user"
},
{
"content": ... | codefeedback |
[
{
"content": "Program a function to remove all prime numbers from an array",
"role": "user"
},
{
"content": "To remove all prime numbers from an array, you can follow the steps below:\n\n1. Create a function, let's call it `remove_primes`, that takes an array as input.\n2. Inside the function, creat... | codefeedback |
[
{
"content": "Write a code to encode a given body of text into base64, but also ensure that the encoding is done in reverse order of the usual base64 encoding. For example, instead of encoding 'Hello World' as 'SGVsbG8gV29ybGQ=', you should encode it as 'QGQsYmGsbydibGk=ZG90dGVyL2J5dGVzOg=='.",
"role": "use... | codefeedback |
[
{
"content": "Given a list of tuples representing a tree structure, where each tuple contains two elements: the value of a node and a list of its children, output the tree structure in Python. The output should include the parent-child relationship and indentation to indicate the level of each node.\n\nFor exam... | codefeedback |
[
{
"content": "Compile a function that checks if a number is a perfect square and a prime number. Output true if both conditions are met, false otherwise.",
"role": "user"
},
{
"content": "Here is the compiled function in Python:\n\n```python\nimport math\n\ndef is_perfect_square_and_prime(num):\n ... | codefeedback |
[
{
"content": "Write a function that sorts an array of strings in ascending order based on the number of distinct characters in each string. If two or more strings have the same number of distinct characters, sort them lexicographically.\n\n#Erroneous Code Reference#\nProvide an erroneous code snippet that attem... | codefeedback |
[
{
"content": "Output the longest consecutive string of non-repeating characters in a given string.",
"role": "user"
},
{
"content": "Here is a possible solution in Python:\n\n```python\ndef longest_non_repeating_substring(s):\n max_len = 0\n start = 0\n seen = {} # To store the last seen i... | codefeedback |
[
{
"content": "Using Numpy, create an array of size 10 and fill it with unique random integer numbers between 0 and 9, without using any loops.",
"role": "user"
},
{
"content": "Here is the code to create an array of size 10 filled with unique random integer numbers between 0 and 9 using numpy:\n\n``... | codefeedback |
[
{
"content": "Take an array of integers and return true if there is a triplet whose sum is equals to the given target. The triplet should consist of unique elements and the sum of any two elements in the triplet should not be equal to the target. Additionally, the function should return false if there are more ... | codefeedback |
[
{
"content": "Create a function that takes a matrix (MxN array) and returns a new matrix where each element is the sum of the corresponding element in the original matrix and its neighboring elements (top, bottom, left, right).",
"role": "user"
},
{
"content": "To solve this problem, we can iterate ... | codefeedback |
[
{
"content": "Implement a sorting algorithm which takes an array of integers as input and sorts it in ascending order. The sorting algorithm must use a time complexity of O(nlogn) and must not use any built-in sorting functions or libraries. The input array may contain duplicate values and the algorithm must ha... | codefeedback |
[
{
"content": "Given a target number, find three numbers in the list whose sum is equal to the target number.\nlist = [2, 7, 11, 15, 6, 3], target = 20",
"role": "user"
},
{
"content": "To find three numbers in the list whose sum is equal to the target number, we can use the two-pointer approach. \n\... | codefeedback |
[
{
"content": "Given an array of numbers, find the maximum product of any three distinct numbers in the array. The array will have at least 6 numbers. You may not use sorting or nested loops to solve this problem.\narr = [2, 5, 6, 9, -2, -7, -1]",
"role": "user"
},
{
"content": "To find the maximum p... | codefeedback |
[
{
"content": "Given an array of positive integers, find the longest subarray with the total sum equal to the given sum. The subarray must contain at least one odd integer and one even integer. Return the subarray itself.\narr = [2, 5, 1, 6, 3, 4], sum = 8",
"role": "user"
},
{
"content": "One possib... | codefeedback |
[
{
"content": "Calculate the total number of unique elements in this array, where each sub-array contains exactly two elements. Additionally, the elements in each sub-array are restricted to be positive integers greater than zero.",
"role": "user"
},
{
"content": "In order to calculate the total numb... | codefeedback |
[
{
"content": "Given a list of distinct integers, generate all possible permutations of the list. The generated permutations should be stored in a list and returned in lexicographic order. Your solution should not use any built-in functions or libraries for generating permutations.",
"role": "user"
},
{
... | codefeedback |
[
{
"content": "Use regex to extract words from the sentence 'Some of my favorite words are pencil, dinosaur, and coffee.' Then, convert all the extracted words to uppercase and count the frequency of each word. Finally, display the words in descending order of their frequency.",
"role": "user"
},
{
"... | codefeedback |
[
{
"content": "Find the longest palindromic substring of this string.\nstring = \"carrace\"\n\n# New Problem #\nGiven a string, find the longest palindromic substring within the string. A palindromic substring is a substring that remains the same when its characters are reversed.\n\nExample:\nInput: \"carrace\"\... | codefeedback |
[
{
"content": "Write the code for a function that takes two parameters n and m and returns the sum of the first n prime numbers starting with m.",
"role": "user"
},
{
"content": "To solve this problem, we can define a helper function `is_prime` that checks if a number is prime. Then, we can iterate t... | codefeedback |
[
{
"content": "Write the code to create a one-dimensional array and initialize it with random numbers between 1 and 100 of length 4. The array must not contain any repeated numbers.",
"role": "user"
},
{
"content": "Here's an example code in Python to create a one-dimensional array and initialize it ... | codefeedback |
[
{
"content": "Find the inverse of the given matrix\n[ [5, 7, 2], [3, 1, 6], [4, 8, 9] ]\n\n#Erroneous Code#\n```\ndef matrix_inverse(matrix):\n if len(matrix) != len(matrix[0]):\n raise ValueError(\"Matrix must be square.\")\n \n determinant = calculate_determinant(matrix)\n if determinant ==... | codefeedback |
[
{
"content": "Find the sum of the first 10 positive integers, where the sum must be calculated using a recursive function and the output should be displayed in reverse order.",
"role": "user"
},
{
"content": "To calculate the sum of the first 10 positive integers using a recursive function, we can d... | codefeedback |
[
{
"content": "Develop a code to get the current date and time and print it, but you are not allowed to use any built-in date or time functions or libraries. You need to implement your own algorithm to calculate the current date and time.",
"role": "user"
},
{
"content": "To get the current date and ... | codefeedback |
[
{
"content": "Replace words with corresponding synonyms in the given text, while maintaining the original word order and preserving capitalization.\n\ntext: \"The cat is lazy and likes to sleep during the day.\"\nword: \"sleep\"\nsynonym: \"nap\"\n\nAdditional Instructions:\n1. Implement the solution using a Tr... | codefeedback |
[
{
"content": "Write a python code to insert a new node at the head of a doubly linked list and ensure that the linked list remains sorted in ascending order.",
"role": "user"
},
{
"content": "Here is a Python code to insert a new node at the head of a doubly linked list and ensure that the linked li... | codefeedback |
[
{
"content": "Create an array of prime numbers in descending order starting from 1000 to 2 using a for loop.",
"role": "user"
},
{
"content": "Here is the code to create an array of prime numbers in descending order from 1000 to 2 using a for loop in Python:\n\n```python\nprimes = []\n\nfor num in r... | codefeedback |
[
{
"content": "Generate a Matrix with random integers between 1-50 where each row and column has at least one prime number, and output the Matrix.\nrows = 5\ncolumns = 6",
"role": "user"
},
{
"content": "Here is a matrix with 5 rows and 6 columns, where each row and column contains at least one prime... | codefeedback |
[
{
"content": "Using the given list of strings, create a new list that contains only the lowercase letters. The input list can contain a maximum of 10^6 strings, and each string can have a maximum length of 10^3 characters. The output list should be sorted in ascending order. The time complexity of your solution... | codefeedback |
[
{
"content": "Sort the list below using modified insertion sort in Python:\nlist = [1,12,1,4,8,10,13]\n\n- The modified insertion sort should sort the list in descending order.\n- The modified insertion sort should not use any built-in sorting functions or methods.\n- The modified insertion sort should be imple... | codefeedback |
[
{
"content": "Suggest the best algorithm to reverse a string without using any additional data structures and with a time complexity of O(n), where n is the length of the string.",
"role": "user"
},
{
"content": "One possible algorithm to reverse a string without using additional data structures and... | codefeedback |
[
{
"content": "Write a code to add two integers without any type conversion, using only bitwise operators.",
"role": "user"
},
{
"content": "Here's a code snippet in Python that adds two integers without any type conversion, using only bitwise operators:\n\n```python\ndef add_without_conversion(a, b)... | codefeedback |
[
{
"content": "Convert the following matrix into a list of lists in Python. The matrix contains n rows and m columns, where n and m are positive integers. The elements in each row are in ascending order, and the elements in each column are in descending order. Find an algorithm with a time complexity of O(n+m) t... | codefeedback |
[
{
"content": "Create an array of size 10 with each element being a random prime number between 1 and 100.",
"role": "user"
},
{
"content": "Here is one possible solution in Python:\n\n```python\nimport random\n\ndef is_prime(n):\n if n <= 1:\n return False\n for i in range(2, int(n**0.5... | codefeedback |
[
{
"content": "Design a function which prints all the permutations of a given list of numbers, while also counting the total number of permutations and returning it as a result.",
"role": "user"
},
{
"content": "Here's a Python function that uses recursion to find and print all permutations of a give... | codefeedback |
[
{
"content": "Design a function in Python to toggle whether a given HTML tag has a given class and remove any other classes present in the tag. The function should also handle nested HTML tags.\n<div class=\"myClass\">Hello world</div>\n\n#Erroneous Code Example#\ndef toggle_class(tag: str, class_name: str) -> ... | codefeedback |
[
{
"content": "Find the minimum value from a given array. However, you are not allowed to use any built-in functions or methods for finding the minimum value (e.g. min() function, sorting the array and taking the first element, etc.). You must come up with your own algorithm to solve this problem. The array may ... | codefeedback |
[
{
"content": "Develop a Python code to extract all words from a sentence that begin with a specific letter and have a length greater than or equal to 3. \nsentence = \"I love coding in Python\"\nletter = \"P\"",
"role": "user"
},
{
"content": "Here is the Python code to extract all words from a sent... | codefeedback |
[
{
"content": "Write a generic code for traversing a binary tree in post-order and counting the number of nodes greater than a given value.",
"role": "user"
},
{
"content": "Here's a generic code in Python for traversing a binary tree in post-order and counting the number of nodes greater than a give... | codefeedback |
[
{
"content": "Write a recursive function that calculates the factorial of a given number.",
"role": "user"
},
{
"content": "Here is a recursive function in Python that calculates the factorial of a given number:\n\n```python\ndef factorial(n):\n # Base case: factorial of 0 is 1\n if n == 0:\n ... | codefeedback |
[
{
"content": "Extract all the strings that match the following regex pattern from a given text block which is in the format \"name #number\", where the name can be any alphanumeric characters and the number is a 4-digit integer. The extracted strings should be sorted in ascending order based on the number.",
... | codefeedback |
[
{
"content": "Create a multi-dimensional array in Python where each element is a randomly generated integer between 1 and 100. The array should have dimensions of at least 5x5 and should be populated in a way that no two elements in the same row or column have the same value.",
"role": "user"
},
{
"... | codefeedback |
[
{
"content": "Print the maximum element in a linked list, while also keeping track of the second maximum element. Additionally, you need to find the index position of the maximum element in the linked list.",
"role": "user"
},
{
"content": "To solve this problem, we can iterate through the linked li... | codefeedback |
[
{
"content": "Compute the average of the elements of the given list, but with the following constraints:\n1. The list may contain duplicates, and they should be counted individually in the average calculation.\n2. The average should be rounded to the nearest integer.\n3. You are not allowed to use any built-in ... | codefeedback |
[
{
"content": "Suggest a data structure that can be used to store contacts information, where each contact should have a unique identifier, and the phone number must be in a specific format (e.g., +1 (123) 456-7890). Additionally, implement a function to search for contacts based on their email domain.",
"ro... | codefeedback |
[
{
"content": "Provide a function to implement a Binary Tree traversal. However, the function should not use recursion and should instead use an iterative approach.",
"role": "user"
},
{
"content": "Here's an example of a function that implements an iterative approach for binary tree traversal using ... | codefeedback |
[
{
"content": "Implement the bottom up cut rod algorithm in Python, ensuring that the time complexity of your solution is O(n^2) and the space complexity is O(n).",
"role": "user"
},
{
"content": "Sure! Here's an implementation of the bottom-up cut rod algorithm in Python with a time complexity of O(... | codefeedback |
[
{
"content": "Write code to convert a given string to all uppercase letters in Python, but without using the built-in `upper()` function.",
"role": "user"
},
{
"content": "To convert a given string to all uppercase letters in Python without using the `upper()` function, you can iterate through each ... | codefeedback |
[
{
"content": "Implement a class to implement a Huffman coding algorithm, but without using any built-in data structures or libraries for sorting or priority queue. You must create your own data structure and implement the sorting and priority queue functionalities from scratch.",
"role": "user"
},
{
... | codefeedback |
[
{
"content": "Sort the string list in descending order based on the sum of the ASCII values of each character in the key and the value.",
"role": "user"
},
{
"content": "Here is the code to sort the string list in descending order based on the sum of the ASCII values of each character in the key and... | codefeedback |
[
{
"content": "Given a string s, create a function to find the character that appears the most and return its index. The function should only consider alphanumeric characters and ignore any special characters or whitespaces. Additionally, the function should be case-insensitive. If multiple characters have the s... | codefeedback |
[
{
"content": "Given a list of strings, write a function to sort them alphabetically in ascending order while considering the case sensitivity. The function should handle strings with special characters and leading/trailing whitespaces. The function should return a new sorted list without modifying the original ... | codefeedback |
[
{
"content": "Convert the given nested hashmap {'name1': {'subname1': 'value1'}, 'name2': {'subname2': 'value2'}} to a JSON string. The time complexity should not exceed O(n^2), where n is the total number of elements in the hashmap.",
"role": "user"
},
{
"content": "To convert the given nested hash... | codefeedback |
[
{
"content": "Create a function that takes an integer n as an argument and returns the sum of all prime numbers from 1 to n. The function should have a time complexity of O(n√n).\nn = 10",
"role": "user"
},
{
"content": "To solve this problem, we will use the Sieve of Eratosthenes algorithm to effic... | codefeedback |
[
{
"content": "Describe the process of writing a recursive program to calculate the factorial of a given number. Include additional reasoning steps to demonstrate your understanding of recursion and its implementation.",
"role": "user"
},
{
"content": "Writing a recursive program to calculate the fac... | codefeedback |
[
{
"content": "Find the max 2 numbers in a list of n numbers without using any comparison operator. The list can contain both positive and negative integers, and the numbers can be repeated.\n\n#Additional Requirements#\n1. The solution should have a time complexity of O(n).\n2. The solution should have a space ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.