標籤:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.解題思路:往一個用數組表示的數裡面加1,注意下資料溢出即可,JAVA實現如下: public int[] plusOne(int[]
標籤:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any point in
標籤:題目描述: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 signature of the function had been updated to return the index instead of the pointer. If
標籤:java 封裝 Java語言是一個物件導向的語言,但是Java中的基礎資料型別 (Elementary Data Type)卻是不物件導向的,這在實際使用時存在很多的不便,為瞭解決這個不足,在設計類時為每個基礎資料型別 (Elementary Data Type)設計了一個對應的類進行代表,這樣八個和基礎資料型別 (Elementary Data
標籤:內容:在Java中利用Callable進行帶返回結果的線程計算,利用Future表示非同步計算的結果,分別計算不同範圍的Long求和,類似的思想還能夠借鑒到需要大量計算的地方。public class Sums { public static class Sum implements Callable<Long> {private final Long from;private final Long to;public Sum(long from,
標籤: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 is marked as 1 and 0 respectively in the grid.For example,There is one obstacle in the middle of
標籤:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.解題思路:只需找到對應的位置,然後指向head,接著把之前節點指向null即可,注意k可以取大於length的值,所以k%=