随笔分类 - Leetcode
Solutions for the problems on Leetcode
摘要:问题: https://leetcode.com/problems/add-two-numbers-ii/#/description 思路:该题与“415. Add Strings”类似,都需要先将原来的数字序列翻转,然后就转化成了跟“2. Add Two Numbers”类似的问题,进而就容易解决
阅读全文
摘要:问题: https://leetcode.com/problems/01-matrix/#/description 基本思路:广度优先遍历,根据所有最短距离为N的格找到所有距离为N+1的格,直到所有的格都找到了最短距离。 具体步骤: 首先初始化矩阵,值为0的格其最短距离也是0,保持不变;值为1的格是
阅读全文
摘要:Problem: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...
阅读全文
摘要:问题: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 ...
阅读全文
摘要:1 public class Solution { 2 public ListNode mergeTwoLists(ListNode l1, ListNode l2) { 3 ListNode dummy1 = new ListNode(0), dummy2 = new L...
阅读全文
摘要:问题:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lon...
阅读全文
摘要:问题:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telep...
阅读全文
摘要:问题:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in th...
阅读全文

浙公网安备 33010602011771号