본문 바로가기

Problem Solving1484

[LeetCode] 67. Add Binary - Java • 문제 링크 Add Binary - LeetCodeCan you solve this real interview question? Add Binary - Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: *leetcode.com • 풀이 코드public class Solution { public String addBinary(String a, String b) { StringBuilder sb.. 2026. 5. 21.
[LeetCode] 66. Plus One - Java • 문제 링크 Plus One - LeetCodeCan you solve this real interview question? Plus One - You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-leetcode.com • 풀이 코드public class Solution { public int[] plusOne(int[] digits) { for (int i = digits.leng.. 2026. 5. 20.
[LeetCode] 58. Length of Last Word - Java • 문제 링크 Length of Last Word - LeetCodeCan you solve this real interview question? Length of Last Word - Given a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only. Example 1: Input:leetcode.com • 풀이 코드public class Solution { public int lengthOfLastWord(String s) { int i = s.l.. 2026. 5. 19.
[LeetCode] 35. Search Insert Position - Java • 문제 링크 Search Insert Position - LeetCodeCan you solve this real interview question? Search Insert Position - Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must wleetcode.com • 풀이 코드public class Solution { public int searchInsert(int[] nums, int target) { .. 2026. 5. 18.
[LeetCode] 24. Swap Nodes in Pairs - Java • 문제 링크 Swap Nodes in Pairs - LeetCodeCan you solve this real interview question? Swap Nodes in Pairs - Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be chanleetcode.com • 풀이 코드public class Solution { public ListNode swapPairs(ListNode head) { ListNode .. 2026. 5. 17.
[LeetCode] 28. Find the Index of the First Occurrence in a String - Java • 문제 링크 Find the Index of the First Occurrence in a String - LeetCodeCan you solve this real interview question? Find the Index of the First Occurrence in a String - Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Ileetcode.com • 풀이 코드public class Solution { public int strStr(String ha.. 2026. 5. 16.