08 2016 档案

摘要:[题目] Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, 阅读全文
posted @ 2016-08-29 11:22 三刀 阅读(93) 评论(0) 推荐(0)
摘要:[题目] Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. [题目 阅读全文
posted @ 2016-08-26 16:32 三刀 阅读(161) 评论(0) 推荐(0)
摘要:[题目] Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in 阅读全文
posted @ 2016-08-26 15:22 三刀 阅读(149) 评论(0) 推荐(0)
摘要:[题目] Determine whether an integer is a palindrome. Do this without extra space. [题目解析] 判断一个给定整数是否为回文数,回文数即121,11411这种正着和反着相同的数字,最小的回文数是0。实现思路可以比较直接,先对 阅读全文
posted @ 2016-08-26 12:09 三刀 阅读(118) 评论(0) 推荐(0)
摘要:[题目] Implement atoi to convert a string to an integer. [题目解析] 该题目比较常见,从LeetCode上看代码通过率却只有13.7%,于是编码提交,反复修改了三四次才完全通过。该题目主要需要考虑各种测试用例的情况,比如"+5"、" 67"、" 阅读全文
posted @ 2016-08-25 21:46 三刀 阅读(166) 评论(0) 推荐(0)
摘要:[题目] Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 [题目解析] 思路比较直接,这里要特别注意的是负数和整数越界的情况。 注意判断是否溢出的时候,是判断的Int 阅读全文
posted @ 2016-08-25 15:17 三刀 阅读(199) 评论(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-08-18 22:27 三刀 阅读(103) 评论(0) 推荐(0)
摘要:[题目]Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. [题目解析] 这是对于求两 阅读全文
posted @ 2016-08-18 22:19 三刀 阅读(153) 评论(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 th 阅读全文
posted @ 2016-08-18 19:45 三刀 阅读(111) 评论(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 tha 阅读全文
posted @ 2016-08-18 00:59 三刀 阅读(145) 评论(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-08-17 21:01 三刀 阅读(162) 评论(0) 推荐(0)
摘要:[题目] Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identi 阅读全文
posted @ 2016-08-16 22:44 三刀 阅读(134) 评论(0) 推荐(0)
摘要:[题目] Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. [题目解析] 这是一个很简单的 阅读全文
posted @ 2016-08-14 18:01 三刀 阅读(135) 评论(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-08-14 16:25 三刀 阅读(105) 评论(0) 推荐(0)
摘要:[题目] Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the 阅读全文
posted @ 2016-08-14 15:44 三刀 阅读(548) 评论(0) 推荐(0)
摘要:[题目] Invert a binary tree. to 阅读全文
posted @ 2016-08-14 14:03 三刀 阅读(140) 评论(0) 推荐(0)
摘要:[题目] Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farth 阅读全文
posted @ 2016-08-14 13:35 三刀 阅读(132) 评论(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 阅读全文
posted @ 2016-08-13 11:52 三刀 阅读(137) 评论(0) 推荐(0)
摘要:Write a function that takes a string as input and returns the string reversed. Example:Given s = "hello", return "olleh". [题目解析] 这是个非常常见的题目,在面试中命中率极高, 阅读全文
posted @ 2016-08-13 00:05 三刀 阅读(151) 评论(0) 推荐(0)
摘要:题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would hav 阅读全文
posted @ 2016-08-02 19:23 三刀 阅读(547) 评论(0) 推荐(0)