Maximum Length of a Concatenated String with Unique Characters

Sdílet
Vložit
  • čas přidán 8. 07. 2024
  • For business inquiries email partnerships@k2.codes SOCIAL
    ----------------------------------------------------------------------------------------------------------------
    Instagram: / kevinnaughtonjr
    Twitter: / kevinnaughtonjr
    Patreon: / kevinnaughtonjr
    Merch: teespring.com/stores/kevin-na...
    GitHub: github.com/kdn251
    MUSIC
    ----------------------------------------------------------------------------------------------------------------
    look at me. by ☽shinji☾
    / balm
  • Věda a technologie

Komentáře • 165

  • @KevinNaughtonJr
    @KevinNaughtonJr  Před 4 lety +5

    instagram: instagram.com/kevinnaughtonjr/
    twitter: twitter.com/kevinnaughtonjr
    patreon: www.patreon.com/KevinNaughtonJr
    merch: teespring.com/stores/kevin-naughton-jrs-store

    • @stonecoldcold2941
      @stonecoldcold2941 Před 4 lety +2

      I have a doubt. When you call the maxUnique function recursively inside that function for the first time..the current doesnt change only index changes. It means the current is always an empty string right. So what is the use of it. Why do we have to do this for empty string.

    • @akshaygupta1990
      @akshaygupta1990 Před 3 lety

      @@stonecoldcold2941 At first i also have the same thought. then i wrote all the recursive calls ..that first recursion call plays a big role when the 2nd recursive call happens .

  • @joaonascimento3574
    @joaonascimento3574 Před 4 lety +2

    What i most like in your videos is just the fact how you explain things kind of complicated in a easy way... i feel like i can finally understand things in the same way i feel a overwhelming will for learn more and more.. thanks for sharing your knowledge. Big hug from Brazil

  • @MiCriFri
    @MiCriFri Před 3 lety +18

    wouldn't it be much faster converting all to a set - if it's size is longer than the initial one - throw it our right away - otherwise do it with all permutations?

  • @mostinho7
    @mostinho7 Před 3 lety +2

    10:05 We loop through the original array (left to right), and at each step we simulate concatenating the item we’re on to our string or not concatenating it (skipping it)

  • @algorithmimplementer415

    Excellent explanation!

  • @piyushdoke
    @piyushdoke Před 2 lety +2

    The complexity can be improved if you don't make those two calls always but based on condition. If characters from the array[index] are already present in current, then calling backtrack function with the next index and same Current string would be the case and otherwise call the backtrack function would be with the next index and Current + array[index].

  • @sandeeppadhi4209
    @sandeeppadhi4209 Před 3 lety

    You are doing a great work

  • @rushilthareja3340
    @rushilthareja3340 Před 4 lety +10

    SLIGHT HICCUP ! only strings that have unique characters can be added so before adding a string check if it has unique characters itself and with the string already formed . this way at an average 50 % recursive calls would be saved

    • @BrettClimb
      @BrettClimb Před 3 lety

      I'm confused, isn't it a worse issue than that? By adding strings that don't have unique characters, isn't he allowing for incorrect solutions (strings that are longer and have redundant characters). Why wouldn't his algorithm just give you the concatenation of all of the strings in the array? Maybe I'm missing something in the code, but I don't see where it's excluding invalid concatenations.

    • @Terszel
      @Terszel Před 3 lety

      @@BrettClimb it doesnt. It will always run at worst case runtime, but it will only take the answer if it is unique. In a real interview they may ask if there's better ways to cut down the number of strings you are checking

  • @empvaibhav9799
    @empvaibhav9799 Před 2 lety +2

    Bro complexity 📈📈📈🥵

  • @vigneshmohan6763
    @vigneshmohan6763 Před 4 lety +2

    Are you saying this is 2^n runtime? If yes, is it not too slow? Can you tell whether I understood right?

  • @nikitagupta8114
    @nikitagupta8114 Před 3 lety

    Hi Kevin! Thanks for the explanation. I really like your videos. Stay safe.

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 3 lety

      Thanks Nikita! If you like my explanations be sure to join the interviewing service I created thedailybyte.dev/?ref=kevin I recommend joining a premium plan if you can!

  • @sarahjeffry3748
    @sarahjeffry3748 Před 3 lety +3

    nice video! thank you for explaining the recursive solution. Could you elaborate more on why we need the first recursive call? I didn't get that part

    • @faizm4765
      @faizm4765 Před 2 lety

      So to create all possible substring, we have two oprions fpr each string in the given vector either to include it or ignore it. First recursive call ignores string at index and second recursive call includes the string at the given index.

  • @dmitrykarpenko2271
    @dmitrykarpenko2271 Před 4 lety +1

    Can we use a Hash Map of currently added words by their unique chars instead of current string?
    This way you will check, do we do one (a char in not in the hash map) or two (a char is in the hash map, thus replace or don't replace it) recursive calls not iterratng through current. Thanks!

    • @prasadvaizus6115
      @prasadvaizus6115 Před 4 lety

      Dmitry Karpenko I believe we need to use the entire string from each array string .. so HashMap, we won’t be able to track each string in an array individually.

  • @jaynilgaglani9480
    @jaynilgaglani9480 Před 4 lety +2

    Hey are you solving premium leetcode questions in your playlists of specific companies?

  • @dyyfkdyyfk6772
    @dyyfkdyyfk6772 Před 4 lety +6

    Shouldn't the helper function being considered when calculating the time complexity?
    I think the time complexity should be O(w*2^n) where w is the average length of words and n is the number of words

  • @rahulchawla958
    @rahulchawla958 Před 2 lety +1

    Hey Kevin! Question - I don't think you recall why we need to simulate both the recursive calls, whats the purpose of not adding to current?

    • @carterk9222
      @carterk9222 Před 2 lety +1

      ["abc", "de", "def"] shows why you need to simulate not adding to current.

  • @arghadeepsaha9446
    @arghadeepsaha9446 Před 4 lety +1

    u doing a great job inspiring us all,although u explain really well but its me ex who made me realise my inner potential and dream of working in product based company.cheers.

  • @jaspreets1097
    @jaspreets1097 Před 4 lety +2

    Hey Kevin (or anyone really). Do you think questions are reasonable to expect for SWE internship positions as well? I know its still good to practice but just wanted to judge the difficulty level. Thanks!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety +3

      Jaspreet S depends on the question in my opinion. If you need help with questions be sure to sign up for the interviewing service I created it’ll teach you how to solve all kinds of problems like this thedailybyte.dev/?ref=kevin I recommend joining the premium tier if you can

  • @aronblanche
    @aronblanche Před 4 lety +2

    Hi kevin why we are storing result in an array instead of an integer

    • @siobhanahbois
      @siobhanahbois Před 4 lety +1

      He answered it in the comments "The reason for using the integer array instead of an integer is because integers are passed by value (not reference like an integer array) so therefore it doesn't retain it's value throughout all the recursive calls"

  • @joseph615
    @joseph615 Před 4 lety +6

    I tried to use an integer to keep track of the maximum length, and the output is 0. Can you tell me why it doesn't work? (I used for exact code besides the result array)

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety +11

      hey John sorry I meant to touch on that and forgot to in the problem. The reason for using the integer array instead of an integer is because integers are passed by value (not reference like an integer array) so therefore it doesn't retain it's value throughout all the recursive calls

    • @joseph615
      @joseph615 Před 4 lety

      Thank you very much Kevin!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety

      John Smith anytime!

    • @waterislife9
      @waterislife9 Před 4 lety

      @@KevinNaughtonJrAh, this actually clarified a lot of things for me :) Thanks!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety

      @@waterislife9 Anytime! If this helped you, you should definitely check out thedailybyte.dev/ :)

  • @mandeepbahal23
    @mandeepbahal23 Před 4 lety +3

    Kevin ! why dont we use an int variable instead of using int array of a unit size ?

    • @miguelsegura1794
      @miguelsegura1794 Před 3 lety

      Well, one way of doing would be creating a private static int property, so you could access this property from any of this class's methods instead of passing it as an input.

    • @DanKaschel
      @DanKaschel Před 2 lety

      To create a variable that is passed by reference. An integer passed in the same way would be passed by value and could not be mutated.
      IMO it's a pretty ugly way to do it, but it works.

  • @mostinho7
    @mostinho7 Před 3 lety +3

    At 1:29, would the string un+ue be considered a concatenation?

    • @KartikChugh
      @KartikChugh Před 2 lety

      Nah the u is the acharacter, hence not valid

  • @madhavchittlangia7044
    @madhavchittlangia7044 Před 2 lety +1

    Can you please explain why you used an array of size 1 instead of maintaining a single integer variable?

    • @ayoubalem865
      @ayoubalem865 Před 2 lety

      because he wants to modify it every time he found a new max length, so if he tried to modify a global integer he will get an error, instead with a global array it will work ! you can try it .

  • @samuelalvarado6044
    @samuelalvarado6044 Před 2 lety +1

    May I ask why you decided to use an integer array of one item over a single integer variable?

    • @ayham95
      @ayham95 Před 2 lety +1

      Because in Java, primitives are passed by value. So when you try to update an int, it won’t update the original variable but its copy. An array value on the other hand is it’s address. So in some ways it’s passed by reference. Please note that java is pass by value only

  • @jamesh1707
    @jamesh1707 Před rokem

    This is a dynamic programming question, not a "Classical DFS" as mentioned at 3:39. It can be solved either through tabulation or memoization. The solution presented here is sub-optimal because it duplicates a significant amount of work.

  • @romanesterkin
    @romanesterkin Před 3 lety +6

    Kevin, great explanation. Thanks!
    I'd suggest to improve time complexity by:
    1. don't call recursion if the string already has duplications;
    2. use memoization inside uniqueCharCount function.
    Improve the space complexity a little bit by using 4byte int instead of array of 26 integers:
    int length = 0;
    int binaryRepresentation = 0;
    for (char c : current.toCharArray()) {
    int shift = 1;
    shift

    • @z08840
      @z08840 Před 2 lety +2

      I would say you don't understand what complexity is :)

    • @DanKaschel
      @DanKaschel Před 2 lety +1

      @@z08840 actually, it sounds like you don't

    • @z08840
      @z08840 Před 2 lety

      @@DanKaschel actually nobody cares how it sounds to you.

    • @anudeepreddy1027
      @anudeepreddy1027 Před 2 lety

      @@z08840 yes indeed 😂

  • @qammaruzzamman9621
    @qammaruzzamman9621 Před rokem

    I am not able to do a dry run of this code, can anyone help?

  • @josevalbuena9423
    @josevalbuena9423 Před 4 lety

    why if (counts[ c - 'a']++ > 0) instead of > 1 ? I'm thinking the first encounter of each character++ is valid right? after that then > 1 means repeated?

    • @alexhong794
      @alexhong794 Před 4 lety

      counts array represents how many duplicates.
      i.e.
      a b -> we have 0 duplicate for a. so count[ch - 'a'] == 0
      if aab -> we have 1 duplicate for a. so count[ch - 'a'] == 1
      so if count[ch - 'a']++ > 0 means we have as least 1 duplicates.
      count array is used to count how many extra / duplicate chars, but not used to count how many characters encountered.
      hope it helps you.

    • @aronblanche
      @aronblanche Před 4 lety +3

      He's using post increment, first it'll get compute then added by 1

  • @rivaille8867
    @rivaille8867 Před 4 lety +9

    At first I thought how the hell am I gonna do this , then I looked at the constraints and I was like brute force😒😒😒

  • @jaychally2251
    @jaychally2251 Před 3 lety +17

    So what is like a good indicator of 'Use DFS or BFS on this problem?' Like where exactly do you use DFS in this problem?

    • @juda550
      @juda550 Před 2 lety +2

      Usually in problems where you need to produce all possible combinations of something, you'll need to use DFS. Example problems in addition to this one are combinations, permutations, and subsets

    • @Varunshrivastava007
      @Varunshrivastava007 Před 2 lety

      Just be vary of the fact that dfs is expensive. So try to implement caching whereever possible

  • @sundarkris1320
    @sundarkris1320 Před 3 lety +2

    I don’t think he explained the reason for two recursive call .. he just read the code. Any one else(perhaps who thanked for the video) can explain here

  • @eugenekim6937
    @eugenekim6937 Před 3 lety +1

    A little lost on the time and space complexity here. You said in the video that the space complexity is the same as the time. But you're saying time is O(2^N) and space is O(N)? Isn't space supposed to be O(2^N) as well?
    Thanks in advance,
    Eugene

  • @pratikchowdhury9210
    @pratikchowdhury9210 Před 4 lety +1

    nice background mate :)

  • @sangrammore4073
    @sangrammore4073 Před 2 lety

    Can we concatenate all the elements together in the given list and then delete same elements within concatenated string thus giving us the longest unique string?

  • @ShaliniNegi24
    @ShaliniNegi24 Před 3 lety +1

    Nice explanation, please try to explain time complexity in more detail.

  • @okayokay5287
    @okayokay5287 Před 2 lety

    Can we just calculate the length of the max and the second max length string
    And return the the sum of them?

  • @JSDev776
    @JSDev776 Před 3 lety

    the hint in the leet code says use DP, so i thought there will be a sophisticated DP solution, but this is simple recursion.

  • @abhaytiwari6411
    @abhaytiwari6411 Před 4 lety

    wow wow
    thanks for making video
    all lots of love from India

  • @ChocolateMilkCultLeader
    @ChocolateMilkCultLeader Před 4 lety +1

    For this solution, is the result array being passed by value? That's the only this makes sense. I thought Java was a pass by reference language?

    • @leanobajio
      @leanobajio Před 4 lety +1

      result array is being passed by reference. passed by reference allows the callee function (maxUnique) to return the reference to the result array after it's value has been modified.

    • @ChocolateMilkCultLeader
      @ChocolateMilkCultLeader Před 4 lety

      @@leanobajio he isn't returning anything though

    • @leanobajio
      @leanobajio Před 4 lety

      @@ChocolateMilkCultLeader he is passing the result array to maxUnique and then returning the 0th element in it in the maxLength function

    • @a.yashwanth
      @a.yashwanth Před 4 lety +1

      I think the pointer is being passed here. That's why he might have taken array instead of variable.

  • @adamberry7536
    @adamberry7536 Před 4 lety

    Hey Kevin,
    Would it be more efficient to only call the backtrack function with the concatenation if the current string + concatenated string only contained unique characters and move that unique character check? That way you would only be doing a partial depth-first-traversal instead of a full depth-first traversal.
    Thanks for your videos!

    • @BrettClimb
      @BrettClimb Před 3 lety

      By allowing strings to be concatenated that share a character, isn't he allowing for incorrect solutions? Why wouldn't his algorithm just give you the concatenation of all of the strings in the array? Maybe I'm missing something in the code, but I don't see where it's excluding invalid concatenations.

    • @KartikChugh
      @KartikChugh Před 2 lety

      @@BrettClimb if they share a character the helper returns -1 which will never be > than anything

  • @osamadar1358
    @osamadar1358 Před 3 lety

    Why is result an array? Couldn't it be an integer?

  • @antoniowong6269
    @antoniowong6269 Před 3 lety +1

    Thanks for the video. This approach will work for getting maximum unique characters in concatenated strings, but it has re-evaluated same strings in the take it / not take it decision tree. How about looping through the string array, concatenate strings along the way and recurse? Like:
    public void LongestUniqueStringRecursive(string[] s, int index, string current, int []max)
    {
    if (current.Length > max && CheckUniqueness(current))
    {
    max[0] = Math.Max(max[0], current.Length);
    }
    for (int i = index; i< s.Length; i++)
    {
    LongestUniqueStringRecursive(s, i + 1, current + s[i], max);
    }
    }
    This code generates and evaluates string once.
    However, if the question is changed to "Tell me how many ways to generate strings with unique characters from the given array, Kevin's solution is simplest if the code is altered to return int (representing a find)

    • @anudeepreddy1027
      @anudeepreddy1027 Před 2 lety

      I think the time complexity is going to be too large( n^n), If I'm not wrong 🤔

  • @sumodbadchhape9823
    @sumodbadchhape9823 Před 3 lety

    I solved it using DP by applying the technique of Longest Increasing Subsequence. But I was only able to pass 82 / 85 test cases. Can anyone let me know what am I doing wrong?
    import collections
    def hasUniqueChars(ss):
    c = collections.Counter(ss)
    for x in c.values():
    if x > 1:
    return False
    return True
    def lenOfConcatenatedSubstringWithUniqueChars(arr):
    dp = [x if hasUniqueChars(x) else '' for x in arr]
    dpCopy = dp[:]
    print(dp)
    for i in range(len(dp)):
    if dp[i] == '':
    continue
    for j in range(i):
    p = dpCopy[j]+dp[i]
    if hasUniqueChars(p) and len(p) > len(dpCopy[i]):
    dpCopy[i] = p
    maxLen = 0
    for s in dpCopy:
    maxLen = max(maxLen, len(s))
    return maxLen

  • @BelanyZhang
    @BelanyZhang Před 2 lety

    Why does result have to be an array? Why can't it be just an integer? And if it is an integer, how can we make it so that the recursive function modifies the actual integer result instead of a copy?

    • @Varunshrivastava007
      @Varunshrivastava007 Před 2 lety

      arrays in java are stored in heap memory thus preserved during recursive stack calls.

  • @nanangog
    @nanangog Před 4 lety

    Nice

  • @zetsui0411
    @zetsui0411 Před měsícem

    "hella confusing... [""un"" ""iq"",""ue""] especially with those void returns can you go into one simple case provided...we make all the calls down ? We make four calls to the function and get to the end of the array, it runs and then returns true back into third call 'ue' okay result is still blank, that returns TRUE to the previous recursive call, and then again for the second recursive call. What is being modified here other than result? I basically don't get the back propagation here, can you work out the first backpropagation case or two? why would you NOT take current ? Because it is NOT unique?"

  • @mohammeddaoud5018
    @mohammeddaoud5018 Před 2 lety

    We can use memorization to reduce time complexity as this problem has repeated sub problems.

  • @rjose705
    @rjose705 Před 4 lety +5

    Not Gonna Lie, I think DFS is gonna save my F-ing life LMAO

  • @SirTranquilizator
    @SirTranquilizator Před 4 lety +3

    Oh yeah! Classical DFS, I knew tennis was the answer for this problem.

  • @LeYo262728
    @LeYo262728 Před 3 lety

    Are this the interview question in all microsoft position?

    • @ojouniisama5401
      @ojouniisama5401 Před 3 lety +1

      Likely no this is just one of the most asked question for microsoft technical interviews at the time.

  • @bhaskarbhasku2921
    @bhaskarbhasku2921 Před 4 lety +1

    Pretty easy i believe if you understand recursion :) btw nice video

  • @sachinmavi1381
    @sachinmavi1381 Před 4 lety +5

    You have been lifting a lot in lockdown it seems xD

  • @sayantaniguha8519
    @sayantaniguha8519 Před rokem

    Had the constraint been *1

  • @shanigitelman8625
    @shanigitelman8625 Před 4 lety

    Hey Kevin! there is a special reason that you are preferred to solve the problems with Java and not with Python? I know both but not professional with none of them. I'm trying to understand which will be better for me. thanks!

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety

      If you have the choice and don't feel more comfortable with either one I def suggest python, I just use Java because I'm the most comfortable with it and used it the most but I think python is definitely better to interview with generally speaking

    • @shanigitelman8625
      @shanigitelman8625 Před 4 lety

      @@KevinNaughtonJr thanks for your quick response! can i ask you why do you think that?

    • @DanKaschel
      @DanKaschel Před 2 lety

      @@shanigitelman8625 it's a faster and more forgiving language

  • @liamkosar1148
    @liamkosar1148 Před 2 lety

    was anyone else able to do this with just two for loops?

  • @colorfulcodes
    @colorfulcodes Před 4 lety

    Do you work there?

  • @SoferPeOZN
    @SoferPeOZN Před 4 lety +1

    I think that there is a sexy dp aproach for this problem

  • @vk1618
    @vk1618 Před 4 lety

    One of the types of dfs #review

  • @jasongoulet-lipman7308

    You are not passing the interview with that time complexity!

    • @DanKaschel
      @DanKaschel Před 2 lety

      Space complexity is on point though

  • @akashgupta13
    @akashgupta13 Před 4 lety +2

    public int uniqueCharCount(String s) {
    int uniqueChars = (int) s.chars().distinct().count();
    return s.length() == uniqueChars ? uniqueChars : -1;
    }

  • @codeblooded6760
    @codeblooded6760 Před 3 lety

    LIS with unique chars condition

  • @abhirupdas7256
    @abhirupdas7256 Před 3 lety +1

    Hi Kevin, big fan of yours. Just a small mistake I would like to point out. counts【c-'a'】++ > 1 should be the check instead of >0 because we are trying to find duplicates here !

  • @josevalbuena9423
    @josevalbuena9423 Před 4 lety +1

    why int[] result instead of just int result ??

    • @alexhong794
      @alexhong794 Před 4 lety +1

      because result in dfs recursion should be deep copied. You can use int[] result OR use int result BUT put it out of function signature as global value.
      i.e.
      public class {
      int result = 0;
      public funcA() {
      }
      }

    • @mostinho7
      @mostinho7 Před 3 lety

      I still don’t get it :(

    • @mostinho7
      @mostinho7 Před 3 lety

      Alex Hong is this because int would just be passed by value and therefore not modified by the recursive calls? If that’s the case, would passing an Integer object instead of int achieve the same things?

  • @hacker-7214
    @hacker-7214 Před 4 lety

    could you do the bitmanipulation technique. it is better solution

  • @Shadercraft70
    @Shadercraft70 Před 4 lety +2

    Why recursion keep going when string already have duplicated characters,should returned i think

  • @BrettClimb
    @BrettClimb Před 3 lety

    Aren't invalid concatenations of strings being performed given your constraints? For example, "abc" + "cde" gives "abccde" which has a longer unique character count, but isn't valid. I don't see where you are filtering out these solutions.

  • @Eeezus1914
    @Eeezus1914 Před 4 lety

    Nice camera

  • @geethakrishnanbalasubraman7302

    n +iq + ue => nique is an unique string right? Why it is not considered

    • @usdaemon
      @usdaemon Před 3 lety +1

      It must be a whole word "un"...not a single character 'n' from the word '"un"

  • @swagatochatterjee7104
    @swagatochatterjee7104 Před 4 lety +2

    Since we are calling the function again and again, couldn't we have memoized?

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety +2

      definitely, memoizing would help limit the runtime to be bounded by the number of unique subproblems you'd just have to determine how you wanna represent your state (probably the index you're at and the string you currently have)

  • @sainikhilpalukuri1373
    @sainikhilpalukuri1373 Před 3 lety

    Can't we solve it by generating all the substrings. Which only takes o(n2) time complexity.

    • @gaureesha9840
      @gaureesha9840 Před 3 lety

      Generating all substrings is O(2^n) not "n2"

  • @arnoclaude317
    @arnoclaude317 Před 4 lety +11

    Damn u look swole Kevin 👍😂

  • @shivamshah431
    @shivamshah431 Před 2 lety

    Using an array of size 1 to avoid global variables is really smart.

    • @shashu1999
      @shashu1999 Před 2 lety

      Why should we avoid global variables?

    • @DanKaschel
      @DanKaschel Před 2 lety

      @@shashu1999 it's considered a code smell to use a global variable to store a state that only applies to a specific method invocation. Imagine if the method was called again; the global variable would still have the old length.

  • @colorfulcodes
    @colorfulcodes Před 4 lety

    You look good 👌🏾

  • @sxganapa1974
    @sxganapa1974 Před 4 lety

    Impresssed by your coding ease.

  • @abhinavpandey3356
    @abhinavpandey3356 Před 2 lety

    Can u tell a better optimised approach

  • @vrushankdoshi7813
    @vrushankdoshi7813 Před 4 lety

    Hey Kevin,
    Are you alright ? I see different background in your videos recently, I hope virus is not bothering you.

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety +5

      I’m safe don’t worry just had to get out of NYC with all the craziness going on thanks for asking hoping you’re safe too!

  • @siobhanahbois
    @siobhanahbois Před 4 lety

    Can you do a DFS version of this?

  • @mohitjain4943
    @mohitjain4943 Před 4 lety +1

    did not understand char [c-'a']++ thing

    • @deepakjain-dr7ds
      @deepakjain-dr7ds Před 4 lety +4

      It is to get array position of a given character while looping over the string. for example the ASCII value of 'a' is 65 and if you get character as 'a' , c-'a' = 0 will give position of a..thereby getting the count of unique characters.

    • @KevinNaughtonJr
      @KevinNaughtonJr  Před 4 lety +1

      deepak jain thanks for explaining :)

    • @mohitjain4943
      @mohitjain4943 Před 4 lety +1

      @@deepakjain-dr7ds thanks Mate!

  • @bodolawale5448
    @bodolawale5448 Před 3 lety +1

    I didn't understand anything. You were just writing the solution, maybe it's just me tho

  • @nadavlevanoni4240
    @nadavlevanoni4240 Před 2 lety

    This answer seems inefficient. You can optimize the string concatenation/comparison and cut down on complexity,

  • @SuhailKhan-mq8xn
    @SuhailKhan-mq8xn Před 5 měsíci

    Please use dark mode my eyes hurts

  • @asahikitase5398
    @asahikitase5398 Před 2 lety

    if you do this in the interview, I gurantee that you will fail.

  • @pro_gamerz9411
    @pro_gamerz9411 Před 2 lety

    your on mac microsoft is beating apple🤣

  • @arpitdixit9619
    @arpitdixit9619 Před 4 lety +2

    I love your content kevin, but you keeping the camera away from yourself to show off your shoulders and Biceps is not acceptable at all. Sincerely, Arpit.

  • @brayanvera3102
    @brayanvera3102 Před 2 lety +1

    This just made me hate java more than ever