instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write an SQL query to calculate the median salary of all employees in a table, rounded to the nearest integer. | codefeedback |
Create a JavaScript function which takes a string as a parameter and returns the most frequent character in the string. The function should handle uppercase and lowercase characters as the same. The string can contain special characters and spaces. If there are multiple characters with the same highest frequency, retur... | codefeedback |
Write a Python program to remove all instances of a given value from a given list, but without using any built-in Python methods or libraries. The program should only use basic programming constructs and logic to achieve the desired result. | codefeedback |
Create a JavaScript function that takes a given sentence as a parameter and capitalizes the first letter of each word. Additionally, the function should ignore any words that contain numbers or special characters. The sentence should be at least 10 words long. | codefeedback |
Create a Java program which takes an integer array as a parameter, sorts the array in descending order using a merge sort algorithm, and returns the sorted array.
Additional Requirements:
- The time complexity of the sorting algorithm should be O(n log n).
- The space complexity should be O(n). | codefeedback |
Create a list comprehension that takes all the elements of list_one and creates a new list where all the elements are doubled, but only if they are odd numbers. If an element is an even number, it should be squared instead of doubled.
list_one = [1, 2, 3, 4, 5] | codefeedback |
Construct a function that takes in a list of integers and returns a new list containing only the even numbers in the original list. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the input list.
#Sample Input#
[1, 2, 3, 4, 5, 6]
#Sample Output#
[2, 4, 6] | codefeedback |
Write an SQL query to calculate the difference between the total salaries of male and female employees in a table, but exclude any employees who have been with the company for less than 5 years.
#Reasoning#
By adding the additional requirement of excluding employees with less than 5 years of experience, the difficulty... | codefeedback |
Create a C# program which takes two strings as parameters, and returns true if the two strings are anagrams of each other. The program should have a time complexity of O(n log n) and a space complexity of O(1). | codefeedback |
Create a JavaScript program which takes an array of integers as a parameter and reverses the array in-place. The program should return the reversed array without using any built-in methods like `reverse()`. Additionally, the program should handle cases where the input array is empty or contains non-integer elements.
... | codefeedback |
Create a for loop that goes through every element of list_of_words, prints ‘success’ if an element is equal to “example” and prints ‘failure’ in any other case. Additionally, the loop should break and return the number of elements processed if the word "break" is encountered. Finally, the loop should also count the num... | codefeedback |
You are given a matrix of m rows and n columns. Write a function that calculates the transpose of the given matrix.
The transpose of a matrix is obtained by changing rows to columns and columns to rows. For example, the transpose of the matrix
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
is
[[1, 4, 7],
[2, 5, 8],
[... | codefeedback |
Write a function that takes in a string and returns a list of all the words that have more than 5 characters, while ignoring any words that contain duplicate characters. The function should have a time complexity of O(n), where n is the length of the input string. | codefeedback |
In a given string, create a function that returns the longest consecutive sequence of characters, but with the constraint that the function should have a time complexity of O(n) and a space complexity of O(1).
my_string = "abccdeefghj" | codefeedback |
Create a function that takes in a string and replaces all punctuation marks (including commonly used ones such as period, comma, and exclamation mark, as well as less common ones such as em-dash and ellipsis) with a space. The function should also remove any consecutive spaces resulting from the replacement. | codefeedback |
Create a function that takes in a string and counts the number of vowels in it, while also considering uppercase vowels. The function should ignore any non-alphabet characters and spaces in the string. The function should return a dictionary that includes the count of each vowel found in the string. The function should... | codefeedback |
Write a SQL query to add a new column "age" in the employees table, where the age is calculated based on the birthdate column. | codefeedback |
Design a function in Python to delete duplicates from a list, while also keeping track of the count of each duplicate element. The list is: [2, 3, 2, 4, 5, 5, 6]
#Additional Instructions#
1. Implement the function without using any built-in Python functions or libraries.
2. The function should return a new list with t... | codefeedback |
Create a web page using HTML and CSS that displays a div with some text. However, the text should change color every 2 seconds and rotate between a list of predefined colors. Additionally, when the user hovers over the div, the text should increase in size by 10%. | codefeedback |
Create a new CSS animation rule to rotate an object a full circle while simultaneously changing its color from blue to red. The animation should last for 5 seconds and the object should also scale up and down by 20% during the rotation. | codefeedback |
Write a JavaScript function to capitalize the first letter of each word in a string. Additionally, convert all lowercase letters to uppercase and all uppercase letters to lowercase for all other characters in the string.
String: "tHiS iS An eXaMpLe". | codefeedback |
What is the largest prime factor of the number 885 that is greater than 100? | codefeedback |
Create a Regular Expression pattern to find words that contain the letters "a", "b", "c", and "d", in that specific order and without any additional letters in between. | codefeedback |
Write a code to remove the duplicates from a given list without using any built-in functions or data structures such as sets or dictionaries. The input list can contain any type of elements, and the order of the elements should be preserved in the output.
Example:
Input: [1,2,3,1,2]
Output: [1,2,3]
Note: You are not... | codefeedback |
Write a code to generate a random number between 1 to 100 and store it in a variable. Then, generate another random number between 1 to 10 and add it to the previous number. Repeat this process 10 times and print out the sum of all the generated numbers. | codefeedback |
Write a code to delete all the vowels and any word that starts with a vowel from a given string.
string = "hello world, how are you?" | codefeedback |
Write a code to create a 3 x 3 matrix containing all 0s, but the matrix must be initialized using a recursive algorithm instead of a simple loop. | codefeedback |
Write a function in Java that takes two strings as parameters and returns true if the first string is a substring of the second. Additionally, the function should also return true if the first string is a subsequence of the second string.
A subsequence is defined as a sequence that can be derived from another sequence... | codefeedback |
Write a code to check whether two strings are anagrams or not. The strings may contain upper and lower case alphabets, numbers, and special characters.
Example:
first = "LiStEn!@12"
second = "Silent 21@$"
Note: The code should consider all characters in the strings and not be case sensitive. The time complexity of th... | codefeedback |
Write a function that sorts the given list of numbers in descending order, but without using any built-in sorting functions or libraries. | codefeedback |
Create a program to convert the input sentence to Pig Latin, while also handling punctuation marks and capitalization.
The Pig Latin rules are as follows:
1. If a word begins with a vowel, add "way" to the end of the word.
2. If a word begins with a consonant, move the consonant to the end of the word and add "ay" to ... | codefeedback |
Create a program to create a list of all the prime numbers between 1 and 100. | codefeedback |
Create a program to find all the prime factors of a given number, where the prime factors are the factors that are prime numbers.
Input: 24 | codefeedback |
Create a program to generate the sum of all the elements in a given list. The program should be able to handle large input lists with thousands or millions of elements efficiently. The time complexity of the solution should be less than O(n^2), where n is the number of elements in the input list. Additionally, the prog... | codefeedback |
Create a program to check if a given string is a palindrome. The string may contain uppercase and lowercase letters, numbers, and special characters. The program should ignore any spaces or punctuation marks and only consider the alphanumeric characters in the string.
Example 1:
Input: "A man, a plan, a canal, Panama!... | codefeedback |
Create a program that implements a more complex logic for the given switch statement.
Extend the switch statement to include additional cases, such as case 3, case 4, and so on. Each case should call a different function, such as func3(), func4(), and so on.
Additionally, modify the program to include a default case... | codefeedback |
Create a program to generate all possible pairs of a given list of numbers where the sum of each pair is a prime number. | codefeedback |
Generate a 5x5 array with all its elements equal to 1, ensuring that each row and column sum up to 10. | codefeedback |
Classify the following sentence as a question, a statement, or an exclamation.
Have you ever experienced the unparalleled joy of devouring a perfectly seasoned and expertly prepared brussel sprout? | codefeedback |
Find the total number of elements in a given multi-dimensional array. The array may contain integers, nested arrays, and even other data types such as strings or booleans. The elements can be located at any depth within the array structure.
#Example Input
array1 = [[1,2], 3, 4]
#Expected Output
5
#Example Input
array... | codefeedback |
Classify the sentiment of the given sentence, taking into account not only the presence of positive or negative words but also the overall context and tone. Consider factors such as sarcasm, irony, and subtle nuances that may affect the sentiment classification. Additionally, implement a machine learning algorithm to i... | codefeedback |
Create a JavaScript function that finds the shortest word in a string, excluding words that contain any uppercase letters or special characters. The function should return the shortest word that is longer than 3 characters and has at least one vowel. The string may contain punctuation marks and multiple spaces between ... | codefeedback |
Write a function to compare two strings and return True if they are anagrams. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. The function should ignore any spaces and capitalization.
str1 = 'Debit card'
str2 = 'Bad credit'
#Additional Constraints#
- The function should hav... | codefeedback |
Write a SQL query to get the total amount from orders table where status is "complete" and the order was placed after a specific date. | codefeedback |
Write a code to take two string inputs, str1 and str2, where the length of str1 is equal to the length of str2. The code should generate the output string containing alternate characters from each string, but the output string should not contain any repeated characters. | codefeedback |
Write a SQL query to find the names, job titles, and salaries of all employees working at a given department, sorted by salary in descending order. | codefeedback |
Given a list of strings, write a code to find the longest string. The length of each string in the list should be at least 3 characters. The code should ignore any strings that contain special characters or numbers. The final result should be in uppercase letters.
lst = ['one', 'two', 'three', '4four', 'fi!ve'] | codefeedback |
Write a code to check whether the input string is a palindrome or not. However, you are not allowed to use any additional data structures (such as arrays or stacks) and you must solve the problem in-place with constant extra space. The solution should have a time complexity of O(n), where n is the length of the input s... | codefeedback |
Write a Django Model API to store status, published date, and author information for a blog post. Additionally, the API should include methods to retrieve all blog posts published within a given date range and to retrieve the total number of published blog posts for each author.
Note: The author information should inc... | codefeedback |
Write a code to compare two lists and find the common elements, taking into consideration that both lists can contain duplicate elements and the output should only include the common elements once. Additionally, the code should have a time complexity of O(n+m), where n and m are the lengths of the two lists.
list1 = [... | codefeedback |
Write a JavaScript code to calculate the factorial of a number, but with the additional requirement that the code should handle negative numbers as input and return an error message for negative input. | codefeedback |
Connect to a MySQL database and select all rows from Customers where Phone is greater than 1000 and Country is "USA". | codefeedback |
Write a function that checks if a string is a palindrome or not, but with an additional constraint:
- The function should not use any built-in string reversal functions or data structures (e.g. slicing, reverse() function, stack, etc.).
string = "ana" | codefeedback |
Write a recursive algorithm to generate the Fibonacci series up to the nth term. Additionally, implement a memoization technique to optimize the algorithm's performance. | codefeedback |
Write efficient C++ code to find the maximum subarray sum of a given array, taking into consideration that the array can contain both positive and negative integers. The code should also keep track of the starting and ending indices of the subarray that results in the maximum sum. | codefeedback |
Write a code to return the first 3 prime numbers in a list of integers.
mylist = [1,4,3,6,7,2,4] | codefeedback |
Write a function to remove duplicate items in a list. However, the function should only remove duplicates if they appear consecutively in the list. For example, if the list is [2, 3, 3, 4, 5, 6, 4, 7], the function should return [2, 3, 4, 5, 6, 4, 7].
mylist = [2, 3, 3, 4, 5, 6, 4, 7] | codefeedback |
Parse the string "Hello[1]World[4]123[3]" into a list, where the numbers inside the square brackets indicate the number of times the preceding word should be repeated. If a number is not specified, the default repetition is 1. The words and their repetitions should be stored in a dictionary, where the words are the key... | codefeedback |
Read a code and find all the function calls that are made, while also tracking the number of times each function is called.
Sample Input:
```python
print('Hello world!')
my_function()
my_function2(2, 3)
my_function()
```
Sample Output:
```
Function calls:
- print: 1
- my_function: 2
- my_function2: 1
``` | codefeedback |
Create a for loop to print the prime numbers from 1 to 100. | codefeedback |
Create a Linked List Node with the data of type integer. The node should also have a reference to the next node and a reference to the previous node. | codefeedback |
Generate a unique and random password for a user using python. The password must be at least 8 characters long and contain a combination of uppercase letters, lowercase letters, numbers, and special characters. | codefeedback |
For the following two arrays, create a code snippet to return the intersecting element. The solution must have a time complexity of O(n), where n is the length of the arrays, and must not use any built-in intersection functions or data structures. Additionally, the code snippet should be implemented using only constant... | codefeedback |
Write a function to find the longest string in a list of strings, excluding any strings that contain numbers or special characters.
#Additional Requirements#
- Your solution should have a time complexity of O(n), where n is the total number of characters in all the strings combined.
- You should not use any built-in f... | codefeedback |
Write code to flatten a nested list of integers and return the sum of all the elements. | codefeedback |
Given a binary tree, write a code snippet to list all of its descendant nodes that are at an even level. | codefeedback |
Given a string, write a function to remove all the duplicate characters and return the resulting string. The input string may contain any ASCII characters.
#Example#
Input: "apple"
Output: "ale"
#Additional Test Cases#
Input: "banana"
Output: "ban"
Input: "racecar"
Output: "rce"
Input: "programming"
Output: "progmn... | codefeedback |
Implement a function that finds the maximum element in a given array. However, you are not allowed to use any built-in sorting functions or methods. Additionally, the time complexity of your solution should be less than O(n^2).
arr = [45, 7, 0, 82, 23] | codefeedback |
Implement a sentiment analysis model that can classify the sentiment of a given sentence as positive, negative, or neutral. The model should be able to handle sentences of varying lengths and complexities. | codefeedback |
Write code to find the intersection of two sorted lists. The intersection should contain only unique elements and should be sorted in ascending order.
list1 = [1, 3, 4, 6, 8, 9]
list2 = [1, 2, 5, 6, 8, 10]
#Expected Output#
[1, 6, 8] | codefeedback |
Write code to remove all occurrences of a given element from a list while maintaining the original order of the remaining elements. Additionally, the implementation should have a time complexity of O(n) and should not use any built-in functions or libraries to remove the elements. | codefeedback |
Implement a matrix multiplication algorithm using recursion. | codefeedback |
Generate a data structure that can efficiently store an array of words, where each word is stored in a Trie data structure. Additionally, implement a method that allows for efficient prefix matching, returning all words in the structure that have a given prefix. | codefeedback |
Reorder a given array in specialized order while maintaining the relative order of odd and even numbers. | codefeedback |
Create a function to generate a random password of length n, where n is the number of characters in the password.
Additional Requirements:
1. The password should contain at least one uppercase letter, one lowercase letter, one digit, and one special character.
2. The function should ensure that no two adjacent charact... | codefeedback |
Create a Ruby program to check if a number is even or odd, but you cannot use the modulus operator (%). | codefeedback |
Design a function in Python that returns the k-th smallest element in an array of integers. The array may contain duplicates and the function should handle both positive and negative integers. The function should have a time complexity of O(n) and space complexity of O(1). | codefeedback |
Create a program in C++ that calculates the absolute difference between two numbers. The program should be able to handle large numbers up to 10^9. Additionally, the program should have a time complexity of O(1). | codefeedback |
Write a JavaScript code to valid a password based on the following rules:
1. The password must be at least 8 characters long.
2. The password must contain at least one uppercase letter.
3. The password must contain at least one lowercase letter.
4. The password must contain at least one special character (!@#$%^&*).
5... | codefeedback |
Create a program that prints the first 20 Fibonacci numbers, but with a twist. Implement the Fibonacci sequence using a recursive function. | codefeedback |
Create an HTML page displaying a table of 4 rows and 5 columns. Each cell should contain a unique number from 1 to | codefeedback |
How would you determine if a given number is a prime number, while ensuring the time complexity is less than or equal to O(sqrt(n))? | codefeedback |
Create a function to reverse a string in-place (i.e., without using any extra space).
s = "hello world" | codefeedback |
Design an HTML form with the following fields: first name, last name, age, phone number, address, and email. The form should also include validation for each field, ensuring that the first name and last name are both at least 2 characters long, the age is a positive integer, the phone number follows a specific format (... | codefeedback |
Normalize a given array such that it adds up to a prime number. | codefeedback |
Write a Python function to calculate the factorial of a number (a non-negative integer). However, you are not allowed to use the built-in `math.factorial()` function.
In addition, you should implement the function recursively. | codefeedback |
Find the top 10 most common words in a given string, while also excluding any common stop words such as "the", "and", "a", "is", etc. Additionally, ensure that the solution runs in O(nlogn) time complexity, where n is the length of the input string. | codefeedback |
Write code to find the longest substring of unique characters in a given string, without using any built-in string functions or data structures.
string = 'abcabcbb' | codefeedback |
Find the longest common substring between two strings, case-insensitive.
s1 = "Tangible"
s2 = "Non-Tangible"
Note: A substring is a contiguous sequence of characters within a string.
You are required to implement a function called "longest_common_substring" that takes two strings as input and returns the longest co... | codefeedback |
Classify a given sentence based on the intention behind it, considering multiple possible intentions.
sentence = "I want to buy a car"
The program should analyze the sentence and determine the intention behind it by considering various possibilities, such as:
- The intention to express a desire or want.
- The intentio... | codefeedback |
Create a program to display all prime numbers between a given range, with the additional requirement that the program should also check for palindromic primes.
a, b = 2, 100 | codefeedback |
Write code to implement Bubble Sort.
Additional requirements:
- The sorting algorithm should be implemented as a function.
- The function should take an array of integers as input and return the sorted array.
- The function should handle arrays of any length.
- The function should handle arrays with duplicate elements... | codefeedback |
Write a code to remove the oldest elements from a list until the list contains at most 100 elements.
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ..., 110, 111, 112] | codefeedback |
Implement a function that calculates the Big O notation for a given algorithm's time complexity and return a string representation of the result. | codefeedback |
Write a Python function to check if a value exists in a list of integers, and return the number of occurrences of that value in the list. | codefeedback |
Write a code to multiply two numbers without using the multiplication operator. Additionally, you are not allowed to use any looping constructs (e.g. for loop, while loop) or any built-in functions or methods that directly perform multiplication. | codefeedback |
Given a string, create a function that takes out all the duplicated characters in the string and returns the modified string. The function should also sort the remaining characters in ascending order based on their ASCII values.
Example:
Input: 'Keeep Learning'
Output: ' LKpr'
Note:
- The input string may contain bot... | codefeedback |
Write a function that finds the most frequent item in an array, but with the following constraints:
- The function should have a time complexity of O(n log n), where n is the length of the array.
- The function should not use any built-in sorting or counting functions/methods.
- The function should use constant space ... | codefeedback |
Write a Javascript code to check if the given number is a prime number. Additionally, the code should also check if the number is a perfect square. | codefeedback |
Write an algorithm to perform binary search on a sorted array, ensuring that the time complexity is O(log n) and the space complexity is O(1). | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.