Leet Code Selected Java Solutions

A Solution Set Restricted to Java Language

The practice on LeetCode was started late November 2019, writing this post can remind me how I thought about the question at the time.

Problem 2: Add Two Numbers (Medium, List Manipulation)

  • we can assign an extra node to form the result list.

  • Monitor the current two digits to calculate the carry and then do the normal addition work.

  • Remember to check the null node when the length of two adders are different

Problem 3: Longest Substring Without Repeating Characters (Medium, Sliding Window)

My thoughts:

  • Using greedy to store the length of longest non-repeating substring
  • When encounter a duplicated character, recording the length between two duplicted character
  • Then comparing it with the current length plus one to deal with the special case “abba”
1
currentLength = (currentLength + 1) < lengthBetween ? currentLength + 1 : lengthBetween; //deal with "abba"

Provided Solution

  • To be continued
Site by Shengyu Jin using hexo blog framework. Late Updated: May 6, 2020

载入天数...载入时分秒...