Dynamic Programming Here are some classic Dynamic Programming interview questions. We recommend: Climbing Stairs, Best Time to Buy and Sell Stock and Maximum Subarray. 70. Climbing Stairs leetcode.com/problems/climbing-stairs/solution/ 3번으로 풀었다. 4번부터 쬐끔 당황쓰. Summary You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many disti..
Sorting and Searching These problems deal with sorting or searching in a sorted structure. We recommend First Bad Version as a great introduction to a very important algorithm. 88. Merge Sorted Array leetcode.com/problems/merge-sorted-array/ Solution Approach 1 : Merge and sort Intuition The naive approach would be to merge both lists into one and then to sort. It's a one line solution (2 lines ..
Trees Tree is slightly more complex than linked list, because the latter(후자) is a linear data structure while the former is not. Tree problems can be solved either breadth-first or depth-first. We have one problem here which is great for practicing breadth-first traversal. We recommend: Maximum Depth of Binary Tree, Validate Binary Search Tree, Binary Tree Level Order Traversal and Convert Sorte..
Strings String type of questions were asked in interviews frequently. You will most likely encounter one during your interviews. We recommend: Reverse String, First Unique Character in a String, String to Integer (atoi) Implement strStr(). 총 8문제. 344. Reverse String 투포인터는 이렇게 쓰는 것이다. 이런 느낌의 문제. leetcode.com/problems/reverse-string/solution/ Easy Write a function that reverses a string. The input..
Array Array type of questions were asked in interviews frequently. You will most likely encounter one during your interviews. We recommend: Single Number, Rotate Array, Intersection of Two Arrays II and Two Sum 26. Remove Duplicates from Sorted Array leetcode.com/problems/remove-duplicates-from-sorted-array/ Given a sorted array nums, remove the duplicates in-place such that each element appear ..
Conclusion We hope you're now feeling confident with the basics of Arrays! Because practice makes perfect, here are a few more practice problems for you! What's Next? Let's recap what we looked at in this explore card: We explored what the Array data structure is all about. We looked at the Java syntax for creating Arrays. We looked at the Java syntax for reading and writing from Arrays. We desi..
In-Place Operations Now that we've got all the basic Array operations out of the way, we're going to have a look at in-place Array operations. These are very important from an interviewing standpoint. In-place Array operations are where we modify an Array, without creating a new Array. We've already seen some examples of this: inserting and removing items by shifting existing items along. There ..
Inserting Items Into an Array In the previous chapter, we looked at what Arrays are, and the basic programming constructs of Arrays in Java. We're now going to use these basic constructs to implement three key operations for Arrays: Inserting items. Removing items. Searching for items. These three operations are the fundamental operations for all data structures. In this chapter, we'll be starti..
Introduction to Data Structure Overview Introduction Arrays are a simple data structure for storing lots of similar items. They exist in all programming languages, and are used as the basis for most other data structures. On their own, Arrays can be used to solve many interesting problems. Arrays come up very often in interview problems, and so being a guru with them is a must! In this Explore C..
leetcode.com/problems/maximum-depth-of-binary-tree/ 보통 마지막 솔루션이 더 옵티멀한거여서 봤는데, 특별한것이 없었다; Approach 1: Recursion Intuition By definition, the maximum depth of a binary tree is the maximum number of steps to reach a leaf node from the root node. From the definition, an intuitive idea would be to traverse the tree and record the maximum depth during the traversal. Algorithm 1 / 10 One could travers..
leetcode.com/problems/shortest-word-distance/ n^2으로 풀면 안된다. class Solution { public int shortestDistance(String[] words, String word1, String word2) { int i1 = -1, i2 = -1; int minDistance = words.length; for (int i = 0; i < words.length; i++) { if (words[i].equals(word1)) { i1 = i; } else if (words[i].equals(word2)) { i2 = i; } if (i1 != -1 && i2 != -1) { minDistance = Math.min(minDistance, Mat..
leetcode.com/problems/the-kth-factor-of-n/ The kth Factor of n - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 금요일이라고 쉬운문제인건가 싶었지만, 그렇지 않았음 In this article, we consider three solutions. Approach 1: Brute Force, \mathcal{O}(N)O(N). One could iterate from 11 to NN, figure out all d..
leetcode.com/contest/weekly-contest-215 Contest - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1656. Design an Ordered Stream class OrderedStream { String[] streamList; int ptr; public OrderedStream(int n) { streamList = new String[n]; ptr = 0; } public List insert(int id, Strin..
leetcode.com/problems/min-cost-climbing-stairs/ Min Cost Climbing Stairs - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { public int minCostClimbingStairs(int[] cost) { int f1 = 0, f2 = 0; for(int i = cost.length - 1; i >= 0; --i) { int f0 = cost[i] + Math.min(f1,..
leetcode.com/problems/increasing-order-search-tree/ Increasing Order Search Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Approach 1: In-Order Traversal class Solution { public TreeNode increasingBST(TreeNode root) { List vals = new ArrayList(); inorder(root, vals); TreeNo..
leetcode.com/problems/random-pick-index/ Random Pick Index - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array...
www.geeksforgeeks.org/reservoir-sampling/ Reservoir Sampling - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.geeksforgeeks.org leetcode.com/problems/linked-list-random-node/ Linked List Random Node - LeetCode Level..
leetcode.com/contest/weekly-contest-217 Contest - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com leetcode.com/problems/richest-customer-wealth/ Richest Customer Wealth - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge an..
Design a queue that supports push and pop operations in the front, middle, and back. Implement the FrontMiddleBack class: FrontMiddleBack() Initializes the queue. void pushFront(int val) Adds val to the front of the queue. void pushMiddle(int val) Adds val to the middle of the queue. void pushBack(int val) Adds val to the back of the queue. int popFront() Removes the front element of the queue a..
leetcode.com/contest/biweekly-contest-40 Contest - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 4개는 언제 풀수있을까...ㅜ
나는 최근에 이상한 일을 하고 있다. 예전의 나와 경쟁... 오늘은 2019년 2월 10일 나와의 경쟁. leetcode.com/contest/weekly-contest-123 Contest - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { public List addToArrayForm(int[] A, int K) { int n = A.length; int c = K; for(int i = A.length-1;i >= 0;i--)..
leetcode.com/contest/weekly-contest-191 Contest - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 실력이 좀 늘었나? 하고 생각했지만, 3문제가 워낙 쉬웠던것 같다. leetcode.com/contest/weekly-contest-191/ranking/161/ Contest - LeetCode Level up your coding skills and quickly land a job. This is the best place..
leetcode.com/contest/weekly-contest-122/ Contest - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 드디어 3문제 풀었다. 근데이번에 좀 쉬운편인듯 leetcode.com/contest/weekly-contest-122/problems/vertical-order-traversal-of-a-binary-tree/
leetcode.com/problems/range-sum-of-bst/ Range Sum of BST - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com youtu.be/3XmV2XzJrw0 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { thi..
class Solution { public int minimumDeletions(String s) { int n = s.length(); int[] aCnt = new int[n+1]; for(int i = n-1; i >= 0; i--) { aCnt[i] = aCnt[i+1]; if(s.charAt(i) == 'a') aCnt[i]++; } int delection = aCnt[0]; int bCnt = 0; for(int i = 0; i < n; i++) { if(s.charAt(i) == 'b') bCnt++; delection = Math.min(delection, bCnt + aCnt[i+1]); } return delection; } } 스택을 이용하는 다른 방법도 있음.
1번과 2번을 푸는데, 고수는 5분/5분 중수는 10분/10분 정도 걸린듯함. leetcode.com/problems/check-array-formation-through-concatenation/ Check Array Formation Through Concatenation - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Approach 1: One by One 코드가 예쁜편 class Solution { public boolean canFormArray(i..
구글꺼에 HARD 가 많아보이는건 내 착각인가...
en.wikipedia.org/wiki/Practice_(learning_method)#Deliberate_practice Practice (learning method) - Wikipedia From Wikipedia, the free encyclopedia Jump to navigation Jump to search The act of rehearsing a behavior repeatedly; sessions scheduled for the purpose of rehearsing and performance improvement Practice is the act of rehearsing a behaviour over and over, o en.wikipedia.org tackleberrysolut..