This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
void removeChars(string &str, char ch) | |
{ | |
int i; | |
int resInd = 0; //Result string index | |
for( i = 0; i < str.length(); i++ ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include < iostream > #include < string > #include < algorithm > | |
using namespace std; | |
void reverseWords(string & str) { | |
//reverse the entire string | |
reverse(str.begin(), str.end()); | |
string::iterator strIt; | |
string::iterator wordBegin = str.begin(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) | |
{ | |
int [] array = {6,2,3,6,3,6,6,6}; | |
System.out.println("Majority number is: " + getMajorityNum(array)); | |
} | |
public static int getMajorityNum(int[] array) | |
{ | |
//Initialize first num as majority num | |
int majorNum = array[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with IntelliJ IDEA. | |
* User: Ravi | |
* Date: 10/13/13 | |
* Time: 9:56 PM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class MoveZerosDemo { | |
public static void main(String[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.util.Scanner; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: Ravi | |
* Date: 10/14/13 | |
* Time: 6:36 AM | |
* To change this template use File | Settings | File Templates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
//Node definition for a single linked list | |
class SLLNode | |
{ | |
private: | |
//data member | |
int data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with IntelliJ IDEA. | |
* User: Ravi | |
* Date: 10/15/13 | |
* Time: 7:09 AM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class FindLeastDiffNumArray { | |
public static void main(String[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with IntelliJ IDEA. | |
* User: Ravi | |
* Date: 10/15/13 | |
* Time: 7:51 PM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class ArrangeAlternate { | |
public static void main( String[] args ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with IntelliJ IDEA. | |
* User: Ravi | |
* Date: 10/17/13 | |
* Time: 6:01 AM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class BiggestElementsRight { | |
public static void main(String [] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created with IntelliJ IDEA. | |
* User: Ravi | |
* Date: 10/17/13 | |
* Time: 6:41 AM | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class SearchSortedMatrix { | |
public static void main(String [] args) | |
{ |
OlderNewer