instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a JavaScript function that takes an array and a value as input and inserts the value at the beginning of the array. The function should have a time complexity of O(1) and should not use any built-in array methods like unshift() or splice(). | codefeedback |
Write a function in SQL to get the average salary of all engineers whose designation is "Senior Software Engineer" and whose years of experience is greater than 5. | codefeedback |
Clone a given array and reverse the order of its elements.
arr = [5,4,3,2,1] | codefeedback |
Write a C program to print the numbers from 1 to 100, with the following conditions:
if the number is divisible by 2, print "fizz"
if the number is divisible by 3, print "buzz"
if the number is divisible by both 2 and 3, print "fizzbuzz"
if the number is divisible by 4, print "foo"
if the number is divisible by 5, pri... | codefeedback |
Write JavaScript code to Print the message "Hello World" after 5 seconds. | codefeedback |
Provide a function to read a single line of user input in Python, while ensuring that the input is a valid email address. | codefeedback |
Create a function to print a table using a given dictionary, where the dictionary can have an arbitrary number of keys and values of any data type.
example_dict = {
'Name': ['John', 'Stella', 'Daniel'],
'Age': [20, 23, 19],
'City': ['New York', 'London', 'Paris'],
'Country': ['USA', 'UK', 'France'],
... | codefeedback |
Perform sentiment analysis on this text.
"The hotel staff were extremely helpful and attentive, making my stay a delightful and memorable experience. The luxurious amenities and impeccable service provided by the hotel exceeded all my expectations. I highly recommend this hotel to anyone seeking a remarkable and enjoya... | codefeedback |
Define a function called find_sum that takes a list of numbers and adds them all together. Additionally, implement a check to ensure that the input list contains only numeric values. If any non-numeric values are found, raise a ValueError with an appropriate error message. | codefeedback |
Implement a scientific calculator using JavaScript that supports the following operations:
- Addition
- Subtraction
- Multiplication
- Division
- Exponentiation
- Square root
- Logarithm
The calculator should also have a memory feature that allows the user to store and recall previous calculations.
Constraints:
- The... | codefeedback |
Compile a C++ program, called "my_program", that prompts the user to enter a number and then calculates the factorial of that number using recursion. The program should display the factorial as the output. | codefeedback |
Retrieve the value of an item in a given array, but the array must contain only unique values. Additionally, the function should return an error message if the item is not found in the array.
arr = [1, 2, 3, 4, 5]
#New Constraints and Requirements#
- The array must be sorted in ascending order.
- The array must not co... | codefeedback |
Suggest a way to debug these lines of code and ensure that the loop terminates before 10 iterations. Additionally, the code should print the value of 'i' along with the message "Something is wrong!" on each iteration. | codefeedback |
Use Python to write a code that displays a multiplication table of a given number, but the table should only display the multiplication results for prime numbers less than or equal to the given number. | codefeedback |
Using Java, make a program that finds out the smallest common denominator between two numbers, where both numbers are guaranteed to be within the range of 1 to 1,000,000. Additionally, the program should be able to handle large numbers efficiently and have a time complexity of O(sqrt(N)), where N is the larger of the t... | codefeedback |
Using Java, create a class constructor for a 3D vector that also includes methods to perform common vector operations such as addition, subtraction, scalar multiplication, dot product, cross product, and normalization. The time complexity of each method should be optimized to be as efficient as possible, with a maximum... | codefeedback |
Create a python function that will convert a string to all uppercase and remove all punctuation marks from the string.
# Constraints:
- The input string will only contain alphabetic characters, spaces, and punctuation marks.
- The output string should only contain uppercase alphabetic characters and spaces.
- The func... | codefeedback |
Suggest a SQL query to find the percentage of the total mark of a student, but this time there are multiple students and their marks are stored in a separate table. The tables have the following structure:
Table "students":
- student_id (integer)
- student_name (string)
Table "marks":
- mark_id (integer)
- student_id... | codefeedback |
Construct a function that can generate a unique identifier, but the identifiers must be at least 10 characters long and contain a combination of letters (both uppercase and lowercase) and numbers. The function should also be able to generate at least 10 million unique identifiers per second. | codefeedback |
Create a function in JavaScript for validating a given a string for all required special characters and ensuring that it contains at least 2 digits, 2 special characters, and 2 capital letters. Additionally, the function should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Create an object-oriented program in Java which can display the current date and time, while also implementing the Observer pattern. | codefeedback |
Write a function in Python which can generate a random string consisting of lowercase letters, numbers and symbols. The generated string should have a length between 10 and 20 characters, inclusive. Additionally, the string must contain at least one lowercase letter, one uppercase letter, one number, and one symbol. | codefeedback |
Create a database table called 'Employees' with fields such as employee_id, name, age, email, etc. Implement a function to perform CRUD operations (Create, Read, Update, Delete) on the 'Employees' table using an Object-Relational Mapping (ORM) framework of your choice. Ensure that the function is capable of handling a ... | codefeedback |
Create a function in Python for sending an email using the SMTP protocol. Your function should validate the email address and password provided by the user, and only allow sending the email if the authentication is successful. Additionally, the function should handle any errors or exceptions that may occur during the e... | codefeedback |
Given the data structure below, write a function to print out all the elements in the array, but with the constraint that the function should have a time complexity of O(n^2), where n is the length of the array.
const arr = [1, 2, 3, 4, 5]; | codefeedback |
Write a JavaScript program to find the sum of an array of numbers using a recursive function. The function should take an array of numbers as input and return the sum of all the numbers in the array. The input array can have a maximum length of 10000. The time complexity of the solution should be O(n), where n is the l... | codefeedback |
Implement a function that checks if a number is a prime palindrome. | codefeedback |
Construct and execute a SQL query to select fields from the following table, where the email addresses must be in a specific format.
Table: student
Fields: firstname, lastname, email
The email addresses must be in the format "firstname.lastname@domain.com". | codefeedback |
Create a JSON object to represent an address that includes the following fields: street, city, state, country, and postal code. Additionally, include nested objects for latitude and longitude coordinates. | codefeedback |
Name and describe a feature of the JavaScript Date object that allows you to format the date string in a specific timezone while also accounting for daylight saving time changes. | codefeedback |
Implement the update function in Java for a circular queue data structure. | codefeedback |
Create a JavaScript class that has three properties: a name, an age, and a list of hobbies.
The class should have the following methods:
1. A method called `introduce` that prints out the name and age of the person.
2. A method called `addHobby` that takes a hobby as an argument and adds it to the list of hobbies.
3.... | codefeedback |
Create a JavaScript function to convert a given temperature in celsius to its equivalent in fahrenheit, but without using any arithmetic operators. | codefeedback |
Convert the following array of integers to a string, while ensuring that the resulting string is in reverse order and all elements are separated by a comma: [1, 2, 3, 4, 5]
[5, 4, 3, 2, 1] | codefeedback |
Create a C++ Program to reverse the words of a string while maintaining the original order of the words. Additionally, handle cases where there are leading or trailing spaces in the string and multiple spaces between words. | codefeedback |
Change the following code to create a new string without spaces and all letters in uppercase.
string = "Hello World" | codefeedback |
Implement a sorting algorithm for the following array of objects:
Object[] array = {new MyClass(23), new MyClass(10), new MyClass(4), new MyClass(15), new MyClass(66), new MyClass(28), new MyClass(11)};
where MyClass is a custom class with an integer attribute.
Additionally, the sorting algorithm should be a stable s... | codefeedback |
Summarize the given article about the rise of artificial intelligence and its impact on the job market and society in one sentence, while also providing the source of the article. | codefeedback |
Classify the following sentence as offensive or non-offensive, considering that the sentence can be in any language and may contain additional punctuation or symbols. Sentence: Your work is terrible and I can't believe you are still employed. | codefeedback |
You are developing a web application that includes a form with a button element that has the ID of "submit-btn". Your task is to implement a feature that makes the button unclickable under certain conditions. Write a function in JavaScript that achieves this.
Requirements:
- The function should accept two parameters: ... | codefeedback |
Rewritten Test:
What is the time complexity of the following function?
```python
def f(x):
s = 0
for j in range(1, x+1):
for k in range(1, x+2):
if j % k == 0:
s = s + 1
return s
```
Please analyze the time complexity of the function and provide a Big O notation represe... | codefeedback |
Write a code to extract data from a password-protected PDF document, where the password is unknown. | codefeedback |
Create a responsive HTML and CSS layout to display a grid of books with their author, title, description, and a thumbnail image.
Book 1: Author - John, Title - The Catcher in the Rye, Description - “The Catcher in the Rye is a 1951 novel by J. D. Salinger.”, Thumbnail - image1.jpg
Book 2: Author - Jane, Title - Sense ... | codefeedback |
Construct a query to find the 3rd highest salary from an employee table. | codefeedback |
Write a SQL query to find out all the cities that have the most expensive houses, but exclude any cities that have a population less than 1 million. | codefeedback |
Make a valid http request call with the following parameters:
- url = 'www.example.com'
- Method = 'GET'
- Header = 'Content-Type:application/json'
Additionally, you need to handle the following scenarios:
1. Implement error handling for the http request, including cases such as a connection timeout, invalid URL, or s... | codefeedback |
Write a Dockerfile for an Nginx server that includes a custom configuration file and sets up SSL/TLS encryption using a self-signed certificate. | codefeedback |
Build a function in PHP that converts a string into ASCII code. The function should handle strings of any length and should have a time complexity of O(n), where n is the length of the string. | codefeedback |
Create a program to search for a specific word in a document and return the index position of the first occurrence. The program should handle multiple documents and allow the user to input the document and word to search. The program should also handle case sensitivity, so that "words" and "Words" are considered differ... | codefeedback |
Create a program to generate random passwords of 10 characters consisting of letters, numbers, and special characters. The password must meet the following requirements:
- At least 2 uppercase letters
- At least 2 lowercase letters
- At least 2 numbers
- At least 2 special characters
The program should also ensure tha... | codefeedback |
Compose a SQL query to display the highest minimum salary of the employees in each department, where the minimum salary must be greater than $50,000 and the department must have at least 5 employees. | codefeedback |
Create an initialization script for a database that includes the following requirements:
1. Create a table called "users" with the following columns:
- id (integer)
- name (string)
- email (string)
- password (string)
- created_at (timestamp)
- updated_at (timestamp)
2. Create a table called "posts"... | codefeedback |
Create a table in MySQL that stores employee details, including their name, age, gender, job title, department, salary, and hire date. The table should have the appropriate data types for each column and should include primary key constraints. Additionally, add a foreign key constraint to reference the department table... | codefeedback |
Write an SQL query to select the employees who have worked for more than 10 years and have a salary higher than the average salary of all employees. | codefeedback |
Write a SQL query to calculate the average age of customers who have purchased items from a store, while also excluding any customers who have made a purchase in the last 30 days. | codefeedback |
Code a function that prints out the characters of a string in reverse order, starting from the last character.
str = "Hello World!" | codefeedback |
Construct a multi-threaded application in Python to read and calculate the sum of a list of numbers, where each number is represented as a string and can be up to 10^100 in length. The list can have up to 10^6 numbers.
Example List of numbers: ['1000000000000000000000000000000000000000000000000000000000000000000000000... | codefeedback |
Find the greatest number from an array, but this time, the array can contain negative numbers as well.
arr = [41, 77, -56, 99] | codefeedback |
Create an SQL query to select only the rows from a table where the second column is not empty and contains at least one uppercase letter. | codefeedback |
Your job is to generate random numbers within a given range, but you are not allowed to use any built-in random number generation functions or libraries. You must implement your own algorithm to generate random numbers. Additionally, the generated random numbers should be unique and not repeat within the range specifie... | codefeedback |
Design an algorithm in Python to detect palindrome strings with the following constraints:
- The algorithm must have a time complexity of O(n), where n is the length of the input string.
- The algorithm must not use any built-in string manipulation functions (e.g. reverse(), join(), etc.).
- The algorithm must ignore a... | codefeedback |
Write a regular expression pattern to find all the words which begin with a digit, but do not end with a digit. | codefeedback |
Parse a nested JSON string that contains arrays and objects.
{"name":"John", "age":30, "hobbies":["reading", "painting"], "address":{"street":"123 Main St", "city":"New York"}} | codefeedback |
Write a code in Java to convert any string to camel case format, while also removing any consecutive duplicate characters in the string.
String = "this_is_a_string" | codefeedback |
Deploy a Keras model to Google App Engine, ensuring the following:
1. Implement a Flask application that will serve as the API endpoint for predictions.
2. The Flask application should have multiple routes to handle different types of requests, such as training the model, predicting on new data, and evaluating the mode... | codefeedback |
Create a class for a basketball team that tracks the performance statistics of each player, including points scored, assists, rebounds, steals, and blocks. Additionally, the class should have a method to calculate the overall team performance based on these statistics, taking into account the individual player's contri... | codefeedback |
Implement a queue data structure that supports the following operations:
1. `enqueue(item)`: Add an item to the end of the queue.
2. `dequeue()`: Remove and return the item at the front of the queue.
3. `peek()`: Return the item at the front of the queue without removing it.
4. `isEmpty()`: Check if the queue is empty.... | codefeedback |
Create a SQL query to retrieve the name, address, contact number, and total spending of the customers who have made at least three purchases in the last month, ordered by their total spending in descending order. | codefeedback |
Create a React component that displays a list of items. Each item should have the following properties:
- id: a unique identifier for the item (string)
- name: the name of the item (string)
- price: the price of the item (number)
- imageURL: the URL of the image representing the item (string)
The component should fetc... | codefeedback |
Perform sentiment analysis on a given sentence using Python, considering multiple sentences instead of just one. The sentences are as follows:
1. The food was really good but the service was terrible.
2. I had a great time at the restaurant and the staff was very friendly.
3. Although the ambiance was nice, the food wa... | codefeedback |
Design and implement an automated login system that can handle multiple users and ensure secure authentication. Consider the following requirements:
1. User Management:
- The system should support registration of new users.
- Each user should have a unique username and password.
- The system should validate t... | codefeedback |
Using Python, create a program that prints out the numbers 0 to 100 in descending order. | codefeedback |
Explain the concept of the depth-first search algorithm and provide an example. Additionally, describe the time complexity of the algorithm and discuss any potential drawbacks or limitations it may have. | codefeedback |
Write a function to calculate the factorial of a given number n. | codefeedback |
Write a method in Swift to capitalize the first letter of each word in a given sentence. The sentence may contain punctuation and multiple spaces between words.
sentence = "hello world, how are you?" | codefeedback |
Write a program to determine the number of islands in a given map of Scotland. The map is represented by a 2D matrix where 0's represent water and 1's represent land. An island is formed by connecting adjacent lands horizontally or vertically. | codefeedback |
Create a program to detect a negative number in an array of numbers. However, you are not allowed to use any comparison operators (e.g., <, >, <=, >=, ==) to check for negativity. You can only use mathematical operations to determine if a number is negative.
numbers = [10, -5, 4, 20] | codefeedback |
Develop an API that returns a list of students and their ages, sorted in descending order of their ages. The API should be able to handle large amounts of data efficiently, with a time complexity of O(nlogn) or better. Additionally, the API should be able to filter the list of students based on specified criteria such ... | codefeedback |
Create a data structure to store employee information with the following requirements:
1. The data structure should be able to efficiently store and retrieve information for a large number of employees (e.g., at least 10,000).
2. Each employee should have the following attributes: ID (unique identifier), name, age, sal... | codefeedback |
Generate all possible permutations of the given array of numbers, where each permutation must contain exactly two odd numbers and one even number. The original array may contain duplicate numbers, but the permutations should not have any duplicates.
numbers = [1, 2, 2, 3, 4]
(Note: In the original test, there was no ... | codefeedback |
Search for all usernames that contain the substring "John" in any position in the database. The search should be case-sensitive and should return both exact matches and partial matches. The database contains millions of records, so the algorithm should be efficient and not have a time complexity higher than O(n log n),... | codefeedback |
Write the code to calculate the sum of all prime numbers between 1 and a given input number recursively. | codefeedback |
Design the algorithm to perform a depth-first search on a given binary tree and return the sum of all the nodes in the tree. | codefeedback |
Create a sorting algorithm for an array that only needs 1 iteration and has a time complexity of O(nlogn). | codefeedback |
Implement a class called "Person" with the following requirements:
1. The class should have private variables for name, age, and address.
2. The class should have public getter and setter methods for all the variables.
3. The name should only accept a string with a length between 3 and 20 characters.
4. The age should... | codefeedback |
Create a program to detect a loop in a linked list and return the starting node of the loop. | codefeedback |
Write a SQL query to retrieve data from two tables with similar columns. Additionally, you should order the results by the length of the name in descending order.
Table1
| id | name | address |
|----|-------------|---------|
| 1 | John | NYC |
| 2 | Mary | LA |
| 5 | Christopher | Da... | codefeedback |
Create a new C++ class with a constructor and destructor that also implements a custom copy constructor and overloaded assignment operator. | codefeedback |
Debug the following code for finding the median of three numbers, but you are not allowed to use any conditional statements (if, elif, else) or any comparison operators (>, <, ==). You can only use mathematical operations and functions. | codefeedback |
Use regular expression to remove special characters from any given string and then sort the resulting string in alphabetical order.
my_string = 'Hi There! Welcome.@' | codefeedback |
Design an algorithm to add two given binary numbers with the following constraints:
- The time complexity of the algorithm should be O(log n), where n is the length of the longer binary number.
- The space complexity of the algorithm should be O(1), i.e., the algorithm should not use any additional data structures othe... | codefeedback |
Explain the concept of polymorphism in object-oriented programming and provide an example of how it can be implemented in a real-life scenario. | codefeedback |
Classify the given sentence using the Bag-of-Words approach, and also determine the sentiment of the sentence.
Sentence: She felt so excited that her application got approval.
In addition to classifying the sentence using the Bag-of-Words approach, you are required to extract the important keywords from the sentence ... | codefeedback |
Create a class called "MathOperations" with the following methods:
1. "get_sum": This method takes in two numbers as input and calculates their sum. However, instead of using the "+" operator to add the numbers, you must implement your own algorithm for addition using only bitwise operators. You are not allowed to use... | codefeedback |
Given a string of length N, create an HTML table with N rows and 4 columns. Each cell in the table should contain a substring of the input string such that the length of each substring is a prime number. The table should be constructed in such a way that the sum of the lengths of all substrings is minimized. | codefeedback |
Write a JavaScript function that takes two numbers and returns the sum of all numbers between the two, inclusive. Additionally, the function should handle negative numbers and validate the input to ensure that the first number is smaller than the second number. | codefeedback |
Create a multi-threaded GUI application in C# that displays a welcome message when the program is launched. The welcome message should be randomly generated from a list of predefined messages. Additionally, the application should have a button that allows the user to change the language of the welcome message. The user... | codefeedback |
Write an R program to generate 5 random prime numbers between 0 and 100. | codefeedback |
Write a function that calculates the Fibonacci numbers to the nth number, ensuring that the function runs in O(n) time complexity. | codefeedback |
Using the given sentence, design a regular expression which will match the given word only if it is preceded by the word "red" and followed by a comma.
Word: apple
Sentence: I bought a red apple, green apple, and yellow apple from the store. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.