instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write an SQL query to get the name, age, and salary of the youngest employee who is not a manager, and has a salary greater than the average salary of all employees. | codefeedback |
Write a recursive algorithm to identify all elements with the given ID attribute in a given XML document. The algorithm should have a time complexity of O(n), where n is the number of elements in the XML document. Additionally, the algorithm should also check for nested elements and correctly identify elements with the... | codefeedback |
Write a web application that allows users to register for an account, log in, and send emails to other registered users.
The application should have the following features:
1. User Registration:
- Users should be able to create an account by providing a unique email address and a password.
- The email address s... | codefeedback |
Write a Java function to find out if a string contains any repeated vowels in consecutive order. The function should return the longest consecutive substring of repeated vowels found in the string.
Example:
Input: "Hello World"
Output: "oo"
Input: "The quick brown fox jumps over the lazy dog"
Output: ""
Note:
- The ... | codefeedback |
Write a HTML code snippet to create a table with three columns and five rows. Each cell in the table should contain a unique number from 1 to 15. Additionally, each number in the first column should be displayed in bold font. However, the numbers should be displayed in descending order instead of ascending order. | codefeedback |
Write a Python program to create a histogram for a given list of numbers, but instead of counting the occurrences of each number, count the occurrences of each unique pair of numbers in the list. The program should be able to handle large lists with a time complexity of O(n^2), where n is the length of the list. Additi... | codefeedback |
Create a JavaScript function for the linear search algorithm that searches for a specific element in an array. The function should take two parameters: the array to be searched and the element to be found. The function should return an array of all the indices where the element is found in the array, even if it occurs ... | codefeedback |
Write a JavaScript function that takes an argument and determines whether it is even or odd. However, you cannot use the modulus operator (%) or any arithmetic operators (+, -, *, /) to determine the parity of the number. | codefeedback |
Generate a valid Ruby code that implements the following function.
Replace all vowels in a string with the corresponding number of underscores.
The function should have a time complexity of O(n), where n is the length of the input string.
Note: The corresponding number of underscores for each vowel should be determin... | codefeedback |
Construct a C# method that calculates the area of a rectangle. The method should validate that the rectangle dimensions are positive integers and less than 1000, and throw an exception if they are not. Additionally, if the dimensions are not integers, round them to the nearest integer before calculating the area. | codefeedback |
Create a valid JavaScript array of objects containing the four elements "name", "age", "gender", and "hobbies". Each object should have a randomly generated name, age between 18 and 60, gender (either "male" or "female"), and an array of randomly generated hobbies (minimum 1 and maximum 5 hobbies per person).
Addition... | codefeedback |
Implement a function to generate the nth element in a Fibonacci series, where n is a positive integer. The function should have a time complexity of O(log n) and a space complexity of O(log n).
Note: You are not allowed to use iteration or recursion in the implementation. | codefeedback |
Create a class called "AdvancedCalculator" that has the following requirements:
1. It should have a constructor that takes two integers as parameters and stores them as instance variables.
2. It should have a method called "add" that returns the sum of the two integers.
3. The "add" method should check if both integ... | codefeedback |
Create an HTML page that includes a form.
The form should have inputs for a first name, last name, email, favorite color, and a submit button.
Add client-side validation to ensure that the email entered is in a valid format (e.g., contains "@" and ".com").
On submission of the form, display an error message if any of t... | codefeedback |
Write a React function that takes in an array of elements and sets the background color of each element to a random color. Additionally, ensure that each element's background color is unique and does not match the background color of any other element. | codefeedback |
Design and write a code to detect and count the number of occurrences of a particular substring in a string, while ignoring any occurrences that are part of a larger word. The code should also handle case-insensitive matching.
Requirements:
- The code should have a time complexity of O(n), where n is the length of the... | codefeedback |
Design and write a code to identify the maximum number of consecutive vowels contained in any given string. The code should also output the substring that contains the maximum number of consecutive vowels.
String = "Queensland"
However, the code should now have a time complexity of O(n^2), where n is the length of the... | codefeedback |
Design a program to create a new string with the characters of the first string in the reverse order, while ignoring any vowels and duplicate characters in the original string. The program should also handle the input string in a case-insensitive manner.
String = "HeLLo WoRld" | codefeedback |
Create a Python program to validate an email address according to RFC5322 syntax. Additionally, the program should check if the email address domain exists by performing a DNS lookup. The program should be able to handle multiple email addresses inputted by the user and should provide a list of valid email addresses al... | codefeedback |
Edit the following C++ code to print the twin prime numbers between 1 and 100. Twin prime numbers are prime numbers that differ by 2.
#include <iostream>
using namespace std;
int main()
{
int i, j;
cout << "The twin prime numbers between 1 and 100 are:";
for (i = 1; i <= 100; i++)
{
... | codefeedback |
Create a program to output the items in a list that appear only once. The list may contain integers, floats, strings, or a combination of these data types. The program should handle any input list size and provide the correct output.
In addition, the program should:
1. Handle lists with nested lists and dictionaries, ... | codefeedback |
Create a program to apply upper case to a given string, while also removing any duplicate characters. Additionally, implement a feature to count the occurrences of each character in the string and display the character along with its count in descending order. Handle any possible edge cases and invalid inputs appropria... | codefeedback |
Create a program to insert a given character at a particular position in a given string. However, the program should also handle the case where the given string is a sentence with multiple occurrences of the given character and the position refers to the Nth occurrence of the character. The program should also handle c... | codefeedback |
Suggest a good way to format the following array of objects in PHP, where each object represents a person and includes additional information such as their address, phone number, and email address. Ensure that the address field is limited to 50 characters, the phone number field follows a specific format (XXX-XXXX), an... | codefeedback |
Write a program in Python that connects to a MySQL database, selects a specific table, and updates a specific row in that table based on a given condition. | codefeedback |
Create a program that takes a string as input and outputs an array of words. Each word should be in uppercase and sorted in alphabetical order. The program should ignore any punctuation marks or special characters in the string. The input string should have a minimum length of 20 characters and contain at least one num... | codefeedback |
Create a for loop to iterate over a list of words and print their length. However, exclude any words that contain the letter "e" and contain an even number of letters.
words = ["happy", "sad", "tired", "energetic"]
#Difficulty Increased Explanation#
In the original test, the task was to iterate over a list of words a... | codefeedback |
Output the Fibonacci sequence from 0 to 15, but only include the odd numbers in the sequence. Additionally, implement the solution using a recursive approach with a maximum depth of 100. | codefeedback |
Write a ruby method that takes an array of integers and returns an array of their square root values, but also filters out any negative numbers and rounds the square root values to two decimal places. Additionally, the method should handle any invalid inputs, such as non-integer elements in the input array, by skipping... | codefeedback |
What is the most efficient way to check if a given number is a prime in Python, while also ensuring that the solution has a time complexity of O(sqrt(n)) and does not use any built-in libraries or functions for prime number generation or factorization, and additionally, the solution should not use any loops or recursio... | codefeedback |
Programmatically calculate the sum of the first 1000 prime numbers. | codefeedback |
Replace the last occurrence of a given word in a string, making sure the replacement is case-insensitive and maintaining the original capitalization of the word in the replaced string. Additionally, the replacement should only happen if the last occurrence of the word is not part of another word.
str = "Welcome to the... | codefeedback |
Write a code in Java to find all the prime numbers between 0 and n, where n can be as large as 10^9. Additionally, the code should be optimized to run within a time complexity of O(nlog(logn)).
Reference code:
```java
public class PrimeNumbers {
public static void main(String[] args) {
int n = 100;
... | codefeedback |
Implement a password validator in Java that meets the following requirements:
- The password must contain at least one uppercase letter.
- The password must contain at least one lowercase letter.
- The password must contain at least one digit.
- The password must contain at least one special character (!, @, #, $, %, ^... | codefeedback |
Given a JSON string, write a Python function to parse and organize the contents of the object. The function should handle nested arrays and objects, as well as an arbitrary depth of nesting within the JSON string.
Example Input:
{
"1": "Apple",
"2": "Orange",
"3": {
"A": "Banana",
"B": "Grape"
},
"4"... | codefeedback |
Write an algorithm to search for the first occurrence of a specific element in a linked list and return its index. If the element is not found, return -1. The time complexity of your algorithm should be O(n), where n is the number of elements in the linked list.
Additionally, you should implement your linked list as a... | codefeedback |
In Python, write a code snippet to calculate the average of prime numbers in a list.
listOfNumbers = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
# Additional Instructions #
1. Implement a function called is_prime(number) that takes in a number as input and returns True if the number is prime, and False otherwise.
- A number ... | codefeedback |
Implement an algorithm that returns the maximum sum of a subarray in a given array. The subarray can be any length, but it must be non-empty. If the array contains only negative numbers, the algorithm should return the smallest negative number. If the array contains both positive and negative numbers, the algorithm sho... | codefeedback |
Implement a sorting algorithm in C++ that can handle both ascending and descending order.
The sorting algorithm should have a time complexity of O(nlogn) and a space complexity of O(1).
The sorting algorithm should be able to handle arrays of size up to 10^7 elements.
The sorting algorithm should be able to handle arra... | codefeedback |
Write a JavaScript function that takes two numbers as parameters and returns their sum. The function should be named "addNumbers".
The function should only accept positive integers as inputs. If the input is not a positive integer, the function should throw an error.
Additionally, the function should check if the su... | codefeedback |
Write a SQL query to order the strings in the 'name' column alphabetically and then reverse the order, but exclude any strings that contain numbers or special characters. | codefeedback |
You are working on a Java application and need to implement a method that reads data from a file and performs some operations on it. However, there is a possibility that the file may not exist or may be corrupted. In such cases, you need to cleanly exit from the method using exceptions.
Write a Java method that takes ... | codefeedback |
Find the first occurrence of a repeated letter in the given string, but ignore any whitespace characters.
## Example ##
### Input ###
string = "abcde fghij"
### Output ###
Index: -1
### Explanation ###
Although the string contains repeated letters (e), they are separated by whitespace characters and should be ignor... | codefeedback |
Find all possible permutations of the string "ABC" that start with the letter "A" and end with the letter "B". | codefeedback |
Create an array of numbers that is a random combination of integers from 1 to 100. Additionally, ensure that the array does not contain any duplicate numbers. Sort the array in ascending order and then remove all odd numbers from the array. Finally, calculate the sum of all the remaining numbers in the array. | codefeedback |
Create a sentiment analysis program that classifies a given text into one of five sentiment categories: extremely negative, negative, neutral, positive, or extremely positive. Additionally, provide a sentiment score ranging from -100 to 100 to represent the intensity of the sentiment expressed in the text, with -100 in... | codefeedback |
Find the longest substring of a string without repeating characters and with at least one uppercase letter, one lowercase letter, one digit, and one special character.
string="aB$cAbcbb123" | codefeedback |
Explain the concept of tail recursion optimization and discuss its advantages over regular recursion. Provide an example to demonstrate the difference between the two. | codefeedback |
Create a Dictionary where the list items are the keys and the square of the items are the values. However, you are not allowed to use any built-in Python functions or operators to calculate the square of a number, and you are also not allowed to use any loop or recursion constructs.
myList1 = [1, 2, 3, 4, 5, 6] | codefeedback |
Convert the following XML code to JSON, while ensuring that the output JSON format follows the naming conventions specified in a separate configuration file. Additionally, the solution should handle XML elements with attributes and include them in the JSON output.
Please note that the configuration file may contain d... | codefeedback |
Develop a MATLAB function to calculate the product of two matrices, but without using the built-in matrix multiplication function (e.g., `*` or `matmul()`). Instead, you must implement your own algorithm to compute the matrix product.
Additionally, your implementation should handle matrices of different sizes and retu... | codefeedback |
Create a function that takes 2 strings as arguments, and returns the longest string. The function should also remove any duplicate characters in the returned string.
However, you are not allowed to use any built-in functions or libraries that can directly remove duplicate characters. You need to implement the logic to... | codefeedback |
Thoroughly analyze the following CSS code for potential errors, improvements, and optimization opportunities, considering design aesthetics and technical considerations:
1. Check if the color value "#FFFFFF" is a valid hexadecimal color code. If not, suggest a valid color code. Ensure the suggested color complements t... | codefeedback |
Design a function with three inputs that returns the maximum of the three, but you are not allowed to use any comparison operators (e.g., >, <, >=, <=) in your solution. | codefeedback |
## Updated Test ##
Compress a given string using Run Length Encoding
Write a function `run_length_encoding` that takes in a string as input and returns the compressed version of the string using Run Length Encoding.
**Example:**
```python
string = "AAABBBCCC"
print(run_length_encoding(string))
```
**Output:**
```
... | codefeedback |
Implement a function to retrieve the nth node from the end of a singly-linked list. The function should have a time complexity of O(n) and a space complexity of O(1). You are not allowed to modify the linked list structure or use any extra data structures. | codefeedback |
Modify the below code so that it swaps two variables without the use of a temporary variable and without using any arithmetic operators, bitwise operations, or any built-in swap functions. The solution should only use logical operations and the assignment operator.
```python
int a = 10, b = 20;
int temp;
temp = a;
a =... | codefeedback |
Design a React JS component to render a button that displays the text "Click Me" only if the user has successfully authenticated with a back-end server, has the necessary permissions, and the current date is within a specified date range. If any of these conditions are not met, the button should be disabled and display... | codefeedback |
Write a program that generates a random HTML document with a specified number of opening and closing tags, where the opening and closing tags are mismatched and the total number of opening and closing tags is greater than 100. | codefeedback |
Create a function that takes a list of integers and removes all duplicates. The function should return a new list with only the unique elements, and the order of the elements in the new list should be the same as the original list.
Example:
Input: [1, 2, 2, 3, 3, 3]
Output: [1, 2, 3]
Note:
- The input list may contai... | codefeedback |
Create a function that returns the sum of two numbers passed as arguments, with the additional requirement that the function must handle floating point numbers and round the result to the nearest integer. The function should also check if the input numbers are within the range of -1000 to 1000, inclusive. If the input ... | codefeedback |
You are given an expression tree, where each node represents either an operator or an operand. The operators can be one of the four basic arithmetic operations: addition (+), subtraction (-), multiplication (*), and division (/). The operands are integers.
Your task is to write a function that takes the expression tre... | codefeedback |
Given a string, replace all vowels in the string with a specified letter. The specified letter should be obtained by shifting the original vowel's ASCII value by a given number of positions. The ASCII values of vowels are as follows: 'a' = 97, 'e' = 101, 'i' = 105, 'o' = 111, 'u' = 117. The given number of positions ca... | codefeedback |
Write a function that retrieves the second to last element of a given array of strings, but only if the second to last element is longer than 5 characters. If it is shorter or equal to 5 characters, the function should return an empty string. Additionally, the function should check if the array contains at least 3 elem... | codefeedback |
Find the index of the element that occurs only once in the array. However, you are not allowed to use any built-in functions or libraries to solve this problem. You must implement the solution using only basic data structures and algorithms provided by the programming language.
arr = [1, 1, 5, 5, 6, 8, 6, 9, 9];
#Dif... | codefeedback |
Create a function to sort an array of objects by the value of a certain key in descending order. The key will always be a string containing a valid Python identifier. The array will always contain at least one object, and each object will always have the key specified.
Example:
arr = [{'name': 'john', 'age': 20}, {'na... | codefeedback |
Write a function to remove all words that contain a certain letter from an array. The function should be case-insensitive and should return the modified array.
arr = ["Apple", "banana", "Orange", "Grape"]
letter = 'a'
Example:
Input: remove_words(arr, letter)
Output: ["Grape"] | codefeedback |
Using the given data, write a function that returns the average of the given numbers. The function should handle cases where the input list may contain duplicate values and the average should be calculated considering these duplicates. Additionally, the function should round the average to the nearest integer. The inpu... | codefeedback |
Describe the necessary steps to debug a complex multi-threaded python program, ensuring that the program executes without any errors or race conditions. Additionally, implement a mechanism to handle exceptions and handle memory leaks efficiently by utilizing the asyncio library for asynchronous programming. | codefeedback |
Increase the difficulty of the given programming test question by requiring the solution to handle larger input sizes.
1. Generate a random list of integers called "myList" with a length of 10,000,000 and values ranging from 1 to 1,000,000 (inclusive).
2. Convert the given list to a dictionary where the items are the ... | codefeedback |
Create a function that takes in a 2D list and prints the contents of the list in a 2D format. However, you are not allowed to use any built-in functions or libraries in your solution. The input list will always be rectangular, meaning that all inner lists will have the same length.
Additionally, you must implement the... | codefeedback |
Create a HTML web page that displays "Welcome To My Page" with a heading level 2. Additionally, add a paragraph below the heading that describes the purpose of the page in at least 3 sentences. Finally, style the heading and paragraph using CSS to have a font size of 24 pixels, a font color of blue, and a background co... | codefeedback |
Given an array of integers, find the pair of elements that have the greatest difference. The pair must also satisfy the condition that the larger element is located at an index greater than the smaller element. The array can have duplicates, and the solution must handle them correctly. If multiple pairs have the same m... | codefeedback |
Construct a C++ program that prints out the longest string that contains both uppercase and lowercase letters from an array of strings. The program should also handle cases where multiple strings have the same maximum length. Additionally, you should implement a function to remove any duplicate strings from the input a... | codefeedback |
Implement a function that checks if two strings are anagrams. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. The function should take two strings as input and return True if the strings are anagrams, and False otherwise.
To solve this problem, follow these steps:
1. Conver... | codefeedback |
Write a C# program to remove all adjacent duplicates from a string, while also considering case sensitivity and only using a single loop.
string str = "aabbA"; | codefeedback |
Write Python code to print out an inverse dictionary where the original key becomes the value and the original value becomes the key. The original dictionary may contain duplicate values, so the inverse dictionary should store all the keys associated with a particular value in a list. The implementation should have a t... | codefeedback |
Create an HTML webpage that displays a welcome message along with a dynamic timestamp that updates every second. The timestamp should be formatted in the following way: "YYYY-MM-DD HH:MM:SS". The webpage should also include a button that, when clicked, changes the background color of the page randomly. Additionally, th... | codefeedback |
Implement the bubble sort algorithm to sort the given list of numbers in non-decreasing order. However, you are not allowed to use any additional space or create any new variables. The sort must be performed in-place. The bubble sort algorithm repeatedly swaps adjacent elements if they are in the wrong order until the ... | codefeedback |
Given two strings s1 and s2, write a Python program to find whether s1 is an anagram of s2, taking into account letter case and punctuation. The program should also handle multi-word anagrams.
s1 = 'Listen, lady! I am evil'
s2 = 'Silent, devil! I am lady' | codefeedback |
Given a dictionary of words, write Python code to find out the longest word in the dictionary that starts with a vowel and ends with a consonant. The dictionary should contain at least 50 words and each word should be at least 8 characters long. Additionally, the solution should have a time complexity of O(n), where n ... | codefeedback |
Construct an SQL query to delete a row from a table named "Employees" where the value of the column "Salary" is greater than the average salary of all employees in the table. Additionally, ensure that the deleted row is the one with the highest salary among all the rows that satisfy the condition. | codefeedback |
Create a CSS rule to apply a five-pixel red border to a text box when it is hovered over, and change the border color to blue when it is in focus. Additionally, include a smooth transition effect when the border color changes. Furthermore, ensure that the border width increases gradually from one pixel to five pixels w... | codefeedback |
Suggest a function written in Haskell for reversing an array, but the function should use a recursive approach instead of an iterative approach. Additionally, the function should handle arrays containing duplicate elements efficiently.
arr = [3, 4, 9, 5, 8, 9, 3] | codefeedback |
Write a React.js application to display a table with employee details. The employee details should be fetched from a GraphQL API endpoint and dynamically populated in the table. Additionally, provide a search functionality where the user can filter employees based on their names and sort the table data based on differe... | codefeedback |
Design a function in Java that rotates a N x N matrix 180 degrees counterclockwise.
#Erroneous Code#
Here is a reference code that rotates the matrix clockwise instead of counterclockwise:
```java
public static void rotateMatrix(int[][] matrix) {
int n = matrix.length;
for (int layer = 0; layer < n / 2; layer... | codefeedback |
Develop an algorithm for counting the number of unique characters in a string while ignoring case sensitivity, without using any additional data structures.
str = "HeLlO WoRlD!" | codefeedback |
Create a function in PHP that takes two numbers as input: a starting number and an ending number. The function should calculate the sum of all the cubes of the odd numbers between the starting and ending numbers (inclusive). Additionally, the function should throw an exception if the starting number is greater than the... | codefeedback |
Construct a webpage that displays a list of 1000 hyperlinks. Each hyperlink should have a randomly generated text of length between 5 and 20 characters, and a link that redirects to a randomly generated URL. The webpage should be able to handle at least 5000 concurrent user requests without any performance degradation.... | codefeedback |
Create a program that dynamically generates an HTML table with the following specifications:
- The table should have a header row with 8 columns.
- Each column should have a unique name and should be sorted in ascending order.
- The background color of the header row should be set to lime.
- The table should have 20 ro... | codefeedback |
Can you draft an algorithm in C# for computing the factorial of a number? The input number can be a large integer, up to 10^6. The algorithm should be able to handle this large input efficiently. Additionally, you need to handle the scenario where the input number is negative and return an error message. | codefeedback |
Generate the first 20 prime numbers that are also palindromes. | codefeedback |
Suggest a line of code in Rust for generating a random prime number within a given range, but ensure that the generated number is also a palindrome. | codefeedback |
Propose a way in C to extract the day, month, year, hour, minute, and second from the input date and time in the format "dd-mm-yyyy hh:mm:ss". The input date and time will be provided in the format "dd-mm-yyyy hh:mm:ss". Your solution should handle leap years and account for different lengths of months.
Example input:... | codefeedback |
Suggest an efficient algorithm to count the number of unique three-letter words in a given string. The algorithm should have a time complexity of O(n), where n is the length of the string. Additionally, the algorithm should use constant space, i.e., O(1) space complexity.
You are not allowed to use any built-in functi... | codefeedback |
What will be the output of this code snippet?
a = [1, 2, 3, 4, 5]
b = [x**2 for x in a if x%2 == 0 and x > 2]
print(b) | codefeedback |
We would like you to suggest a method written in TypeScript for reversing a string. The method should be able to handle strings containing alphanumeric characters, punctuation, and white spaces. Additionally, you should not use any built-in string manipulation functions or methods. The reversed string should be stored ... | codefeedback |
Modify the code to print the second largest number in a list of positive integers less than 100. Ensure that the code handles cases where the list contains duplicate numbers. The code should also return an error message if the list is empty or contains less than two numbers. Additionally, the code should ignore any neg... | codefeedback |
Can you code a script in Bash for accepting user inputs and validating them to ensure they are within a specific range, while also handling different data types and error conditions?
Write a Bash script that prompts the user to enter a value. The script should validate the input to ensure it meets the following criter... | codefeedback |
Can you propose a C++ program for multiplying two matrices while ensuring that the dimensions of the matrices are compatible for multiplication?
Matrix1 = [[2, 3],
[4, 5]]
Matrix2 = [[6, 7],
[8, 9]]
The program should also handle the case when the dimensions of the matrices are not compatibl... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.