標籤:題目描述:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory. For example,Given input
標籤:題目描述:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.You may not alter the values in the nodes,
標籤:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times. Example 1:Given intervals [1,3],[6,9], insert and
標籤: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 does not exist, return 0.Note: A word is defined as a character sequence consists of non-space
標籤:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]] 解題思路:參考Java for LeetCode 05
標籤:題目描述:Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may not modify the values in
標籤:一 string public final class String繼承自java.lang.Object類。實現了介面:java.io.Serializable, Comparable<String>, CharSequenceString類是不能被修改的字串。因為String類裡面的資料是final類型的。 區別兩種方式:① String s = "aaaa";② String s1 = new String("aaaa");對於第一種,只在池中建立,
標籤:Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].解題思路一:用兩個指標startIndex和endIndex來維護每次添加intervals的start和end的位置,然後分類討論即可,JAVA實現如下:public List<Interval>
標籤:A robot is located at the top-left corner of a m x n grid (marked ‘Start‘ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish‘