leetcode

Programming/Algorithm

[Java-알고리즘] Two Sum

[Problem] Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. [Example1] Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. [Example2] Given nums = [3, 2, 4], target = 6, Because nums[1] + num..

Programming/Algorithm

[Java-알고리즘] toLowerCase Implemet

[Problem] Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. [Example1] Input: "Hello" Output: "hello" [Example2] Input: "here" Output: "here" [Example3] Input: "LOVELY" Output: "lovely" [Solution] import java.lang.StringBuilder; class Solution { public String toLowerCase(String str) { char[] characters = str.toCharArray(); int strLen = st..

Programming/Algorithm

[Java-알고리즘] Split a String in Balanced Strings

[Problem] Balanced strings are those who have equal quantity of 'L' and 'R' characters. Given a balanced string s split it in the maximum amount of balanced strings. Return the maximum amount of splitted balanced strings. [Example1] Input: s = "RLRRLLRLRL" Output: 4 Explanation: s can be split into "RL", "RRLL", "RL", "RL", each substring contains same number of 'L' and 'R'. [Example2] Input: s ..

Programming/Algorithm

[Java-알고리즘] Jewels and Stones

[Problem] You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels. The letters in J are guaranteed distinct, and all characters in J and S are letters. Letters are case sensitive, so "a" is considered a different type of stone ..

Programming/Algorithm

[Java-알고리즘] IP 주소 분리

요즘 https://leetcode.com 에서 알고리즘 문제를 풀고 있다. 수행속도 및 메모리 사용량까지 모두 측정해줘서 좋았고, 문제를 푼 사람들 중에 내가 푼 방법의 효율성을 알려주는 부분도 좋았다. 앞으로는 계속 leet code 문제를 올릴 것 같다. [Problem] Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]". [Example1] Input: address = "1.1.1.1" Output: "1[.]1[.]1[.]1" [Example2] Input: address = "255.100.50.0..

JohnMark
'leetcode' 태그의 글 목록