[Link] https://leetcode.com/problems/two-sum/ class Solution { public int[] twoSum(int[] nums, int target) { HashMap<Integer, Integer> hm = new HashMap<>(); for(i...
LeetCode. 94.Binary Tree Inorder Traversal
[Link] https://leetcode.com/problems/binary-tree-inorder-traversal/ Using Recursive call(Top - Bottom) /** * Definition for a binary tree node. * public class TreeNode { * int val; * ...
LeetCode. 540. Single Element in a Sorted Array
[Link] https://leetcode.com/problems/single-element-in-a-sorted-array/ class Solution { public int singleNonDuplicate(int[] nums) { int start = 0, end = nums.length - 1, mid; ...
LeetCode. 94.Binary Tree Inorder Traversal
[Link] https://leetcode.com/problems/hamming-distance/ class Solution { public int hammingDistance(int x, int y) { int bitX, bitY, cnt = 0; if(x < y) { int t...
BOJ. Sums of subsets (11659)
[Link] https://www.acmicpc.net/problem/11659 I solved this with segment tree since I wanted to pratice it. It’s actually faster just using sum[i]: sum of arr[0] ~ arr[i] import java.util.*; impo...
LeetCode. 53. Maximum Subarray
[Link] https://leetcode.com/problems/maximum-subarray/ import java.util.Arrays; import java.util.LinkedList; import java.util.List; class Solution { public List<List<Integer>> ...
LeetCode. 13. Roman to Integer
[Link] https://leetcode.com/problems/roman-to-integer/ import java.util.HashMap; class Solution { public HashMap<Character, Integer> hm = new HashMap<>(); public int romanT...
LeetCode. 83. Remove Duplicates from Sorted List
[Link] https://leetcode.com/problems/remove-duplicates-from-sorted-list/ /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListN...
AtCoder. 019 Pick Two(6)
[Link] https://AtCoder.jp/contests/typical90/tasks/typical90_s import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Buffer...
LeetCode. 14. Longest Common Prefix
[Link] https://leetcode.com/problems/longest-common-prefix/ import java.util.Arrays; import java.util.LinkedList; import java.util.List; class Solution { public String longestCommonPrefix(...