Google Adsense Home에 들어가니
다음과 같은 화면이 나를 반겼다.
바로 업데이트 버튼을 눌렀다.
Google Adsense 가입 시
결제 수단을 설정하지 않았기 때문에 설정을 해준다.
Given a 32-bit signed integer, reverse digits of an integer.
Note:
Assume we are dealing with an environment that could only store integers within the 32-bit signed integer range: [−231, 231 − 1].
For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
Input: x = 123
Output: 321
public int reverse(int x) {
if (x == 0) {
return 0;
}
while (true) {
if (x % 10 == 0) {
x /= 10;
} else {
break;
}
}
StringBuilder answer = new StringBuilder();
if (x < 0) {
answer.append("-");
x *= -1;
}
while (x != 0) {
answer.append(x % 10);
x /= 10;
}
int ans;
try {
ans = Integer.parseInt(answer.toString());
} catch (Exception e){
return 0;
}
return ans;
}
Case 1
class Solution {
public int reverse(int x) {
long num = 0;
while (x != 0) {
num = num * 10 + x % 10;
x = x / 10;
}
if (num != (int) num) {
return 0;
}
return (int) num;
}
}
Hibernate가 DB에 날리는 모든 Query를 보여준다.
해당 옵션과 관련해서는 반드시 알아야 할 부분이 있다.
그 부분에 대해서는 Spring Boot SQL Option : ‘show_sql’ Option Deep 하게 알아보기 글을 참고하자.
application.yml
spring:
jpa:
properties:
hibernate:
show_sql: true
application.properties
spring.jpa.properties.hibernate.show_sql = true
Output
Hibernate: select testentity0_.id as id1_8_0_ from test_entity testentity0_ where testentity0_.id=?
Hibernate: insert into test_entity (id) values (?)
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.
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
return new int[] { map.get(complement), i };
}
map.put(nums[i], i);
}
throw new IllegalArgumentException("No two sum solution");
}
정말 오랜만에 Algorithm을 푸려니까 머리가 돌아가지 않는다.
꾸준히 풀어줘야겠다.
이 글의 코드 및 정보들은 강의를 들으며 정리한 내용을 토대로 작성하였습니다.
개발을 하다 보면
다음과 같은 Column들이 필요하다.
언제 생성되었는가?
언제 수정되었는가?
누가 생성하였는가?
누가 수정하였는가?
위와 같은 Needs를 Spring에서는 추상화시켜놓았다.
이 글에서는 2가지 방식으로 해당 기능 사용법을 알아본다.
순수 JPA를 사용하는 방식
Spring Data JPA를 사용하는 방식