I am thrilled to announce that Social Street View has won the Best Paper Award at Web3D 2016, which was held next to SIGGRAPH 2016 in late August! Please visit the project website for more details: http://www.socialstreetview.com I also published my slides and videos.

LJAI is a personal chatbot hosted in my private server, available on the WeChat platform by searching 爱打滚的玲酱, and now available via the Web platform! What makes LJAI different is the virtual and real mapping of our own cat. Recently, we have acquired over 120 users, and thousands of chat messages. http://veritayuan.com/lingjiang Compared with the…

This series illustrate my shaders on Shadertoy.com, which renders Instagram filters in real time. Brannan Filter Brannan filter emphasizes the grey and green colors, and paints a metallic tint upon the photos. Click the mouse for comparison. I write this shader to stylize your photos in batch on my own ShaderToy renderer 🙂 (To be…

Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B. Input: nums = [1,3,1] k = 1 Output: 0 Explanation: Here are all the pairs: (1,3) -> 2 (1,1) -> 0 (3,1) -> 2 Then the 1st…

Here are some random thoughts and summaries on deferred rendering pipeline. Deferred shading is generally faster than forward shading According to Unity3D, As a general rule, Deferred Rendering is likely to be a better choice if our game runs on higher-end hardware and uses a lot of realtime lights, shadows and reflections. Forward Rendering is…

Vergence-accommodation conflict Vergence movements are closely connected to accommodation of the eye. Under normal conditions, changing the focus of the eyes to look at an object at a different distance will automatically cause vergence and accommodation, sometimes known as the accommodation-convergence reflex. Visual odometry Match moving VR in practice GPU-based rendering (almost) as usual (OpengGL,…

It is nothing related with AR and VR. But in the era of AI, who wouldn’t want to develop a cute chatbot? Feel free to scan the QR code below to follow our cute pet 🙂 Most of the code is based upon Python. I have developed the following functionalities. AIML matching Dictionary Idiom Wikipedia…

Real-time image manipulation is always fascinating. With the power of the modern GPU, it is possible to achieve the postprocessing effects all in a single shader. Remember that in GLSL, matrix are column major. Brightness is a float between [-1, 1], directly adding to the RGB Contrast is a float between [0, 1, ∞], directly…

Leetcode 691 is an interesting problem, I didn’t notice that T <= 15. BFS is good enough (and even faster) for this, but dynamic programming with bit compression is the ultimate solution with more words.

Leetcode 691. Stickers to Spell Word

C++

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

classSolution{

public:

// 691. Stickers to spell word

// Time: O(2^T * S * T),

// T <= 15

// T is the number of letters in the target word,

// S is the total number of letters in all stickers

// Space: O(2^T)

intminStickers(vector<string>&stickers,stringtarget){

usingFreq=vector<int>;

constintMAX_ALPHABET=26;

constintT=target.size();

vector<Freq>freqs(stickers.size());

// calc frequency statistics

auto buildFreqFromString=[=](conststring&s){

Freq ans(MAX_ALPHABET);

for(constauto&c :s)

++ans[c-'a'];

returnans;

};

Freq targetFreq=buildFreqFromString(target);

for(inti=0;i<stickers.size();++i){

freqs[i]=buildFreqFromString(stickers[i]);

// remove higher frequency than the target

for(intj=0;j<MAX_ALPHABET;++j)

freqs[i][j]=min(freqs[i][j],targetFreq[j]);

}

// test if a is the proper subset of b

auto isProperSubset=[=](constFreq&a,constFreq&b){

for(inti=0;i<a.size();++i)

if(a[i]>=b[i])returnfalse;

returntrue;

};

// remove the proper subset of stickets

for(inti=freqs.size()-1;i>=0;--i){

for(intj=0;j<freqs.size();++j)

if(i!=j&&isProperSubset(freqs[i],freqs[j]))

freqs.erase(freqs.begin()+i);

}

auto getStringFromFreq=[=](constFreq&a){

stringans="";

for(inti=0;i<a.size();++i){

ans+=string(a[i],'a'+i);

}

returnans;

};

vector<string>pieces(freqs.size());

for(inti=0;i<freqs.size();++i){

pieces[i]=getStringFromFreq(freqs[i]);

cout<<i<<" "<<pieces[i]<<endl;

}

constintMAX_T=1<<T;

vector<int>f(MAX_T,-1);

f[0]=0;

for(inti=0;i<MAX_T;++i){

if(f[i]<0)

continue;

for(constauto&piece :pieces){

intj=i;

for(constauto&c :piece){

// find the first k that does not appear in state i

for(intk=0;k<T;++k){

if((j>>k)&1)

continue;

if(target[k]==c){

j|=(1<<k);

break;

}

}

if(f[j]<0||f[j]>f[i]+1){

f[j]=f[i]+1;

}

}

}

}

returnf[MAX_T-1];

}

// BFS, slower version

// Time: O(N^{T+1} T^2), N is the number of tickers, T is the number of letters in the target word