摘要:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp...
阅读全文
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The si...
阅读全文
摘要://快慢指针public class Solution {public boolean hasCycle(ListNode head) {if(head==null)return false;ListNode slow=head;ListNode fast=head;do{if(fast==null...
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target valu...
阅读全文
摘要:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
阅读全文
摘要:转载自:LeetCode Question Difficulty Distribution1Two Sum25arraysortsetTwo Pointers2Add Two Numbers34linked listTwo PointersMath3Longest Substring Without...
阅读全文
摘要: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).You are given a target value t...
阅读全文
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret...
阅读全文
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a...
阅读全文
摘要:import java.util.*;public class Solution { public static int reverse(int x) { int a=x,tmp=0,i; int []b=new int[32]; for(i=0;i=0;j--){ tmp+=b[j]...
阅读全文
摘要:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
阅读全文
摘要: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 an...
阅读全文
摘要:Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity...
阅读全文
摘要://如果sum>Max 则更新Max//如果sumMax)Max=sum; if(sum<0)sum=0;}//貌似双指针法,Max指针指向全局最大,sum指针移动,找到更大的则赋给Max,Max始终指向了全局最大
阅读全文