Unity

Unity C# 숫자 3자리마다 콤마 삽입 및 삭제하기

계기 Block Puzzle Game 게임 제작 도중 스코어 세자리마다 콤마를 추가해달라는 요청이 생겨 알아보게 되었다. 보기에는 숫자로 보이지만 실상 Text Component로 이루어서 있어 string으로 되어있는데, 사용하면서 tostring이나 int.parse를 사용했었는데 콤마를 어떻게 넣을지 어려웠었다. 방법 의외로 방법은 간단했는데, int 혹은 string 형식에 콤마를 넣을때는 int score = 36500; Debug.Log(String.Format("{0:#,0}", score)); // "36,500" 위와 같이 사용하고 현재 score와 save된 score를 비교해야 할때 int로 변환하면서 콤마를 삭제하는 로직이 필요하다. string score = "36,500"; //..

TIL

[leetcode] 148. Sort List

Sort List Given the head of a linked list, return the list after sorting it in ascending order. Example 1: Input: head = [4,2,1,3] Output: [1,2,3,4] Example 2: Input: head = [-1,5,3,4,0] Output: [-1,0,3,4,5] Example 3: Input: head = [] Output: [] Constraints: The number of nodes in the list is in the range [0, 5 * 104]. -105 head.next!.val) { [head.val, head.next!.val] = [head.next!.val, head.va..

TIL

[Hash Table 구현] Linear Probing 방식의 Hash Table을 구현해 보세요.

Linear Probing 방식의 Hash Table hash table은 JavaScript에서 { "key" : { "innerKey" : "value" } } 와 같이 사용하는것을 지칭하는것으로 알고 있었는데, linear probing방식으로 구현해보는 과제가 주어져 일단 linear probing이 무엇인지부터 알아보아야겠다. Linear Probing ? 위키디피아에 따르면 linear probing이란, 해시 테이블 의 충돌을 해결하기 위한 컴퓨터 프로그래밍 방식 , 키-값 쌍 의 컬렉션을 유지 관리 하고 주어진 키와 관련된 값을 찾기 위한 데이터 구조 라고한다. 세션을 듣던 중 해싱된 키값이 중복될경우 다음 해싱된 키값으로 저장하는 로직으로 설명을 들었던것을 참고하여 구현하면 될것으로 보인..

TIL

[leetcode] 219. Contains Duplicate II

Contains Duplicate II Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j)

TIL

[leetcode] 1. Two Sum

Two Sum Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0..

TIL

[leetcode] 150. Evaluate Reverse Polish Notation

Evaluate Reverse Polish Notation You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation. Evaluate the expression. Return an integer that represents the value of the expression. Note that: The valid operators are '+', '-', '*', and '/'. Each operand may be an integer or another expression. The division between two integers always truncates t..

TIL

[leetcode] 155. Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: MinStack() initializes the stack object. void push(int val) pushes the element val onto the stack. void pop() removes the element on the top of the stack. int top() gets the top element of the stack. int getMin() retrieves the minimum element in the stack. You must impl..

TIL

[leetcode] 167. Two Sum II - Input Array Is Sorted

Two Sum II - Input Array Is Sorted Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1

TIL

[leetcode] 125. Valid Palindrome

Valid Palindrome A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise. Example 1: Input: s = "A man, a plan, a canal: Panama" Output: true Explanatio..

JangKroed
JangKroed