221. Maximal Square 208. Implement Trie (Prefix Tree) 211. Design Add and Search Words Data Structur

221. Maximal Square

棋盘格里面的每个位置都是以该位置为左上角,最大的方形的边长,从下往上,从右往左,那么每个格子就是由右下角的三个决定的。initialize的时候注意initialize最右边一条和最下边一条

208. Implement Trie (Prefix Tree)

注意这个构造的结构:自己创造了node,node是一个class,class里面需要有variabl,function,和constructor。注意写public。这个node class里有一个Node* 的variable。variable的名字是children/next...trie结构需要26的children,所以children后面要有[26]。

node构建好之后,开始构建trie。trie也是一个class。trie本身也有variable和function和constructor。题目需要自己写variable,填constructor和function。trie只需要一个variable:root。所以constructor只需要initialize一个varible:root = new Node(): root本身是一个node,作为node就有自己的constructor。

struct和class的区别:

  • Structures are value types; classes are reference types. A variable of a structure type contains the structure's data, rather than containing a reference to the data as a class type does.

  • Structures use stack allocation; classes use heap allocation.

  • All structure elements are Public by default; class variables and constants are Private by default, while other class members are Public by default. 

211. Design Add and Search Words Data Structure

trie+search

选dfs还是bfs呢?找path,选dfs(一般用recursion)

注意循环node->children[i]和word[i]的i不是一个i

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值