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
std::stringstream ss; | |
// set a flag to formatting with decimal digits | |
ss.setf(std::ios_base::fixed, std::ios_base::floatfield); | |
float f = 1.555555; | |
// set a nuber of digits | |
ss.precision(2); | |
ss << "Float: " <<f; |
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
# node --harmony sequential_timeout.js | |
# need to install co | |
var processor = function(timer) { | |
return new Promise(function(resolve, reject) { | |
setTimeout(resolve, timer * 1000); | |
}); | |
} | |
var serial_timeout = function(timer_arr) { |
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 Solution | |
{ | |
public static int LCS(String s1, String s2) { | |
int l1 = s1.length(); | |
int l2 = s2.length(); | |
if (l1 == 0 || l2 == 0) return 0; // no common strings | |
// memorization | |
int[][] m = new int[l1][l2]; | |
int maxLen = 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
def LCS(s1, s2): | |
if not s1 or not s2: | |
return 0 | |
len1, len2 = len(s1), len(s2) | |
# memorization | |
m = [] | |
for i in range(len1): | |
m.append([0]*len2) #m[len1][len2] |
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.lang.Math; | |
public class Solution { | |
public static String LCS(String s1, String s2) { | |
if (s1.isEmpty() || s2.isEmpty()) { | |
return ""; | |
} | |
int l1 = s1.length(); | |
int l2 = s2.length(); |
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 LCS(s1, s2): | |
l1, l2 = len(s1), len(s2) | |
if l1 == 0 or l2 == 0: return '' | |
# memorization of m[l1][l2] | |
m = [] | |
for x in range(l1): | |
m.append([0]*(l2)) | |
# Fill 0th row |
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 index_of(string, target): | |
leng_s = len(string) | |
leng_t = len(target) | |
if leng_s == 0 or leng_t == 0: | |
return -1 | |
for i in range(leng_s): | |
j = 0 | |
if i + leng_t > leng_s: | |
return -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
class Solution | |
{ | |
public static int indexOf(String s, String t) { | |
int s_length = s.length(); | |
int t_length = t.length(); | |
if (s_length == 0 || t_length == 0) return -1; | |
for (int i = 0; i < s_length; i++) { | |
if (i + t_length > s_length) return -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
# Class of linked list Node. | |
class Node(): | |
def __init__(self, val): | |
self.next = None | |
self.value = val | |
def next(self): | |
return self.next | |
def setNext(self, nextNode): |
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
// Class of linked list node | |
class Node { | |
public int value; | |
public Node next; | |
public Node(int value) { | |
this.value = value; | |
this.next = null; | |
} | |
OlderNewer