摘要:
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.大整数乘法,一位一位往上乘,注意进位的处理即可。此外,注意0的处理 1 public class Solution { 2 public String multiply(String num1, String num2) { 3 // Start typing yo... 阅读全文
摘要:
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B aremandnrespectively.从后往前遍历,减少移动次数。此题与替换字符串类似 1 public void merge(int A[], int m, int B[], int n) 阅读全文
摘要:
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the two partitions.For example,Given1->4->3->2->5->2andx= 3,return1->2->2->4->3- 阅读全文