随笔分类 - ~~Leetcode~~
摘要: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?题目意思: 给定一个单链表,判断它是不是回文串 进一步思考: ...
        阅读全文
                
摘要:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ...
        阅读全文
                
摘要:Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur...
        阅读全文
                
摘要:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota...
        阅读全文
                
摘要:Given an integer, write a function to determine if it is a power of two.题目意思: 给定一个整数,判断是否是2的幂解题思路: 如果一个整数是2的幂,则二进制最高位为1,减去1后则最高位变为0,后面全部是1,相与判读是否为零,...
        阅读全文
                
摘要: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 front o...
        阅读全文
                
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
        阅读全文
                
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"Corner Cases:Did you con...
        阅读全文
                
摘要:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i...
        阅读全文
                
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA...
        阅读全文
                
摘要:There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi...
        阅读全文
                
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ...
        阅读全文
                
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
        阅读全文
                
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on...
        阅读全文
                
摘要: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 ...
        阅读全文
                
摘要:Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,...
        阅读全文
                
摘要:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.class Solution {public: ...
        阅读全文
                
摘要:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc...
        阅读全文
                
摘要:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace...
        阅读全文
                
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially...
        阅读全文
                

 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号