instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
What data structure would be suitable to represent a sparse matrix with millions of columns and rows, where the number of non-zero elements is expected to be less than 1% of the total elements? | codefeedback |
Suggest an in-place sorting algorithm for an array that contains both duplicates and unique elements, without using any extra data structures or libraries. The algorithm should have a time complexity of O(nlogn) and should be able to handle large arrays efficiently.
[8, 4, 3, 5, 9, 8, 10] | codefeedback |
Create a function that searches the given list to find a key value and returns its position. The function should have a time complexity of O(log n) and should not use built-in search functions such as index(). Additionally, the function should handle cases where the key value is not present in the list and return an ap... | codefeedback |
Given a list of integers, write a program to convert it into a list of strings. Additionally, implement the following requirements:
1. Convert all odd integers to strings and leave the even integers as they are.
2. Remove any duplicate integers from the resulting list.
3. Sort the list in descending order based on the... | codefeedback |
Create a function that returns the longest substring of the string given, where the substring must contain at least one uppercase letter and one digit.
string = "Hello World!123" | codefeedback |
Please rewrite the code snippet to calculate the area of a rectangle with the following requirements:
- The function should take in two parameters: length and width.
- The function should return the calculated area as a float, rounded to 2 decimal places.
- The function should raise a ValueError if either length or wi... | codefeedback |
Write a SQL query that finds the TOTAL sales of each product in a given month and calculates the percentage of the total sales for each product in that month. Additionally, the query should only include products that have sales exceeding a certain threshold.
Table name: sales
Columns: product_id, quantity, order_date,... | codefeedback |
Create a JavaScript object that stores the properties of an employee.
Name: John Doe
Age: 25
Position: Accountant
Department: Finance
Employee ID: 12345
In addition, add the following methods to the object:
1. A method called `calculateSalary` that takes in the number of hours worked in a month and the hourly rate as ... | codefeedback |
Create a swift class that describes a flower. The class should have the following properties:
- Name: a string representing the name of the flower.
- Color: a string representing the color of the flower.
- Petals: an integer representing the number of petals on the flower.
Additionally, the class should have the follo... | codefeedback |
Develop a program in Python to implement a Simple Linear Regression model.
## Problem Statement ##
Write a Python program to implement a Simple Linear Regression model to predict the salary of employees based on their years of experience.
## Instructions ##
1. The program should ask the user for the number of data po... | codefeedback |
Using jQuery, design an effect to fade out an element when clicked on. Additionally, ensure that the element fades out over a duration of 2 seconds and that the element becomes hidden after fading out. | codefeedback |
Create a data structure to store all of the prime numbers up to 10 million. Additionally, provide a piece of erroneous code that attempts to check for primality using a faulty algorithm. | codefeedback |
Create an HTML page with a form that has two inputs: Name and Email.
After the user submits the form, validate the inputs by checking if the Name input is not empty and if the Email input is a valid email address format. If any of the inputs fail the validation, display an error message next to the respective input fi... | codefeedback |
Find the number of unique triplets in this array which sum up to zero.
arr = [-1, 0, 1, 2, 2, 3, 4] | codefeedback |
Write a jQuery code to find and display the longest word from a given string. Additionally, if there are multiple longest words with the same length, display all of them.
var str = "This is a sample string.";
#Additional Instructions#
1. Exclude any punctuation marks from the words. Only consider alphabetic character... | codefeedback |
Read the given input, and write a Python code to create a dictionary which contains unique elements as keys and their corresponding count as values. The input will contain a mixture of strings, integers, and lists. The code should be able to handle any type of input and count the occurrences of each unique element.
Inp... | codefeedback |
Create a function in Python to evaluate the given numpy array and return the maximum absolute difference of any two elements, where the difference is calculated by subtracting the smaller element from the larger element. | codefeedback |
Given an array of strings, sort the strings in descending order of length. If two strings have the same length, sort them alphabetically. The array can contain duplicate strings.
array = ["Banana", "Apple", "Orange", "Pineapple", "Grapes", "Cherry"] | codefeedback |
Write a function in JavaScript that takes in a number x and returns all possible pythagorean triplets whose sum is equal to x. The function should return an array of arrays, where each inner array represents a triplet. Each triplet should be in ascending order.
For example, if the input is 12, the function should retu... | codefeedback |
Using HTML/CSS and JavaScript, construct a web page that generates a random password with the following requirements:
1. The password must be at least 8 characters long.
2. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character.
3. The password must not conta... | codefeedback |
Write a SQL query which returns rows that have duplicate values in exactly three columns and only if the duplicates are consecutive. | codefeedback |
Create a python generator that prints fibonacci numbers from n to 2*n-1, where n is a positive integer greater than 1. The generator should only print the numbers that are divisible by 3. | codefeedback |
Find the sum of two integers without using + or - signs, and with a time complexity of O(log n), where n is the larger of the two integers.
a = 123456789
b = 987654321 | codefeedback |
Generate a code to implement a binary search in a sorted array of strings with up to 1 million elements. The array may contain duplicate strings, and the search should return the index of the first occurrence of the target string. | codefeedback |
Generate a code to find the kth smallest prime number in an unsorted list of positive integers given three inputs (list, k and n).
list = [12, 3, 5, 7, 19]
k = 3
n = len(list)
In this version of the test, the code needs to identify the kth smallest prime number from the given list of positive integers. This requires ... | codefeedback |
Generate a code to throttle a stream of messages that exceeds a set limit of messages within a certain time window. The time window should now be dynamic and determined by the user input. The code should also be able to handle multiple streams of messages simultaneously. | codefeedback |
Given an array of integers, find the maximum possible sum of a subarray within the array. The subarray must contain at least two elements and the elements must be consecutive. | codefeedback |
Create a function in Java to generate Fibonacci numbers up to n, but you are not allowed to use recursion or any built-in functions to calculate Fibonacci numbers. | codefeedback |
What does the 'break' keyword do in a loop structure in Python and how is it used? Explain with an example code snippet. Additionally, discuss the advantages and disadvantages of using the 'break' keyword in a loop. | codefeedback |
Write an HTML code for a form to submit data. The form should have a maximum character limit of 100 for each input field, and it should validate that the email address provided is in the correct format. Additionally, the form should include a dropdown menu with at least 5 options and a checkbox that must be checked bef... | codefeedback |
Create a function in Python that takes a list of integers and returns the first two elements whose sum is a prime number. | codefeedback |
Code an algorithm to find the closest pair of elements in a given array with respect to a given target number. The array will contain at most 10^6 elements and the target number will be within the range of -10^9 to 10^9. You need to find the pair of elements that have the smallest absolute difference with the target nu... | codefeedback |
Construct a syntax tree representing the following sentence:
Bob, who is a software engineer, likes to eat red, juicy apples from his backyard tree, which he planted himself. | codefeedback |
Create a for loop for the list where each element must be squared and multiplied by 2. Ensure that the final sum of all the squared and multiplied elements is greater than | codefeedback |
Print each word in the following sentence in reverse order.
"This is a coding challenge."
#Erroneous Code#
Write a program to reverse the given sentence. | codefeedback |
Create a new array containing the square of each element in the given array, but exclude any numbers that are divisible by 3.
my_array = [2, 3, 4, 5, 6, 7, 8] | codefeedback |
Write a function that takes a string as input and prints each letter of the string on a separate line. The function should ignore any whitespace characters in the string. The function should also handle both uppercase and lowercase letters. The function should have a time complexity of O(n), where n is the length of th... | codefeedback |
Parse the following HTML text and print out all of the elements and the content inside them. Additionally, check if any of the elements have a class attribute with the value "highlight" and if so, print out the class name as well.
<html>
<head>
<title>Example Page</title>
</head>
<body>
<... | codefeedback |
Create a dynamic web page that displays the company name, logo, and description. Implement functionality to allow the user to change the company name, logo, and description through an input form.
Requirements:
1. The web page should have a header section that displays the company name and logo.
2. The company name sho... | codefeedback |
Write an R code to get the names of all uncorrelated columns in a data frame. Additionally, your solution should be able to handle missing values in the data frame and provide a way to specify the desired level of significance for determining correlation. | codefeedback |
Write a C++ code to implement quick sort algorithm with the following additional requirements:
1. The pivot element should be selected randomly from the array.
2. The partitioning step should be implemented using the Hoare's partition scheme.
3. The quick sort algorithm should be implemented as a recursive function.
4.... | codefeedback |
Create a GPT-3 model to generate text given a seed phrase, with the requirement that the generated text must have a minimum length of 500 characters. | codefeedback |
Train a machine learning model to predict the stock price of a company based on historical data. The historical data should include a wider range of features such as volume, market sentiment, economic indicators, and other relevant data sources. Additionally, implement advanced preprocessing techniques such as data nor... | codefeedback |
Create a class in Java that has two fields and two constructors.
Field1: String - this field should only accept input that consists of alphabetic characters and should be case-sensitive.
Field2: int - this field should only accept input that is within a specific range, for example, between 1 and 100 (inclusive).
The ... | codefeedback |
Write a Bash script to quickly calculate the harmonic mean for a set of positive numbers. | codefeedback |
Generate HTML for a button with the text "Click Here!", where the button's color changes to red when hovered over and a popup appears displaying the number of times the button has been clicked. | codefeedback |
Write a web scraper using Python that retrieves data from a website and saves it to a database. The scraper should be able to handle dynamic content and pagination. Additionally, implement rate limiting and handling of anti-scraping measures implemented by the website. | codefeedback |
Implement a thread-safe LRU cache in Java with the following requirements:
1. The cache should have a fixed capacity.
2. When the cache is full and a new element is added, the least recently used element should be removed.
3. The cache should support thread-safe operations, allowing multiple threads to read and write ... | codefeedback |
Edit the following code to check if the resulting output of the division is a prime number.
a = 15
b = 4
output = a/b | codefeedback |
Given a list of phone numbers, write a code to find the one with the highest digits. The phone numbers may contain special characters such as parentheses, hyphens, or spaces. Your code should consider the digits only when comparing the phone numbers.
phone_numbers = ["+44 (0) 123-456-789", "+45 9876-54321", "+44 1234 5... | codefeedback |
Write a MySQL query to find the names, salaries, and ages of all employees who have salaries greater than 80,000 and are between the ages of 30 and 40. | codefeedback |
Sum the numbers in the following array and print the result. The array must now have at least 3 nested lists, each containing at least 3 integers. Additionally, you must now handle and ignore any non-integer elements present in the array. The final result should be rounded to the nearest whole number. array = [[1, 2, 3... | codefeedback |
Return the index of the first occurrence of an element in the given array, but only if the element occurs consecutively at least two times in a row. If there are no consecutive occurrences, return -1.
arr = [2, 3, 3, 1, 5, 2]
#Reasoning Steps#
1. Create a variable "prev" and set it to None. This will store the previou... | codefeedback |
Write a function in Python that takes in a list of positive integers and returns the second largest element. The list must have at least 5 elements and cannot contain duplicates. Additionally, the function should be able to handle a list with a size up to 1000 elements efficiently.
list_of_numbers = [5, 10, 15, 20, 25... | codefeedback |
Write a CSS selector to style all buttons with the class 'submit' that are descendants of a div element with the class 'container'. | codefeedback |
You need to program a function to calculate the dot product of two arrays.
array1=[1, 2, 3]
array2=[-1, 0, 4]
Please note that the arrays may contain non-integer elements. | codefeedback |
You need to write a program to print out the prime numbers between a given range of numbers, where the starting number is greater than 1 and the ending number is less than or equal to 10^6. | codefeedback |
You need to write a program that takes a given string and checks if it is a valid IP address. The program should also handle both IPv4 and IPv6 addresses.
string1="2001:0db8:85a3:0000:0000:8a2e:0370:7334" | codefeedback |
You need to write a program to delete a given node from a singly linked list. However, you can only access the node to be deleted, and not the head of the linked list.
Example:
head = [1, 2, 3, 4, 5]
node_data = 3
In this case, you can only access the node with data = 3. You cannot access the head node or any other n... | codefeedback |
Create an AWS service to host a website with the following specifications:
1. The website should be able to handle high traffic and should be scalable.
2. The website should have a database backend to store user information.
3. Implement a user registration and login system for the website.
4. Implement a feature to a... | codefeedback |
Create a Java program to find all Armstrong numbers in a given range and display them in ascending order.
An Armstrong number is a number that is equal to the sum of its digits raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153.
Your program should take ... | codefeedback |
Write an algorithm to calculate the maximum subarray sum of a given list of numbers. The maximum subarray sum is defined as the largest possible sum that can be obtained by summing up the elements of a contiguous subarray within the given list.
For example, given the list_of_numbers = [-2, 3, 1, -4], the maximum subar... | codefeedback |
Translate the statement "All animals are mammals" into a valid predicate in first-order logic, including a specific condition for aquatic animals. | codefeedback |
Using the given array of objects, find the object with the highest age and the highest weight. If there is a tie in age, prioritize the object with the higher weight. If there is a tie in weight, prioritize the object with the earliest birthdate. If there is still a tie, prioritize the object with the shortest name. Re... | codefeedback |
Write a program to generate the Fibonacci sequence up to a given number 'n', where n is greater than or equal to 2. | codefeedback |
Create a Ruby function to generate a number between 0 and 1 with a precision of at least 6 decimal places. | codefeedback |
Implement an algorithm in Java to count the number of ones in a binary number, without using any bitwise operations or loops. | codefeedback |
Write a SQL query to get the top 10 customers with highest overall spending, considering only customers who have made at least 5 purchases. | codefeedback |
Design a MySQL query to find out the youngest employee who has a salary greater than $50,000. | codefeedback |
Write an SQL query to display all employees who work in the R&D department and have a salary higher than the average salary of all employees in the company. | codefeedback |
Create a PHP function to print the first 1000 prime numbers that are also palindromic. | codefeedback |
Create a function in C++ to calculate the sum of a range of numbers, with the additional requirement that the range should exclude any multiples of a given divisor. | codefeedback |
Design a key-value database with Python for storing course information.
The database should contain the following fields: Course Name, Course ID, Course Description, Course Instructor, and Course Schedule.
In addition, the database should support the following operations:
1. Add a new course to the database.
2. Remove... | codefeedback |
Write a query in MySQL to display the top 3 highest salaries, but exclude any employees whose salary is above $100,000. | codefeedback |
Implement a function in PHP to display all prime numbers between 2 and the given number n. | codefeedback |
Write a Python program to find all numbers from 1 to the given number n which are divisible by 6 and also have the sum of their digits divisible by 3. | codefeedback |
Convert a date in the format "MM/dd/yyyy" to a Unix timestamp, considering time zone offsets and daylight saving time adjustments. | codefeedback |
Use the regular expression to extract the words ending with 'sion' from a paragraph of text, ensuring that the words are preceded by a space or a punctuation mark and followed by a space or a punctuation mark. The paragraph may contain up to 500 words and should be case-insensitive. The extracted words should be sorted... | codefeedback |
Edit the given code to add a new element to the list, but the new element must be a prime number. The list should initially contain the prime numbers [2, 3, 5]. | codefeedback |
Write a program that takes a sentence as input and determines the syntactic structure of each word in the sentence. The program should identify the part of speech (noun, verb, adjective, etc.) for each word and display the result. | codefeedback |
Create a HTML table element with n columns and m rows, where n and m are positive integers. The table should have alternating background colors for each row and each column should have a unique ID. The table cells should contain random integers ranging from 1 to 1000, and the cells in the last column should be sorted i... | codefeedback |
Generate code to calculate the average age of a group of people, while also finding the maximum and minimum ages.
[["Person", "Age"],
["Jim",26],
["John", 39],
["Tracy",19]] | codefeedback |
Create a Matlab program to find the sum of a given series.
The given series is 1 + 1/4 + 1/9 + ...
Additionally, if the sum of the series exceeds a certain threshold, print a warning message indicating that the series has exceeded the threshold and stop calculating further terms. | codefeedback |
Create a class in Python that can be used as a context manager. The context manager should also have the ability to handle and propagate exceptions within the context block. Additionally, it should implement the `__enter__` and `__exit__` methods to ensure that specific resources are properly acquired and released resp... | codefeedback |
Write VBA for a search interface to pull information from one tab of an excel sheet to a different tab, with the additional requirement that the search should be case-sensitive. | codefeedback |
Define a function in Python that calculates the sum of the product of the elements of a nested list. | codefeedback |
Create a Java program to multiply two given matrices, ensuring that the dimensions of the matrices are not equal and that the number of columns in the first matrix is equal to the number of rows in the second matrix. The program should also handle the case where the matrices have dimensions greater than 1000. | codefeedback |
Write a Python program to implement the Find-Max algorithm, which finds the maximum value in an array, while also keeping track of the number of comparisons made during the search. The program should take an array of integers as input and output the maximum value along with the total number of comparisons made. The inp... | codefeedback |
Generate a list of random alphanumeric strings of length 25. The strings must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. | codefeedback |
Write a SQL statement to fetch the maximum age from the table "employee" for each department, along with the department name. | codefeedback |
Write a Python program to format the following list of IP addresses in a specific way, where each IP address is displayed with its corresponding network address and subnet mask. The subnet mask should be represented in CIDR notation. Additionally, the program should validate the IP addresses to ensure they are valid an... | codefeedback |
Write a function to check whether a linked list contains a given value. The linked list can contain integers and is represented by a class `LinkedList`. The class should have the following methods:
1. `add(value)`: Adds a new node with the given value to the end of the linked list.
2. `contains(value)`: Returns `True`... | codefeedback |
Write a React component that accepts an array of objects, where each object has a "name" property (string) and a "age" property (number), and renders a sorted list of the objects based on their age in ascending order. | codefeedback |
Write a SQL query that returns the number of orders shipped on each day, excluding any orders with a status of "cancelled". Include the order date, number of orders, and the total order amount for each day. | codefeedback |
Given two sorted arrays in Java, how would you merge them into one sorted array without using any additional data structures?
int[] array1 = {1, 3, 5, 7, 9};
int[] array2 = {2, 4, 6, 8, 10};
You need to merge the two arrays into a single sorted array without using any additional arrays or data structures. The merged ... | codefeedback |
Write a SQL query for finding the customers who have placed orders with a total price of more than $100 and have also made a purchase in the last 30 days. | codefeedback |
Create a function to generate random numbers from 0-99, ensuring that the generated numbers are unique and sorted in ascending order. | codefeedback |
Given a JavaScript object, how can you remove a key from the object if the object is nested within multiple levels of other objects and arrays? | codefeedback |
Write a function in any programming language that takes a string email address as input and returns an HTML code snippet to create an email link for that email address. The function should also include error handling to ensure the input is a valid email address. | codefeedback |
Create a function that takes in a list of words and returns a list of all possible anagrams for each word. The anagrams should be sorted in alphabetical order.
Time Complexity Requirement: The function should have a time complexity of O(n*m*log(m)), where n is the number of words in the input list and m is the average... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.