03 2019 档案

摘要:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's 阅读全文
posted @ 2019-03-31 13:17 __Meng 阅读(112) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
posted @ 2019-03-31 13:10 __Meng 阅读(134) 评论(0) 推荐(0) 编辑
摘要:请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径。路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下移动一个格子。如果一条路径经过了矩阵中的某一个格子,则之后不能再次进入这个格子。 例如 a b c e s f c s a d e e 这样的3 X 阅读全文
posted @ 2019-03-30 15:19 __Meng 阅读(161) 评论(0) 推荐(0) 编辑
摘要:地上有一个m行和n列的方格。一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子。 例如,当k为18时,机器人能够进入方格(35,37),因为3+5+3+7 = 18。但是,它不能进入方格(35,38),因为3+5+3+8 阅读全文
posted @ 2019-03-29 16:47 __Meng 阅读(251) 评论(0) 推荐(0) 编辑
摘要:请实现两个函数,分别用来序列化和反序列化二叉树 Java: 阅读全文
posted @ 2019-03-29 15:55 __Meng 阅读(188) 评论(0) 推荐(0) 编辑
摘要:从上到下按层打印二叉树,同一层结点从左至右输出。每一层输出一行。 C++: 阅读全文
posted @ 2019-03-29 11:10 __Meng 阅读(312) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return the postorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it iterative 阅读全文
posted @ 2019-03-28 16:39 __Meng 阅读(105) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, return the preorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it iterativel 阅读全文
posted @ 2019-03-28 16:26 __Meng 阅读(101) 评论(0) 推荐(0) 编辑
摘要:给定一棵二叉搜索树,请找出其中的第k小的结点。例如, (5,3,7,2,4,6,8) 中,按结点数值大小顺序第三小结点的值为4。 C++: 阅读全文
posted @ 2019-03-27 23:31 __Meng 阅读(247) 评论(0) 推荐(0) 编辑
摘要:请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符 "go" 时,第一个只出现一次的字符是 "g"。当从该字符流中读出前六个字符“google" 时,第一个只出现一次的字符是 "l"。 C++: 阅读全文
posted @ 2019-03-27 17:16 __Meng 阅读(301) 评论(0) 推荐(0) 编辑
摘要:把 n 个骰子仍在地上,求点数和为 s 的概率。 java: 阅读全文
posted @ 2019-03-27 16:29 __Meng 阅读(248) 评论(0) 推荐(0) 编辑
摘要:五张牌,其中大小鬼代表任意数字,牌面大小为 0。判断这五张牌是否能组成顺子。 C++: 阅读全文
posted @ 2019-03-27 15:52 __Meng 阅读(520) 评论(0) 推荐(0) 编辑
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes its 阅读全文
posted @ 2019-03-27 11:22 __Meng 阅读(114) 评论(0) 推荐(0) 编辑
摘要:让小朋友们围成一个大圈。然后,随机指定一个数 m,让编号为 0 的小朋友开始报数。每次喊到 m-1 的那个小朋友要出列唱首歌,然后可以在礼品箱中任意的挑选礼物,并且不再回到圈中,从他的下一个小朋友开始,继续 0...m-1 报数 .... 这样下去 .... 直到剩下最后一个小朋友,可以不用表演。 阅读全文
posted @ 2019-03-26 19:51 __Meng 阅读(156) 评论(0) 推荐(0) 编辑
摘要:求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 阅读全文
posted @ 2019-03-26 16:13 __Meng 阅读(109) 评论(0) 推荐(0) 编辑
摘要:写一个函数,求两个整数之和,要求在函数体内不得使用+、-、*、/四则运算符号。 C++: 阅读全文
posted @ 2019-03-26 15:57 __Meng 阅读(147) 评论(0) 推荐(0) 编辑
摘要:给定一个数组 A[0, 1,..., n-1],请构建一个数组 B[0, 1,..., n-1],其中 B 中的元素 B[i]=A[0]*A[1]*...*A[i-1]*A[i+1]*...*A[n-1]。要求不能使用除法。 阅读全文
posted @ 2019-03-26 15:29 __Meng 阅读(212) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example 阅读全文
posted @ 2019-03-26 11:25 __Meng 阅读(120) 评论(0) 推荐(0) 编辑
摘要:将一个字符串转换成一个整数,字符串不是一个合法的数值则返回 0,要求不能使用字符串转换整数的库函数。 Iuput: +2147483647 1a33 Output: 2147483647 0 C++: 阅读全文
posted @ 2019-03-26 10:53 __Meng 阅读(201) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2019-03-25 19:43 __Meng 阅读(121) 评论(0) 推荐(0) 编辑
摘要:给定一个数组和滑动窗口的大小,找出所有滑动窗口里数值的最大值。例如,如果输入数组{2,3,4,2,6,2,5,1}及滑动窗口的大小3,那么一共存在6个滑动窗口,他们的最大值分别为{4,4,6,6,6,5}; 针对数组{2,3,4,2,6,2,5,1}的滑动窗口有以下6个: {[2,3,4],2,6, 阅读全文
posted @ 2019-03-23 13:36 __Meng 阅读(116) 评论(0) 推荐(0) 编辑
摘要:1.同步 synchronized 2.轮询 while volatile 3.wait/notify机制 syncrhoized加锁的线程的Object类的wait()/notify()/notifyAll() ReentrantLock类加锁的线程的Condition类的await()/sign 阅读全文
posted @ 2019-03-21 22:47 __Meng 阅读(867) 评论(0) 推荐(0) 编辑
摘要:输入一个字符串(只包含 a~z 的字符),求其最长不含重复字符的子字符串的长度。例如对于 arabcacfr,最长不含重复字符的子字符串为 acfr,长度为 4。 java: 阅读全文
posted @ 2019-03-21 16:57 __Meng 阅读(616) 评论(0) 推荐(0) 编辑
摘要:当一个进程申请使用资源的时候,银行家算法通过先 试探 分配给该进程资源,然后通过安全性算法判断分配后的系统是否处于安全状态,若不安全则试探分配作废,让该进程继续等待。 安全序列 安全序列是指对当前申请资源的进程排出一个序列,保证按照这个序列分配资源完成进程。 数据结构 int n,m; //系统中进 阅读全文
posted @ 2019-03-10 14:20 __Meng 阅读(1035) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示