摘要: Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" Corner Cases: Di 阅读全文
posted @ 2018-03-20 13:09 轻风舞动 阅读(434) 评论(0) 推荐(0) 编辑
摘要: Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the n 阅读全文
posted @ 2018-03-20 09:06 轻风舞动 阅读(868) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up:Can you solve it without using extra space? 阅读全文
posted @ 2018-03-20 08:56 轻风舞动 阅读(415) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 给定一个链表,判断是否有环存在。Follow up: 不使用额外空间。 解法:双 阅读全文
posted @ 2018-03-20 08:46 轻风舞动 阅读(241) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to in 阅读全文
posted @ 2018-03-20 06:24 轻风舞动 阅读(423) 评论(0) 推荐(0) 编辑
摘要: Given two strings S and T, determine if they are both one edit distance apart. 72. Edit Distance 的类似题目,编辑距离是从一个单词变成另一个单词的变换步骤。变换步骤可以是:插入,删除和替换。所以考虑三种情 阅读全文
posted @ 2018-03-20 06:07 轻风舞动 阅读(749) 评论(0) 推荐(0) 编辑
摘要: Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2018-03-20 05:58 轻风舞动 阅读(249) 评论(0) 推荐(0) 编辑
摘要: A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde 阅读全文
posted @ 2018-03-20 05:32 轻风舞动 阅读(1477) 评论(0) 推荐(0) 编辑
摘要: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2018-03-20 04:24 轻风舞动 阅读(434) 评论(0) 推荐(0) 编辑
摘要: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: Cr 阅读全文
posted @ 2018-03-20 04:05 轻风舞动 阅读(676) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: Credits:Special thanks to @ifanchu for addin 阅读全文
posted @ 2018-03-20 03:59 轻风舞动 阅读(1043) 评论(0) 推荐(0) 编辑
摘要: Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 阅读全文
posted @ 2018-03-20 03:14 轻风舞动 阅读(420) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2018-03-20 02:53 轻风舞动 阅读(462) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
posted @ 2018-03-20 02:46 轻风舞动 阅读(296) 评论(0) 推荐(0) 编辑
摘要: 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 @ 2018-03-20 02:30 轻风舞动 阅读(816) 评论(0) 推荐(0) 编辑
摘要: If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers. For each integer in this list: Given a 阅读全文
posted @ 2018-03-20 02:00 轻风舞动 阅读(705) 评论(0) 推荐(0) 编辑