10 2015 档案
摘要:题目:Write a SQL query to find all duplicate emails in a table namedPerson.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.co...
阅读全文
摘要:题目:TheEmployeetable holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+------...
阅读全文
摘要:题目:给出一个字符串Initial和另一个字符串Detection,判断Detection是否为Initial的一个出栈序列如:Initial =123456,Detection =213654, 则Detection是Initial的一个出栈序列思路一:可以使用栈代码: public sta...
阅读全文
摘要:题目:反转一个句子,要求句子中的每个单子都被反转,但单词本身不被反转如:I am a Boy! 反转为:Boy! a am I思路:左旋转处理1. 将整个句子的所有字符统一反转2. 根据空格,阶段单词,再反转每一个单词代码: public static String ReversalStrin...
阅读全文
摘要:题目: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 inte...
阅读全文
摘要:题目:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For ex...
阅读全文
摘要:题目:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled u...
阅读全文
摘要:题目:有一个宽为W个小格,高为H个小格,总小格数为W*H的棋盘。棋盘中,可以被涂色的小格用"P"标识,不可以涂色的小格用"B"标识,可以涂色也可以选择不涂色的小格用"?"标识。如下W=5, H=4的棋盘PPPBBPP?BBPP?PPBBP?P有一个儿童,手中有1*1 , 2*2, 3*3 等方形图章...
阅读全文
摘要:题目:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路1:找对应关系,90度翻转是...
阅读全文
摘要:题目:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the de...
阅读全文
摘要:题目:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note...
阅读全文
摘要:题目: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 s...
阅读全文
摘要:题目:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"(((...
阅读全文
摘要:题目:Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction ...
阅读全文
摘要:题目:A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any poi...
阅读全文
摘要:题目:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1]...
阅读全文
摘要:题目:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).Find the minimum element.Yo...
阅读全文
摘要:题目:Reverse a singly linked list.思路1:直接用循环遍历即可代码: public static ListNode reverseList(ListNode head) { if(head == null || head.next == null){ ...
阅读全文
摘要:题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析:平衡二叉树的特点:左右子树的高度差不能超过1采用二分查找思想和递归思想代码: publi...
阅读全文
摘要:题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2...
阅读全文
摘要:题目:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl...
阅读全文
摘要:题目:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. ...
阅读全文
摘要:题目Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]ret...
阅读全文
摘要:题目:思路1:遍历参考的字符S,从中取出一个字符在需要检查的字符T中,使用indexof来得出位置如果结果为-1 则直接返回false如果结果为1,则将该字符从T中删除代码: public static boolean isAnagram(String s, String t) { ...
阅读全文
摘要:题目:Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, r...
阅读全文
摘要:题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in...
阅读全文

浙公网安备 33010602011771号