본문 바로가기

반응형

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

(75)
1768. Merge Strings Alternately (JS) hi. I've solved a problem related to strings.It was simple, so I solved it right away. I'm so happy! Anyway, I'm going to explain this problem.There are two strings, and you need to combine them character by character, not string by string.However, some strings have different lengths.So, regardless of whether their lengths match or not, you should merge them one character at a time. Here’s my so..
1071. Greatest Common Divisor of Strings (JS) hi. I have another question about a LeetCode problem.First, please check what the problem is.It's quite a simple one, but it was hard to implement in code.I'm not an AI, so it's really difficult to explain in a programming language.I tried using the substr and includes methods,but they didn't work properly.They couldn't cover all the cases.So... I googled the answer and re-realized the power of ..
151. Reverse Words in a String (Javascript) Hi!I solved a LeetCode problem about strings.It's categorized as a medium problem, but I found it not too difficult.I tried solving it, and I succeeded!Anyway, let me explain the problem description.Remove leading and trailing spaces.If there are multiple spaces between words, reduce them to a single space.The goal is not to reverse the string character by character, but to reverse it word by wo..
How to solve the conflict in the office? Two days ago, I had a small conflict with my coworker.It happened because we had different goals for using Redux.In my opinion, we should use Redux only for managing state.For example, let's say there's a parent-child relationship, but the child also has its own child, and so on. At the last child level, some data is updated.That data should also be updated in the parent page automatically throu..
643. Maximum Average Subarray I with JS Hi! Long time no see.I've been so busy looking for a job, working, studying English, and learning new tech stacks... T_TBut algorithms are one of the most important things when preparing for a job, so I'm back! Hahaha.Anyway, today I solved a problem about arrays. First, this is my own code. It was too long and unfortunately, it caused a time limit exceeded (TLE) error... 😭Why did I write my co..
leetcode 575. Distribute Candies (javascript) Hi! Happy New Year to you too! I'm in Korea for a while to celebrate the Korean New Year with my family.Even though I'm on holiday, I'm still studying algorithms to improve my logical thinking. Anyway, this is what I'd solved. Summary of My Solution:This problem involves using arrays and the Set data structure to determine the maximum number of unique types.Here's my approach:Initially, I solved..
500. Keyboard Row (javascript) Hi, today I worked on a problem that seems to be related to Hash Maps.To summarize:there are three layers, so I tried using a Map like ["a", "1"], ["b", "2"].However, it didn’t work properly.To solve the problem in my own way, I used a String and compared values directly.Yeah... the code ended up being really long, and the efficiency isn’t great.But I think solving the problem is more important ..
for making new Map in JS hi.today, I learned a new way for initialize the Map. origin way is too long. like  this : for(let i = 0; i     if(a.has(x[i]){          a.set(x[i], a.get(x[i]) + 1)} else { a.set(x[i],1)} for counting the all of the elements in some array, I usually use map and counting them.but today, I found out shorten that code. like this : for(let i = 0; i       a.set(x[i], a.get(x[i] || 0) + 1)} it will b..

반응형