leetcode [#142]
题目 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. 解决方案12345678910111213141516171819202122232425/** * Definition for singly-linked list. * class List
题目 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. 解决方案12345678910111213141516171819202122232425/** * Definition for singly-linked list. * class List
题目 Sort a linked list using insertion sort. 解决方案12345678910111213141516171819202122232425262728293031323334353637383940/** * Definition for singly-linked list. * public class ListNode { *
题目 Given a linked list, determine if it has a cycle in it. 解决方案12345678910111213141516171819202122232425/** * Definition for singly-linked list. * class ListNode { * int val; * ListNod
题目 Write a function to find the longest common prefix string amongst an array of strings. 解决方案1234567891011121314151617181920212223242526272829303132public class Solution { public String lo
题目 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 解决方案1234567891011121314151617181920212223242526272829303132333435363738394041424344454
题目 Given an array of integers, every element appears twice except for one. Find that single one. 解决方案123456789101112131415161718import java.util.Hashtable;public class Solution { public int
题目 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Example“A man, a plan, a canal: Panama” is a palindrome.“race a car” is not a palindro
题目 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy o
题目 Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock)
题目 Given an index k, return the kth row of the Pascal’s triangle. Example:given k = 3,Return [1,3,3,1]. 解决方案1234567891011121314151617181920212223public class Solution { public List<Integ
题目 Given numRows, generate the first numRows of Pascal’s triangle. Example:given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]] 解决方案1234567891011121314151617181920publi
题目 Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example:Given nums = [2, 7
题目 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 leaf node. 解决方案123456789101112131415161718192