- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The algorithm to find the maximum number of points that can be enclosed in a circle of a given radius. This means that for a circle of radius r and a given set of 2-D points, we need to find the maximum number of points that are enclosed (lying inside the circle not on its edges) by the circle.For, this is the most effective method is the angular sweep algorithm.AlgorithmThere are nC2 points given in the problem, we need to find the distance between each of these points.Take an arbitrary point and get the maximum number of points lying in ... Read More
To get the last date i.e. the latest, use aggregate function MAX() with a subquery. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ExpiryDate date ); Query OK, 0 rows affected (1.40 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ExpiryDate) values('2018-12-31'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(ExpiryDate) values('2019-09-01'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(ExpiryDate) values('2019-09-01'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable(ExpiryDate) values('2016-08-30'); Query OK, 1 row affected (0.13 ... Read More
Yes, use AUTO_INCREMENT with PRIMARY KEY. Let us first create a table −mysql> create table DemoTable ( EmployeeId int NOT NULL AUTO_INCREMENT, EmployeeName varchar(40), EmployeeAge int, PRIMARY KEY(EmployeeId), UNIQUE KEY(EmployeeName, EmployeeAge) ); Query OK, 0 rows affected (0.96 sec)Let us check the table description of the table −mysql> desc DemoTable;This will produce the following output −+--------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+----------------+ | EmployeeId | int(11) | NO | PRI | NULL ... Read More
A set is a data structure that stores numeric values. The speciality of sets is that the elements are distinct (i.e. no two elements have the same value). Also the values are stored in ascending order. You can explicitly define the data type of a set in C++ i.e. a user defined data type for a set.To store data in distinct form and in a sorted order. Let’s take an example, Input : 124689781230 Output : 1230467889LogicIn a set the input can be in any order and there can be duplicate value. But the set will store only distinct ... Read More
For this, you can use a subquery. Let us first create a table −mysql> create table DemoTable ( Score int ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(80); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(55); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(88); Query OK, 1 row affected (0.13 sec)Display all records from ... Read More
For this, use the GROUP BY HAVING clause. Let us first create a table −mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(88); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(88); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(88); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(99); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(99); Query OK, 1 row affected (0.09 sec) mysql> insert ... Read More
The basic_string c_str function that returns a pointer to an array of characters that is terminated using null character. It is an inbuilt method that has the value of a string that has null character termination.Syntax to define a c_str function in C++ −const Char ptr* c_str() constAbout the functionIt is an inbuilt method for the c++ STL library. No parameters can be passed to the method. It returns a char pointer. This pointer points to NULL terminated character array.Example Live Demo#include #include using namespace std; int main() { string s = "I Love Tutorials Point"; int ... Read More
To count comma-separated-values, use aggregate function COUNT(*) along with FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable ( Value varchar(100) ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('10, 20, 60, 80'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('60, 70, 90'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('50, 55, 65, 60'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('90, 98, 97'); Query OK, 1 row affected (0.12 sec)Display all records ... Read More
For this, use the INSERT() function from MySQL. The INSERT(str, pos, len, newstr) returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string.It replaces the rest of the string from position pos if len is not within the length of the rest of the string. Returns NULL if any argument is NULL.Let us first create a table −mysql> create table DemoTable ( Password varchar(50) ); Query OK, 0 rows affected (0.51 sec)Insert some records in ... Read More
Let us first create a table −mysql> create table DemoTable ( Name varchar(40), Score int ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Adam', 89); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('Adam', 89); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Chris', 89); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Chris', 89); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Bob', 98); Query OK, 1 row affected (0.10 sec) mysql> insert ... Read More