上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. 找二叉搜索树中第k个小的值。 用中序遍历,增加一个全局变量记录访问到第几个节点,返回访问的第k个节点的值。 阅读全文
posted @ 2017-12-19 21:25 Zzz...y 阅读(169) 评论(0) 推荐(0) 编辑
摘要: On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. Y 阅读全文
posted @ 2017-12-18 21:01 Zzz...y 阅读(1916) 评论(0) 推荐(0) 编辑
摘要: N-皇后问题(n*n棋盘上,放n个皇后,要求每一行,每一列,每一斜线都不能同时出现两个皇后)。统计一共有多少种方法。 解决:Backtracking. 添加pos变量:用来记录前几行皇后的位置 阅读全文
posted @ 2017-12-14 15:25 Zzz...y 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list t 阅读全文
posted @ 2017-12-12 18:29 Zzz...y 阅读(247) 评论(0) 推荐(0) 编辑
摘要: Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth 阅读全文
posted @ 2017-12-11 16:27 Zzz...y 阅读(138) 评论(0) 推荐(0) 编辑
摘要: A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[ 阅读全文
posted @ 2017-12-09 14:45 Zzz...y 阅读(120) 评论(0) 推荐(0) 编辑
摘要: The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文
posted @ 2017-12-07 21:50 Zzz...y 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 从一个文件,读取数据,再输出,一般在代码里实现就是用<fstream>,如http://www.cnblogs.com/Zzz-y/p/7885948.html 使用文件重定向会更加方便。 一段非常简单的输入输出数据的代码。编译,生成test.exe。 在命令窗口,在test.exe根目录下,输入 阅读全文
posted @ 2017-12-06 20:09 Zzz...y 阅读(1427) 评论(0) 推荐(0) 编辑
摘要: Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could 阅读全文
posted @ 2017-12-06 14:46 Zzz...y 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temp 阅读全文
posted @ 2017-12-05 17:46 Zzz...y 阅读(191) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 下一页