Leetcode 389. Find the Difference [Java] | GOOGLE coding interview question

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ส.ค. 2024
  • Check out how to solve the leetcode 389 Find the Difference question in Java. This is one of GOOGLE's most commonly asked coding interview questions according to Leetcode.
    Question URL: leetcode.com/p...
    Please write in the comments below which leetcode problem you want me to solve next.
    And remember, a leetcode a day keeps unemployment away!
    Thanks for watching!
    #leetcode389

ความคิดเห็น • 3

  • @successinsoftwareengineeri4319
    @successinsoftwareengineeri4319 3 ปีที่แล้ว +1

    A problem with this solution is there could be a possible integer overflow (very large strings). To overcome this, you can add a character at index “i” in “t” and immediately subtract character at index “i” in “s”.
    When loop ends, you will be left with one character in “t”. Add it to your result.

    • @ifelsestatement7803
      @ifelsestatement7803  3 ปีที่แล้ว +1

      Yep, you are absolutely correct. This solution was based just on the constrains that leetcode provided (P.S. 0

  • @bekanaveriani1145
    @bekanaveriani1145 3 ปีที่แล้ว

    class Solution {
    public char findTheDifference(String s, String t) {
    int sC = 0;
    int tC = 0;
    for(int i=0; i