분류 전체보기

    [LeetCode] 6. Zigzag Conversion

    6. Zigzag Conversion Medium The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string convert(string s, int numRows..

    AJAX로 3초마다 JSON파일 데이터 읽어 html 웹 페이지에 업데이트하는 방법

    웹페이지를 만들고 새로운 데이터를 아무런 변화없이 업데이트하기 위한 방법이다. 비동기적으로 html 구성요소를 바꾸거나 업데이트하는 등의 동작을 할 수 있다. AJAX를 이용하여 웹페이지의 새로고침 없이 데이터를 업데이트 할 수 있다. 설정해놓은 시간대로 함수를 호출하여 자바스크립트를 실행할 수 있는 함수는 setInterval() 함수이다. // 1000 msec 마이크로세컨드, 1초마다 setInterval 안의 함수를 자동 호출할 수 있다. setInterval(function () {element.innerHTML += "Hello"}, 1000); Ajax 를 사용하여 로컬의 json 파일을 불러오려고 한다. url 에는 파일이 위치하고 있는곳을 적어준다. 원하는 파일 혹은 주소가 제대로 로딩되..

    [LeetCode] 1299. Replace Elements with Greatest Element on Right Side

    1299. Replace Elements with Greatest Element on Right Side Easy Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing so, return the array. Example 1: Input: arr = [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Explanation: - index 0 --> the greatest element to the right of index 0 is index 1 ..

    [LeetCode] 13. Roman to Integer

    13. Roman to Integer Easy Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman numerals are usually written largest to smallest f..

    [LeetCode] 504. Base 7

    504. Base 7 Easy Given an integer num, return a string of its base 7 representation. Example 1: Input: num = 100 Output: "202" Example 2: Input: num = -7 Output: "-10" Constraints: -107

    [LeetCode] 326. Power of Three

    326. Power of Three Easy Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3x. Example 1: Input: n = 27 Output: true Explanation: 27 = 33 Example 2: Input: n = 0 Output: false Explanation: There is no x where 3x = 0. Example 3: Input: n = -1 Output: false Explanation: There is no x whe..

    [LeetCode] 242. Valid Anagram

    242. Valid Anagram Easy Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: false Constraints: 1 bool: # ha..

    [LeetCode] 20. Valid Parentheses

    20. Valid Parentheses Easy Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true ..