随笔分类 - 算法&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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings.这个题目和count and say比较类似了。就是把单独处理字符串的函数写出来,然后一个循环来实现最终功能就行了。这道题,就是...
阅读全文
摘要: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...
阅读全文
摘要: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 --...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the c...
阅读全文
摘要: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 ...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要: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 ...
阅读全文
摘要: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...
阅读全文
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Subscribeto see which companies asked this question蛮简...
阅读全文
摘要: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...
阅读全文