leetcode
文章平均质量分 67
zj443108444
这个作者很懒,什么都没留下…
展开
-
LEETCODE 202
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 integer, replace the number by the sum of the squares原创 2016-03-23 21:26:27 · 261 阅读 · 0 评论 -
LEETCODE 326
Given an integer, write a function to determine if it is a power of three.class Solution {public: bool isPowerOfThree(int n) { if(n == 0) return false; if (1 == n)原创 2016-03-11 19:57:43 · 331 阅读 · 0 评论 -
LEETCODE 190
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as0011100101原创 2016-03-11 19:36:13 · 492 阅读 · 0 评论 -
LEETCODE 189
Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as原创 2016-03-11 17:13:44 · 409 阅读 · 0 评论 -
LEETCODE 172
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.本题的意思是计算N的阶乘最后一共有多少个零。首先要分析零是怎么来的?每出现一个零,那么必然会有10这个因素,10 = 2原创 2016-03-11 15:56:20 · 408 阅读 · 0 评论 -
LEETCODE 171
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...原创 2016-03-11 15:28:43 · 238 阅读 · 0 评论 -
LEETCODE 169
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 array is non-empty and the majority element原创 2016-03-10 22:36:07 · 292 阅读 · 0 评论 -
LEETCODE 168
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB 思路,相当于1原创 2016-03-10 21:35:13 · 414 阅读 · 0 评论 -
LEETCODE 205
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 occurrences of a character must be replaced with anot原创 2016-03-23 21:49:09 · 261 阅读 · 0 评论 -
LEETCODE 206
Reverse a singly linked list.click to show more hints.Hint:A linked list can be reversed either iteratively or recursively. Could you implement both?Subscribe to see which companie原创 2016-03-23 22:15:53 · 298 阅读 · 0 评论 -
LEETCODE 338
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5原创 2016-03-26 23:12:48 · 409 阅读 · 0 评论 -
LEETCODE 290
Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.原创 2016-03-26 22:53:45 · 358 阅读 · 0 评论 -
LEETCODE 278
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the原创 2016-03-25 20:03:21 · 258 阅读 · 0 评论 -
LEEDCODE 234
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?Subscribe to see which companies asked this question刚开始没住时间复杂度和空间复杂度:原创 2016-03-24 23:03:42 · 324 阅读 · 0 评论 -
LEETCODE 226
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1观察到规律为:任意一个节点的左右子节点交换即可。/** * Definition for a binary tree node.原创 2016-03-24 22:41:39 · 261 阅读 · 0 评论 -
LEETCODE 219
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and jis at most k.S原创 2016-03-24 22:33:40 · 249 阅读 · 0 评论 -
LEETCODE 217
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 array, and it should return false if every element原创 2016-03-24 22:22:59 · 281 阅读 · 0 评论 -
LEETCODE 191
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 000000原创 2016-03-14 14:28:49 · 217 阅读 · 0 评论 -
LETCODE 165
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co原创 2016-03-10 20:54:22 · 234 阅读 · 0 评论 -
LEETCODE 160
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘原创 2016-03-10 18:24:28 · 611 阅读 · 0 评论 -
LEETCODE 58
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is原创 2016-03-08 10:01:15 · 238 阅读 · 0 评论 -
leetcode 第五题 找到最长回文串
leetcode第五题,给一个字符串,找到字符串中最长的回文串原创 2015-11-19 19:47:42 · 317 阅读 · 0 评论 -
LeetCode 第12题 整数转罗马字符
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question(1)前置条件为 1(2)取出每一位,得到对原创 2015-11-23 22:59:10 · 259 阅读 · 0 评论 -
LeetCode 19题 删除链表给定的倒数第N个值
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the原创 2015-11-24 21:31:25 · 450 阅读 · 0 评论 -
LeetCode 第7题 翻转数字
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321非常简单的一道题,最主要的错误是没有考虑到翻转以后会越界。int 最大只能保存2^32-1 即-2147483648~~~~2147483647 ,因此在使用中间变量时使用long 类型,l原创 2015-11-20 23:00:46 · 321 阅读 · 0 评论 -
Leetcode 第6题 ZIGZAG后,行列输出
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I原创 2015-11-19 22:12:07 · 340 阅读 · 0 评论 -
LeetCode 20 题 判断括号使用是否正确
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va原创 2015-12-02 16:24:08 · 441 阅读 · 0 评论 -
Leetcode 第8题 判断一个整数是否为回文串
etermine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Subscribe to see which companies asked this question思路很简单,直接将原回文串导过来,判断是否相等。(负数不知道怎么处理原创 2015-11-21 19:07:12 · 294 阅读 · 0 评论 -
LEETCODE 66
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.首先考虑有以下几种情况:原创 2016-03-08 10:31:59 · 194 阅读 · 0 评论 -
LEETCODE 67
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".考虑有以下情况a = "11", b = "00",即不需向前进位,且二者长度相同a = "11", b = "0", 即不需向前进位,且二原创 2016-03-08 15:41:37 · 306 阅读 · 0 评论 -
LEETCODE 155
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get原创 2016-03-10 17:08:02 · 695 阅读 · 0 评论 -
LEETCODE 125
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is no原创 2016-03-09 17:16:20 · 843 阅读 · 0 评论 -
LEETCODE 119
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].思路:首先计算每一行的值,最后返回要求的行。特别注意:给出的例子是第三行,返回【1,3,3,1】。则意味着行数应从第0行开始。这一点最开始没注意,花了很多时间。原创 2016-03-09 16:45:02 · 308 阅读 · 0 评论 -
LEETCODE 118
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]第一种思路,注意到第一行第二行和其原创 2016-03-09 16:26:53 · 273 阅读 · 0 评论 -
LEETCODE 101
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f原创 2016-03-09 15:35:29 · 250 阅读 · 0 评论 -
LEETCODE 100
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 identical and the nodes have the same value.类似于遍原创 2016-03-09 14:51:44 · 372 阅读 · 0 评论 -
LEETCODE 88
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 that is greater or equal to m + n) to hold add原创 2016-03-08 16:49:19 · 223 阅读 · 0 评论 -
LEETCODE 83
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->3->3, return 1->2->3.这个问题很适合用双指针来解决。一个原创 2016-03-08 15:59:23 · 229 阅读 · 0 评论 -
腾讯实习生一面
面试官很NICE.路上堵车,还有一公里的时候下车自己跑过去的,所以全程状态一直不好(当然,自己基础也不好)。(1)讲一讲对测试开发的理解。(2)讲一讲白盒和黑盒。(3)讲一讲QQ登陆需要测试什么(4)讲了下自己做的项目,面试官貌似对于机器学习和深度学习挺感兴趣。(5)深度学习的优势(6)讲一讲对于移动互联网的认识(7)一天之内,时针和分针重合多少次。原创 2016-04-19 13:27:25 · 512 阅读 · 0 评论