Facebook Backtracking Interview Question - Subsets - Leetcode 78

preview_player
Показать описание
FAANG Coding Interviews / Data Structures and Algorithms / Leetcode
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

I just learn about this and I thought this just can be used to solve puzzles but now I amazed

pstorm
Автор

Or just use a boolean indicating the presence of every symbol.

It becomes as simple as counting!

000 = []
001 = [1]
010 = [2]
011 = [1, 2]
100 = [3]
101 = [1, 3]
110 = [2, 3]
111 = [1, 2, 3]

symbolxchannel
Автор

Lol. I just realized I was drawing tree structures in elementary to math before I knew multiplications. Weird brain.

PostMeridianLyf
Автор

permutation formula is more simple way, estadistica - rules.

carloslopez-gznh
Автор

I think bit manipulation can also be used

GoodUser
Автор

Or, you know, just sum the number of predicates for a sequence length 0 to N, because combinitorics.

Validifyed
Автор

Subset up to ith index
Subset(ith) = add-ith-to-subset(ith -1) + subset(ith-1)

trongquocnguyen
Автор

At least show the code for more than half a second yeesh

RobertPodosek