上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmet 阅读全文
posted @ 2017-10-30 18:51 爱简单的Paul 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Given an array with n integers, your task is to check if it could become non-decreasing by modifying at most 1 element. We define an array is non-decr 阅读全文
posted @ 2017-10-30 17:44 爱简单的Paul 阅读(187) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n 阅读全文
posted @ 2017-10-28 21:17 爱简单的Paul 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. Note: Example 1: Examp 阅读全文
posted @ 2017-10-28 20:14 爱简单的Paul 阅读(196) 评论(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 must do this in-place without altering the nodes' values. For 阅读全文
posted @ 2017-10-26 20:04 爱简单的Paul 阅读(169) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2017-10-25 22:13 爱简单的Paul 阅读(2) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2017-10-25 22:12 爱简单的Paul 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 1. 翻转一个数字(leetcode 原题 #7 Reverse Integer) 注意溢出的问题 INT_MIN在标准头文件limits.h中定义。 1 2 在C/C++语言中,不能够直接使用-2147483648来代替最小负数,因为这不是一个数字,而是一个表达式。表达式的意思是对整数214736 阅读全文
posted @ 2017-10-25 20:19 爱简单的Paul 阅读(849) 评论(0) 推荐(0) 编辑
摘要: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by upd 阅读全文
posted @ 2017-10-24 17:42 爱简单的Paul 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 二叉树的前序、中序、后序遍历方式,递归与非递归。(层序遍历的方式已经在之前的博客中写过) 递归方式比较简单。 前序遍历: 前序遍历非递归: 基本思路: 利用栈。先输出结点值,再入栈。然后遍历左子树。退栈时,遍历栈顶结点的右子树。 中序遍历非递归: 先进栈,再遍历左子树,出栈时才会输出结点值 后序非递 阅读全文
posted @ 2017-10-23 19:10 爱简单的Paul 阅读(262) 评论(0) 推荐(0) 编辑
摘要: Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For 阅读全文
posted @ 2017-10-23 17:34 爱简单的Paul 阅读(835) 评论(0) 推荐(0) 编辑
摘要: The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another n 阅读全文
posted @ 2017-10-22 18:33 爱简单的Paul 阅读(560) 评论(1) 推荐(0) 编辑
摘要: 问了很多,不过很多也都没有问到,感觉有点偏,很深入的东西,越问越虚。第一次实习面试从百度开始,也从百度结束吧。看得见的差距,不想将就,所以还是拿最后一次机会去尝试。win or go home, 所以虽然心态又一次崩了,但是已经没有遗憾了。未来的路还很长,慢慢打好基础,来日方长。 1. 纯虚函数、虚 阅读全文
posted @ 2017-10-21 23:14 爱简单的Paul 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 思路:从根节点开始遍历,如果node1和node2中的任一个和root匹配,那么root就是最低公共祖先。 如果都不匹配,则分别递归左、右子树,如果有一个 节点出现在左子树,并且另一个节点出现在右子树,则root就是最低公共祖先. 如果两个节点都出现在左子树,则说明最低公共祖先在左子树中,否则在右子 阅读全文
posted @ 2017-10-21 00:28 爱简单的Paul 阅读(8092) 评论(2) 推荐(1) 编辑
摘要: // 非递归实现int Add (int num1, int num2){ int sum, carry; do{ sum = num1 ^ num2; // 做异或运算 carry = (num1 & num2) << 1; // 进位 ... 阅读全文
posted @ 2017-10-20 23:47 爱简单的Paul 阅读(164) 评论(0) 推荐(0) 编辑
摘要: DFS算法 思想:一直往深处走,直到找到解或者走不下去为止 DFS(dep,...) // dep代表目前DFS的深度 { if (找到解或者走不下去了){ return; } 枚举下种情况,DFS(dep + 1, ...) } DFS: 使用栈保存未被检测的节点,结点按照深度优先的次序被访问并依次压入栈中,并以相反的次序出栈进行新的检测 类似... 阅读全文
posted @ 2017-10-20 15:08 爱简单的Paul 阅读(1734) 评论(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 @ 2017-10-20 11:33 爱简单的Paul 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 输出是56 65.123 阅读全文
posted @ 2017-10-20 11:00 爱简单的Paul 阅读(4284) 评论(0) 推荐(0) 编辑
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam 阅读全文
posted @ 2017-10-20 10:29 爱简单的Paul 阅读(192) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Follow up:Wha 阅读全文
posted @ 2017-10-20 09:58 爱简单的Paul 阅读(157) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页