본문 바로가기

열정가득한 개발자의 이야기/Javascript Algorithm

(4)
1207. Unique Number of Occurrences (Javascript) Hi... I have another array problem.The level is easy, but it is hard for me.However, I won't give up; I'll do my best. Anyway, to summarize this problem, I just need to check the unique count.So, I used the Map object and Set. Here is my answer. First, I convert the array to a Map, where the Map is [key, value], so I add the count as the value.Then, I initialize the Set because a Set can check f..
3005. Count Elements With Maximum Frequency (javascript) Summarize : just counting the Maximun Frequency so I use a Map to keep track of the countsi store the elements in an Array as keys, and their counts as values.Here is my code, and it feels too long, so I'm not satisfied with it.so i ask to Gpt for refactoring.and here is the answer. the code by gpt looks better than mine...and I learned something new, such as the nullish coalescing operator.It r..
392. Is Subsequence (Javascript) Hi, I solved the Leetcode problem 392.It's about comparing two strings.s should be a subsequence of t, and we have to consider the order,but the characters in s can appear separately within t.To summarize, it's just about checking if s is a subsequence.Please read the description. Why is the first example 'true'?It's because s is a subsequence of t,even if the characters are not contiguous.Howev..
58. Length of Last Word (Javascript) Hi. it's been a while.These days, I've started studying JS again.I solved a JS algorithm problem.This problem is part of the Top 150 Interview Questions,so I have to solve it. anyway, I think it is about Array problem.I first converted the String to an array and then used a for loop and an if statement. We need to save time, so I count backwards like this.   so my submission is~~!!   I'm not sur..