This file contains hidden or 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
/** | |
* @jsx React.DOM | |
*/ | |
var React = require('react'), | |
MyReactComponent = React.createClass({ | |
// The object returned by this method sets the initial value of this.state | |
getInitialState: function(){ | |
return {}; |
This file contains hidden or 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
// Array of constructors for the all registered stores | |
var registeredStores = [], // List of registered store constructors | |
registeredStoreNames = [], // StoreNames | |
registeredActions = {}; // Set of registered actionNames | |
// Keep the register functions in a closure so that | |
// there is only one instance of this function irrespective | |
// of the number of components the mixin is applied to | |
function registerStore (store) { | |
var self = this, |
This file contains hidden or 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
var Grandparent = React.createClass({ | |
childContextTypes: { | |
foo: React.PropTypes.string.isRequired | |
}, | |
getChildContext: function() { | |
return { foo: "I m the grandparent" }; | |
}, |
This file contains hidden or 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 QuickSort { | |
private int[] arrA; | |
public QuickSort(int[] arrA) { | |
this.arrA = arrA; | |
} | |
public void quickS(int low, int high) { | |
int mid = (low + high) / 2; | |
int left = low; |
This file contains hidden or 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
//This Program is to find out whether String contains all the unique characters | |
//With out using any additional data structures | |
public class UniqueCharString { | |
private String ip; | |
public UniqueCharString(String ip) { | |
this.ip = ip; | |
} | |
// method 1 : When characters are not ASCII but could be anything alphabets |
This file contains hidden or 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.util.*; | |
public class TwoNumbersInArray { | |
private int[] arrA; | |
private int number; | |
public TwoNumbersInArray(int[] arrA, int number) { | |
this.arrA = arrA; | |
this.number = number; | |
} |
This file contains hidden or 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 Print2DArrayInSpiral { | |
public int arrA[][] = { { 1, 2, 3, 4, 5 }, { 18, 19, 20, 21, 6 }, | |
{ 17, 28, 29, 22, 7 }, { 16, 27, 30, 23, 8 }, | |
{ 15, 26, 25, 24, 9 }, { 14, 13, 12, 11, 10 } }; | |
public int printSpiral(int row_S, int row_E, int col_S, int col_E, | |
boolean reverse, boolean rowPrint) { | |
if (row_S > row_E && col_S > col_E) { |
This file contains hidden or 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 LongestPrefixSequence { | |
private String[] arrA; | |
public LongestPrefixSequence(String[] arrA) { | |
this.arrA = arrA; | |
} | |
public String findPrefix() { | |
int resultLen = arrA[0].length(); | |
int curr; |
This file contains hidden or 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 ReplaceAllSpaces { | |
public void replace(String s1, int length) { | |
char[] chars = s1.toCharArray(); | |
int spaceCount = 0; | |
for (int i = 0; i < length; i++) { | |
if (chars[i] == ' ') { | |
spaceCount++; | |
} | |
} |
This file contains hidden or 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 StringCompression { | |
public String compression(String s1){ | |
StringBuffer sb = new StringBuffer(); | |
int count =1; | |
char prev = s1.charAt(0); | |
for(int i=1;i<s1.length();i++){ | |
char curr =s1.charAt(i); | |
if(prev==curr){ |
OlderNewer