Quickly Reverse a String in C++

Smita Kapse
Updated on 30-Jul-2019 22:30:25

360 Views

In this section, we will see how to reverse a string very quickly using C++. For reversing there is a built-in function in the algorithm library, called reverse(). This function takes the beginning and the ending pointer of a container, then reverse the elements.Input: A number string “Hello World” Output: “dlroW olleH”AlgorithmStep 1:Take a string Step 2: reverse it using reverse() function Step 3: Print the result. Step 4: EndExample Code Live Demo#include #include using namespace std; main() {    string my_str = "This is a string to be reversed";    cout

Use removeAll in Android CopyOnWriteArraySet

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

129 Views

Before getting into an example, we should know what CopyOnWriteArraySet is. It is a thread-safe variant of ArrayList and operations add, set, and so on by making a fresh copy of the underlying array.This example demonstrates about How to use removeAll() in android CopyOnWriteArraySetStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken a text view to show CopyOnWriteArraySet elements.Step 3 − Add the following code ... Read More

Check Privileges and Grants for a Specific User in MySQL

Anvi Jain
Updated on 30-Jul-2019 22:30:25

555 Views

If you want to check privileges for a specific user, then use the below syntax −SHOW GRANTS FOR 'yourUserName'@'yourHostName';The above syntax will check privileges for a specific user.To check the privileges for a specific user, then use FOR. Let’s say we have a username ‘JOHN‘ and host is ‘%’. Following is the query to get the privileges for user “JOHN” −mysql> SHOW GRANTS FOR 'JOHN'@'%';This will produce the following output −+--------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- --------------+ | Grants for JOHN@% | +--------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- --------------+ | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, ... Read More

Get Subset from TreeSet in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

114 Views

Let us first create a TreeSet and add elements:TreeSet treeSet = new TreeSet(); treeSet.add(10); treeSet.add(20); treeSet.add(30); treeSet.add(40); treeSet.add(50); treeSet.add(60); treeSet.add(70); treeSet.add(80); treeSet.add(90); treeSet.add(100);Now, let’s say you need to set sub set from 50 to 70, then use the subset() for it:SortedSet sub = treeSet.subSet(50, 70); System.out.println("Sub Set = " + sub);Exampleimport java.util.TreeSet; import java.util.SortedSet; public class Demo {    public static void main(String[] args) {       TreeSet treeSet = new TreeSet();       treeSet.add(10);       treeSet.add(20);       treeSet.add(30);       treeSet.add(40);       treeSet.add(50);       treeSet.add(60);       ... Read More

Check If a Given Graph is Bipartite Using DFS in C++

Anvi Jain
Updated on 30-Jul-2019 22:30:25

213 Views

A bipartite graph is a graph in which if the graph coloring is possible using two colors only i.e.; vertices in a set are colored with the same color. This is a C++ program to check whether a graph bipartite or not using DFS.AlgorithmBegin    An array color[] is used to stores 0 or 1 for every node which    denotes opposite colors.    Call function DFS from any node.    If the node w has not been visited previously, then assign !    color[v] to color[w] and call DFS again to visit nodes connected    to w.    If ... Read More

DoubleBuffer hasArray Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

111 Views

It can be checked if a buffer has the backing of an accessible double array by using the method hasArray() in the class java.nio.DoubleBuffer. This method returns true if the buffer has the backing of an accessible double array and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          DoubleBuffer buffer = DoubleBuffer.allocate(5);          buffer.put(4.5D);          buffer.put(1.2D);         ... Read More

Stop Specified IntentService in Android

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

694 Views

Before getting into the example, we should know what Intent service is in android. Intent Service is going to do background operation asynchronously. When user call startService() from activity, it doesn’t create the instance for each request and it going to stop service after done some action in service class or else we need to stop service manually by using stopSelf().This example demonstrates about Android stop specified IntentService.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to ... Read More

Use CAST in Android SQLite

Anvi Jain
Updated on 30-Jul-2019 22:30:25

433 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use cast() in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ... Read More

Order By Date and Time in MySQL

George John
Updated on 30-Jul-2019 22:30:25

1K+ Views

You need to use ORDER BY clause for this. Let us first create a table. The query to create a table is as followsmysql> create table OrderByDateThenTimeDemo - > ( - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, - > ShippingDate date, - > ShippingTime time - > ); Query OK, 0 rows affected (0.56 sec)Now you can insert some records in the table using insert command. Here, we have two similar dates, but different times i.e. 2018-01-24mysql> insert into OrderByDateThenTimeDemo(ShippingDate, ShippingTime) ... Read More

Save Points in JDBC Explained

Nancy Den
Updated on 30-Jul-2019 22:30:25

381 Views

Savepoint interface gives you the additional transactional control. Most modern DBMS, support save points within their environments such as Oracle's PL/SQL.When you set a save point you define a logical rollback point within a transaction. If an error occurs past a save point, you can use the rollback method to undo either all the changes or only the changes made after the save point.The Connection object has two new methods that help you manage save points −setSavepoint(String savepointName): Defines a new save point. It also returns a Savepoint object.releaseSavepoint(Savepoint savepointName): Deletes a Savepoint. Notice that it requires a Savepoint object ... Read More

Advertisements