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
str = '{{{[({})[()]]}}}' | |
Stack s = new Stack() | |
i = 0 | |
while(i< str.length()){ | |
c = str[i] | |
if(c == '[' || c == '{' || c== '(') | |
s.push(c) | |
else if(!s.empty() && |
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
str = 'aaaabbbccddddd' | |
out = '' | |
Stack s = new Stack() | |
i=0 | |
while(i<str.length()){ | |
//if element matched | |
if(!s.empty() && s.peek() != str[i] ){ | |
out = out + s.peek() + '' + s.size() |
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
x = [] | |
def fold(n) { | |
if (n == 1) | |
x.add('V') | |
else { | |
fold(n-1) | |
x.add('V') | |
reverse(n-1) | |
} | |
} |
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
map = new LinkedHashMap(); | |
map.put('a', 7); | |
map.put('b', 6); | |
map.put('c', 9); | |
list =new LinkedList<Map.Entry<String, Integer>>( map.entrySet() ); | |
Collections.sort( list, { Map.Entry o1, Map.Entry o2 -> | |
return (o2.getValue()).compareTo( o1.getValue()) | |
}) |
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
String construct(String start, String middle, String end, String data){ | |
StringBuilder construct = new StringBuilder(); | |
String[] tokens = data.split(","); | |
int i=0; | |
construct.append(start); | |
while(i<tokens.length -1){ | |
construct.append(middle.replaceAll("%s", tokens[i])); | |
i++; | |
} | |
construct.append(end.replaceAll("%s", tokens[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
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Random; | |
/** | |
* | |
* @author deepak | |
*/ | |
public class BiasedCoin { |
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
def str = "VVPVVPPVVVPPVPPVVVPVVPPPVVPPVPPVVVPVVPPVVVPPVPPPVVPVVPPPVVPPVPP" | |
print Arrays.asList(str.toCharArray()) |
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 javax.xml.*; | |
import javax.xml.transform.*; | |
import javax.xml.transform.stream.*; | |
import javax.xml.validation.*; | |
import java.io.*; | |
import java.net.*; | |
import org.xml.sax.*; | |
public class XSDValidation{ | |
public static void main(String[] args) throws Exception{ |
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
@Grab(group='org.apache.poi', module='poi', version='3.9') | |
@Grab(group='org.apache.poi', module='poi-ooxml', version='3.9') | |
import org.apache.poi.hssf.usermodel.HSSFCell; | |
import org.apache.poi.hssf.usermodel.HSSFRow; | |
import org.apache.poi.hssf.usermodel.HSSFSheet; | |
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |
import org.apache.poi.hssf.util.HSSFCellUtil; | |
import org.apache.poi.ss.util.CellRangeAddress; |
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
for /R %G in (*.jar) do @jar -tvf %G | find "ClassName" > NUL && echo %G |
OlderNewer