분류 전체보기351 [leetcode 5] Longest Palindromic Substring Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Example 3: Input: s = "a" Output: "a" Example 4: Input: s = "ac" Output: "a" Constraints: 1 2020. 10. 13. [leetcode 3] Longest Substring Without Repeating Characters Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" Output: 3 Explanation: The answer is "wke", with the length of 3. Notice that the ans.. 2020. 10. 13. [leetcode 2] Add Two Numbers You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. Example 1: Input: l1 = [2,4,3], l2 = [5,6,4] Output: [7,0,8] Explanation: 342 +.. 2020. 10. 13. [leetcode 283] Move Zeroes Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. Example: Input: [0,1,0,3,12] Output: [1,3,12,0,0] 문제: 0을 전부 뒤로 미루는 문제 풀이 : 0이 아닌 숫자를 앞에서 부터 채우고 나머지 배열에 0을 채운다. class Solution { public: void moveZeroes(vector& nums) { int last = 0; //0이 아닌 숫자를 앞으로 밀어넣기 for(int i=0; i 2020. 10. 12. 이전 1 ··· 71 72 73 74 75 76 77 ··· 88 다음