04 2016 档案

摘要:题目: Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 题目解答:题目中要求在O(n)的时间复杂度和O(1)的空间 阅读全文
posted @ 2016-04-28 19:02 CodingGirl121 阅读(146) 评论(0) 推荐(0)
摘要:题目: Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner 阅读全文
posted @ 2016-04-28 14:36 CodingGirl121 阅读(159) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are: 题目解答:使用递归的方式来处理这道题目, 阅读全文
posted @ 2016-04-27 19:29 CodingGirl121 阅读(161) 评论(0) 推荐(0)
摘要:题目: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space (size 阅读全文
posted @ 2016-04-25 21:07 CodingGirl121 阅读(126) 评论(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 阅读全文
posted @ 2016-04-25 16:50 CodingGirl121 阅读(151) 评论(0) 推荐(0)
摘要:题目:Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. 阅读全文
posted @ 2016-04-25 16:28 CodingGirl121 阅读(131) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the neare 阅读全文
posted @ 2016-04-25 15:48 CodingGirl121 阅读(167) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tr 阅读全文
posted @ 2016-04-25 15:40 CodingGirl121 阅读(202) 评论(0) 推荐(0)
摘要:题目:Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 题目解答: 这个题目是要求出给定的整数n的 阅读全文
posted @ 2016-04-25 15:24 CodingGirl121 阅读(121) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: But the 阅读全文
posted @ 2016-04-24 00:46 CodingGirl121 阅读(150) 评论(0) 推荐(0)
摘要:题目:Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in fr 阅读全文
posted @ 2016-04-23 22:30 CodingGirl121 阅读(116) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the 阅读全文
posted @ 2016-04-23 21:32 CodingGirl121 阅读(109) 评论(0) 推荐(0)
摘要:题目:Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Yo 阅读全文
posted @ 2016-04-23 20:42 CodingGirl121 阅读(119) 评论(0) 推荐(0)
摘要:题目: Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "hello", return "holle". Example 2: Gi 阅读全文
posted @ 2016-04-23 20:00 CodingGirl121 阅读(331) 评论(0) 推荐(0)
摘要:题目:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transact 阅读全文
posted @ 2016-04-23 17:27 CodingGirl121 阅读(144) 评论(0) 推荐(0)
摘要:题目: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive in 阅读全文
posted @ 2016-04-23 17:04 CodingGirl121 阅读(152) 评论(0) 推荐(0)
摘要:题目: Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". 解答:这个题目超级无敌简单,就是把一个stri 阅读全文
posted @ 2016-04-22 16:48 CodingGirl121 阅读(115) 评论(0) 推荐(0)
摘要:题目: You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each 阅读全文
posted @ 2016-04-21 19:01 CodingGirl121 阅读(161) 评论(0) 推荐(0)
摘要:题目: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occur 阅读全文
posted @ 2016-04-21 17:03 CodingGirl121 阅读(112) 评论(0) 推荐(0)
摘要:题目:Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 题目解答:本题是不 阅读全文
posted @ 2016-04-21 16:43 CodingGirl121 阅读(119) 评论(0) 推荐(0)
摘要:题目: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stoppin 阅读全文
posted @ 2016-04-20 21:24 CodingGirl121 阅读(131) 评论(0) 推荐(0)
摘要:题目:Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2-> 阅读全文
posted @ 2016-04-20 21:04 CodingGirl121 阅读(122) 评论(0) 推荐(0)
摘要:题目:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipe 阅读全文
posted @ 2016-04-20 20:37 CodingGirl121 阅读(156) 评论(0) 推荐(0)
摘要:题目:Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For 阅读全文
posted @ 2016-04-20 19:25 CodingGirl121 阅读(136) 评论(0) 推荐(0)
摘要:题目: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 阅读全文
posted @ 2016-04-20 19:15 CodingGirl121 阅读(111) 评论(0) 推荐(0)
摘要:题目:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read 阅读全文
posted @ 2016-04-20 19:03 CodingGirl121 阅读(119) 评论(0) 推荐(0)
摘要:题目:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 解题思路:罗马数字的构成规则是: 相同的数字连写,所表示的数等于这些数字相加得 阅读全文
posted @ 2016-04-19 18:49 CodingGirl121 阅读(109) 评论(0) 推荐(0)
摘要:题目:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the 阅读全文
posted @ 2016-04-19 18:05 CodingGirl121 阅读(101) 评论(0) 推荐(0)
摘要:题目: Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", 阅读全文
posted @ 2016-04-19 18:00 CodingGirl121 阅读(162) 评论(0) 推荐(0)
摘要:题目:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, 阅读全文
posted @ 2016-04-19 16:49 CodingGirl121 阅读(120) 评论(0) 推荐(0)
摘要:题目:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 s 阅读全文
posted @ 2016-04-19 16:35 CodingGirl121 阅读(121) 评论(0) 推荐(0)
摘要:题目:Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given num = 16, return true. Given num = 5, retur 阅读全文
posted @ 2016-04-19 15:35 CodingGirl121 阅读(174) 评论(0) 推荐(0)