随笔分类 -  算法&Leetcode

摘要:Given two binary strings, return their sum (also a binary string).For example, a = "11" b = "1" Return "100". Subscribe to see which companies asked t... 阅读全文
posted @ 2015-12-22 16:58 0giant 阅读(159) 评论(0) 推荐(0) 编辑
摘要: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 as... 阅读全文
posted @ 2015-12-22 16:54 0giant 阅读(280) 评论(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 time... 阅读全文
posted @ 2015-12-21 17:21 0giant 阅读(205) 评论(0) 推荐(0) 编辑
摘要:Write a function to find the longest common prefix string amongst an array of strings.这个题目和count and say比较类似了。就是把单独处理字符串的函数写出来,然后一个循环来实现最终功能就行了。这道题,就是... 阅读全文
posted @ 2015-12-20 16:01 0giant 阅读(224) 评论(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 off... 阅读全文
posted @ 2015-12-18 21:38 0giant 阅读(175) 评论(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 --> 2 --... 阅读全文
posted @ 2015-12-17 09:50 0giant 阅读(173) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2015-12-16 11:13 0giant 阅读(141) 评论(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 occurrences... 阅读全文
posted @ 2015-12-16 10:37 0giant 阅读(170) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the c... 阅读全文
posted @ 2015-12-15 11:14 0giant 阅读(150) 评论(0) 推荐(0) 编辑
摘要: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 ... 阅读全文
posted @ 2015-12-15 09:20 0giant 阅读(170) 评论(0) 推荐(0) 编辑
摘要: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 ... 阅读全文
posted @ 2015-12-14 20:45 0giant 阅读(175) 评论(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 as sh... 阅读全文
posted @ 2015-12-13 21:56 0giant 阅读(241) 评论(0) 推荐(0) 编辑
摘要: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 ... 阅读全文
posted @ 2015-12-11 09:19 0giant 阅读(136) 评论(0) 推荐(0) 编辑
摘要:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with... 阅读全文
posted @ 2015-12-10 20:32 0giant 阅读(158) 评论(0) 推荐(0) 编辑
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return... 阅读全文
posted @ 2015-12-10 08:34 0giant 阅读(182) 评论(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 tha... 阅读全文
posted @ 2015-12-09 18:12 0giant 阅读(165) 评论(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 nearest le... 阅读全文
posted @ 2015-12-09 14:52 0giant 阅读(187) 评论(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:A: a... 阅读全文
posted @ 2015-12-08 11:36 0giant 阅读(156) 评论(0) 推荐(0) 编辑
摘要:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Subscribeto see which companies asked this question蛮简... 阅读全文
posted @ 2015-12-08 11:18 0giant 阅读(232) 评论(0) 推荐(0) 编辑
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2015-12-07 11:30 0giant 阅读(234) 评论(0) 推荐(0) 编辑