Skip to content

Latest commit

Β 

History

History
609 lines (609 loc) Β· 86.8 KB

README.md

File metadata and controls

609 lines (609 loc) Β· 86.8 KB

Easy LeetCode-Java-Solutions

S.no Coding Problem
1 Count Binary Substrings
2 Check if All A's Appears Before All B's
3 Longest Harmonious Subsequence
4 Missing Ranges
5 High Five
6 Binary Tree Tilt
7 Number of Boomerangs
8 Count the Number of Consistent Strings
9 Sentence Similarity
10 Strong Password Checker II
11 Perform String Shifts
12 Kth Largest Element in a Stream
13 Kth Missing Positive Number
14 Check If String Is a Prefix of Array
15 Capitalize the Title
16 The K Weakest Rows in a Matrix
17 Missing Number
18 Remove Duplicates from Sorted Array
19 Implement strStr
20 Reverse String
21 Create Target Array in the Given Order
22 Increasing Order Search Tree
23 Minimum Number of Moves to Seat Everyone
24 Minimum Absolute Difference
25 Maximum 69 Number
26 Largest Perimeter Triangle
27 Minimum Cost of Buying Candies With Discount
28 Number of Equivalent Domino Pairs
29 Summary Ranges
30 Binary Number with Alternating Bits
31 Find the Distinct Difference Array
32 Buy Two Chocolates
33 Intersection of Multiple Arrays
34 Palindrome Linked List
35 Rectangle Overlap
36 Intersection of Three Sorted Arrays
37 Minimum Changes To Make Alternating Binary String
38 Jewels and Stones
39 Number of Valid Words in a Sentence
40 Greatest English Letter in Upper and Lower Case
41 Unique Email Addresses
42 X of a Kind in a Deck of Cards
43 Longest Nice Substring
44 Count Primes
45 Positions of Large Groups
46 Maximum Population Year
47 Min Cost Climbing Stairs
48 Number of Days Between Two Dates
49 Minimum Distance to the Target Element
50 Path Crossing
51 Check If N and Its Double Exist
52 Word Pattern
53 Maximum Nesting Depth of the Parentheses
54 Two Sum IV - Input is a BST
55 Find Positive Integer Solution for a Given Equation
56 Hamming Distance
57 Defuse the Bomb
58 Check if The Number is Fascinating
59 Minimum Common Value
60 Final Prices With a Special Discount in a Shop
61 Plus One
62 Submission Detail
63 Rotate String
64 Minimum Depth of a Binary Tree
65 Power of Four
66 Valid Perfect Square
67 Find N Unique Integers Sum up to Zero
68 Remove Trailing Zeros From a String
69 Paint Fence
70 Detect Capital
71 XOR Operation in an Array
72 Divide a String Into Groups of Size k
73 Flipping an Image
74 Subtract the Product and Sum of Digits of an Integer
75 Two Sum III - Data Structure Design
76 Check if Binary String Has at Most One Segment of Ones
77 Number Complement
78 Longer Contiguous Segments of Ones than Zeros
79 Design HashSet
80 Convert 1D Array Into 2D Array
81 Odd String Difference
82 Remove Digit From Number to Maximize Result
83 Find Mode in Binary Search Tree
84 Count Hills and Valleys in an Array
85 Maximum Repeating Substring
86 Number of Unequal Triplets in Array
87 Split Strings by Separator
88 Find Closest Number to Zero
89 1-bit and 2-bit Characters
90 Binary Gap
91 Subtree of Another Tree
92 Binary Tree Level Order Traversal II
93 Count Prefixes of a Given String
94 Find the Width of Columns of a Grid
95 Defanging an IP Address
96 Find Target Indices After Sorting Array
97 Truncate Sentence
98 Diameter of Binary Tree
99 Best Poker Hand
100 Range Sum of BST
101 Maximum Average Subarray I
102 Fizz Buzz
103 Check if All the Integers in a Range Are Covered
104 Find First Palindromic String in the Array
105 Duplicate Zeros
106 Minimum Subsequence in Non-Increasing Order
107 Smallest Range I
108 Employee Importance
109 Minimum_index_sum_of_two_lists
110 Points That Intersect With Cars
111 Number of segments in a String
112 Delete Columns to Make Sorted
113 Reverse Only Letters
114 Evaluate Boolean Binary Tree
115 Repeated String Match
116 Neither Minimum nor Maximum
117 Maximum Value of an Ordered Triplet I
118 Uncommon Words from Two Sentences
119 Assign Cookies
120 Most Frequent Number Following Key In an Array
121 Element Appearing More Than 25% In Sorted Array
122 Find the Town Judge
123 Buddy Strings
124 Teoplitz Matrix
125 Leaf-Similar Trees
126 Minimum Hours of Training to Win a Competition
127 Goat Latin
128 Flower Planting With No Adjacent
129 Largest Triangle Area
130 Row With Maximum Ones
131 Determine Color of a Chessboard Square
132 Richest Customer Wealth
133 Consecutive Characters
134 Latest Time by Replacing Hidden Digits
135 Robot Return to Origin
136 Determine Whether Matrix Can Be Obtained By Rotation
137 Flip Game
138 Minimum Value to Get Positive Step by Step Sum
139 Average Value of Even Numbers That Are Divisible by Three
140 Reshape the matrix
141 Valid Anagram
142 Number of Strings That Appear as Substrings in Word
143 DI String Match
144 Running Sum of 1d Array
145 Special Array With X Elements Greater Than or Equal X
146 Number of Distinct Averages
147 Check if an Array Is Consecutive
148 Backspace String Compare
149 Rings and Rods
150 Implement Stack using Queues
151 Baseball Game
152 Pairs of Songs With Total Durations Divisible by 60
153 Destination City
154 Maximum Product of Three Numbers
155 Three Consecutive Odds
156 Set Mismatch
157 Sort Array by Increasing Frequency
158 Find the Distance Value Between Two Arrays
159 Find Anagram Mappings
160 Check if Array is Good
161 Decompress Run-Length Encoded List
162 Flood Fill
163 Magic Squares In Grid
164 Smallest Even Multiple
165 Hexspeak
166 Diet Plan Performance
167 Maximum Number of Balloons
168 Find Smallest Letter Greater Than Target
169 Check if Array Is Sorted and Rotated
170 Maximum Enemy Forts That Can Be Captured
171 Path Sum
172 Day of the Year
173 Number of Beautiful Pairs
174 Can Make Arithmetic Progression From Sequence
175 Furthest Point From Origin
176 Find the Highest Altitude
177 Root Equals Sum of Children
178 Powerful Integers
179 Merge Two Sorted Lists
180 Binary Search
181 K-diff Pairs in an Array
182 Repeated Substring Pattern
183 Calculate Digit Sum of a String
184 Reformat Phone Number
185 Longest Continuous Increasing Subsequence
186 Shuffle the Array
187 Count Pairs Of Similar Strings
188 Ransom Note
189 trailing_zeroes
190 Height Checker
191 License Key Formatting
192 Sum of Values at Indices With K Set Bits
193 Balanced Binary Tree
194 Check If It Is a Straight Line
195 Binary Watch
196 Count Special Quadruplets
197 Three Divisors
198 Make Array Zero by Subtracting Equal Amounts
199 Maximum Number of Words You Can Type
200 Contains Duplicate
201 Decode the Message
202 String Matching in an Array
203 Count the Digits That Divide a Number
204 Distance Between Bus Stops
205 Ugly Number
206 Faulty Keyboard
207 Find the Pivot Integer
208 Pascal's Triangle II
209 Maximum Count of Positive Integer and Negative Integer
210 Count Symmetric Integers
211 Pascal's Triangle
212 Binary Prefix Divisible By 5
213 Number Of Rectangles That Can Form The Largest Square
214 Separate the Digits in an Array
215 Count Negative Numbers in a Sorted Matrix
216 Remove One Element to Make the Array Strictly Increasing
217 Two Furthest Houses With Different Colors
218 Special Positions in a Binary Matrix
219 Check if All Characters Have Equal Number of Occurrences
220 Valid Word Sequence
221 Counting Words With a Given Prefix
222 Binary Tree Inorder Traversal
223 Minimum Moves to Convert String
224 Design Linked List
225 Kth Distinct String in an Array
226 Count Good Triplets
227 Design an Ordered System
228 Get Maximum in Generated Array
229 Convert the Temperature
230 Arranging Coins
231 Count Pairs Whose Sum is Less than Target
232 Check if Word Equals Summation of Two Words
233 Fair Candy Swap
234 Design Parking System
235 Transpose Matrix
236 Delete Greatest Value in Each Row
237 Excel Sheet Column Title
238 First Letter to Appear Twice
239 Linked List Cycle
240 Find All the Lonely Nodes
241 Find the Maximum Achievable Number
242 Base 7
243 Reverse Bits
244 SqrtX
245 Check if Strings Can be Made Equal With Operations I
246 Similar RGB Color
247 Sort the People
248 Is Subsequence
249 Longest Even Odd Subarray With Threshold
250 Reverse Linked List
251 Shortest Distance to a Character
252 Count of Matches in Tournament
253 Valid Parentheses
254 Convert Sorted Array To Binary Search Tree
255 Count Vowel Substrings of a String
256 Construct the rectangle
257 Maximum Units on a Truck
258 Sum of Left Leaves
259 Decrypt String from Alphabet to Integer Mapping
260 Number of Employees Who Met the Target
261 Find Pivot Index
262 Factorial Trailing Zeroes
263 Build an Array With Stack Operations
264 Last Stone Weight
265 range_addition_II
266 Isomorphic Strings
267 Longest Subsequence With Limited Sum
268 Split a String in Balanced Strings
269 To Lower Case
270 Sum of Digits of String After Convert
271 Number of Senior Citizens
272 Minimum Cost to Move Chips to The Same Position
273 Read N characters Given Read4
274 Longest Alternating Subarray
275 Delete N Nodes After M Nodes of a Linked List
276 Count Items Matching a Rule
277 Reverse Vowels of a String
278 Largest Local Values in a Matrix
279 A Number After a Double Reversal
280 Roman to Integer
281 Cousins in Binary Tree
282 Binary Tree Paths
283 Complement of Base 10 Integer
284 Find if Path Exists in Graph
285 Minimum Difference Between Highest and Lowest of K Scores
286 Number of Days in a Month
287 Find Resultant Array After Removing Anagrams
288 Minimum String Length After Removing Substrings
289 Palindrome Number
290 Find Subarrays With Equal Sum
291 Account Balance After Rounded Purchase
292 Minimum Amount of Time to Fill Cups
293 Detect Pattern of Length M Repeated K or More Times
294 Largest Positive Integer That Exists With Its Negative
295 Univalued Binary Tree
296 Single-Row Keyboard
297 Remove Linked List Elements
298 How Many Numbers Are Smaller Than the Current Number
299 Most Frequent Even Element
300 Maximum Odd Binary Number
301 Armstrong Number
302 Counting Elements
303 Make The String Great
304 Cells with Odd Values in a Matrix
305 Power of Two
306 Decode XORed Array
307 Long Pressed Name
308 Kids With the Greatest Number of Candies
309 N-ary Tree Postorder Traversal
310 Max Consecutive Ones
311 Find Words That Can Be Formed by Characters
312 Number of 1 bits
313 Largest Unique Number
314 The Employee That Worked on the Longest Task
315 Paint House
316 Logger Rate Limiter
317 Substrings of Size Three with Distinct Characters
318 Maximum Difference by Remapping a Digit
319 Monotonic Array
320 Check if One String Swap Can Make Strings Equal
321 Valid Palindrome II
322 Occurrences After Bigram
323 Minimum Sum of Four Digit Number After Splitting Digits
324 Move Zeroes
325 Number of Arithmetic Triplets
326 Count Number of Pairs With Absolute Difference K
327 Number of Lines To Write String
328 First Unique Character in a String
329 Maximum depth of Binary tree
330 Largest Number At Least Twice of Others
331 Reverse String II
332 Letter Case Permutation
333 Two Sum
334 Climbing Stairs
335 Projection Area of 3D Shapes
336 Maximize Sum Of Array After K Negations
337 Third Maximum Number
338 Sign of the Product of an Array
339 Heaters
340 Remove Palindromic Subsequences
341 Time Needed to Buy Tickets
342 Find the K-Beauty of a Number
343 Find All K-Distant Indices in an Array
344 Student Attendance Record I
345 Delete Characters to Make Fancy String
346 Longest Uncommon Subsequence
347 Check Distances Between Same Letters
348 Valid Mountain Array
349 Shortest Word Distance
350 Check if String Is Decomposable Into Value-Equal Substrings
351 Matrix Cells in Distance Order
352 Final Value of Variable After Performing Operations
353 Shuffle String
354 Sum of Square Numbers
355 Percentage of Letter in String
356 Intersection of Two Arrays II
357 Most Common Word
358 Count Asterisks
359 Sum of Squares of Special Elements
360 Largest 3-Same-Digit Number in String
361 Number of Students Doing Homework at a Given Time
362 Invert Binary Tree
363 Check if the Sentence Is Pangram
364 Island Perimeter
365 Available Captures for Rook
366 Count Common Words With One Occurrence
367 Degree of an array
368 Sum of Root To Leaf Binary Numbers
369 Circular Sentence
370 Sort Array By Parity
371 Number of Good Pairs
372 Convert a number to hexadecimal
373 Check If a Word Occurs As a Prefix of Any Word in a Sentence
374 Calculate Delayed Arrival Time
375 Concatenation of Array
376 Number of Recent Calls
377 Fixed Point
378 Valid Boomerang
379 Minimum Moves to Equal an Array Element
380 Calculate Money in Leetcode Bank
381 Check If Two String Arrays are Equivalent
382 Find Nearest Point That Has the Same X or Y Coordinate
383 Maximum Product Difference Between Two Pairs
384 Goal Parser Interpretation
385 Find the Losers of the Circular Game
386 Judge Route Cycle
387 K Items With the Maximum Sum
388 Middle of the linked list
389 Maximum Number of Pairs in Array
390 Check if Matrix Is X-Matrix
391 Compare Strings by Frequency of the Smallest Character
392 Intersection of Two Arrays
393 Bulls and Cows
394 Slowest Key
395 Count Equal and Divisible Pairs in an Array
396 nim_game
397 Min Max Game
398 Groups of Special-Equivalent Strings
399 Reformat The String
400 Minimum Number of Operations to Convert Time
401 Form Smallest Number From Two Digit Arrays
402 Minimum Operations to Collect Elements
403 Count Elements With Strictly Smaller and Greater Elements
404 Determine the Winner of a Bowling Game
405 Minimum Operations to Make the Array Increasing
406 Minimum Right Shifts to Sort the Array
407 Index Pairs of a String
408 Number of Steps to Reduce a Number to Zero
409 Confusing Number
410 Convert BST to Greater Tree
411 Find All Numbers Disappeared in an Array
412 Largest Number After Digit Swaps by Parity
413 Merge Two 2D Arrays by Summing Values
414 Reformat Date
415 Largest Odd Number in String
416 Build Array from Permutation
417 Find Lucky Integer in an Array
418 Reverse Prefix of Word
419 Nested List Weight Sum
420 Relative ranks
421 Palindrome Permutation
422 Find Winner on a Tic Tac Toe Game
423 Merge two binary trees
424 Check if Numbers Are Ascending in a Sentence
425 Power of Three
426 Remove Letter To Equalize Frequency
427 Lemonade Change
428 Length of last word
429 Increasing Decreasing String
430 N-th Tribonacci Number
431 Longest Common Prefix
432 Minimum Time Visiting All Points
433 Calculate Amount Paid in Taxes
434 Number of Different Integers in a String
435 Minimize String Length
436 Add Strings
437 Maximum Ascending Subarray Sum
438 Best Time to Buy and Sell Stock
439 Lowest Common Ancestor of a Binary Search Tree
440 Determine if String Halves Are Alike
441 Find the difference
442 Check if Every Row and Column Contains All Numbers
443 Replace All Digits with Characters
444 Largest Substring Between Two Equal Characters
445 Strobogrammatic Number
446 Rearrange Characters to Make Target String
447 Next Greater Element I
448 Counting Bits
449 Remove Outermost Parentheses
450 Count the Number of Vowel Strings in Range
451 Determine if Two Events Have Conflict
452 Replace All ?'s to Avoid Consecutive Repeating Characters
453 Two Sum Less Than K
454 Majority Element
455 Merge Sorted Array
456 Unique Morse Code Words
457 Divisor Game
458 Find Numbers with Even Number of Digits
459 Categorize Box According to Criteria
460 Implement Queue using Stacks
461 N-ary Tree Preorder Traversal
462 Smallest Index With Equal Value
463 Total Distance Traveled
464 Delete Node in a Linked List
465 Sort Array By Parity II
466 Most Visited Sector in a Circular Track
467 Greatest Common Divisor of Strings
468 Remove Element
469 Maximum Subarray Sum I
470 Partition Array Into Three Parts With Equal Sum
471 Remove Duplicates From Sorted Lists
472 Minimum Bit Flips to Convert Number
473 Sort Even and Odd Indices Independently
474 Meeting Rooms
475 Crawler Log Folder
476 Maximum Difference Between Increasing Elements
477 Left and Right Sum Differences
478 Find the Middle Index in Array
479 Range Sum Query Immutable
480 Intersection of two Linked Lists
481 Merge Similar Items
482 Can Place Flowers
483 Generate a String With Characters That Have Odd Counts
484 Count Operations to Obtain Zero
485 Array Partition I
486 Next Greater Element
487 Perfect Number
488 Sum of Digits in the Minimum Number
489 Guess Number Higher or Lower
490 Find the Array Concatenation Value
491 Self Dividing Number
492 Design HashMap
493 Minimum Time to Type Word Using Special Typewriter
494 Check Whether Two Strings are Almost Equivalent
495 Shortest Distance to Target String in a Circular Array
496 Cells in a Range on an Excel Sheet
497 Number of Common Factors
498 Keep Multiplying Found Values by Two
499 Search in a Binary Search Tree
500 Count Largest Group
501 Sum of Unique Elements
502 Moving Average from Data Stream
503 Symmetric Tree
504 Maximum Product of Two Elements in an Array
505 Difference Between Element Sum and Digit Sum of an Array
506 Find Common Characters
507 Lucky Numbers in a Matrix
508 Remove Vowels from a String
509 Add Digits
510 Teemo Attacking
511 Contains Duplicate II
512 Count Integers With Even Digit Sum
513 Minimum Index Sum of Two Lists
514 Two Out of Three
515 Closest Binary Search Tree Value
516 Distribute Money to Maximum Children
517 Sum of Digits in Base K
518 Fibonacci Number
519 Distribute Candies to People
520 Valid Word Square
521 Distribute Candies
522 Check If a Number Is Majority Element in a Sorted Array
523 Alternating Digit Sum
524 Take Gifts From the Richest Pile
525 Verifying an Alien Dictionary
526 Longest Palindrome
527 Sum of All Odd Length Subarrays
528 Average Salary Excluding the Minimum and Maximum Salary
529 Apply Operations to an Array
530 Single Number
531 Keyboard Row
532 Count Distinct Numbers on Board
533 Squares of a Sorted Array
534 Find the Longest Balanced Substring of a Binary String
535 Binary Tree Postorder Traversal
536 Rearrange Spaces Between Words
537 Minimum Recolors to Get K Consecutive Black Blocks
538 Count Square Sum Triples
539 Maximum Distance in Arrays
540 Unique Number of Occurrences
541 Day of the Week
542 Design an Ordered Stream
543 Minimum Distance Between BST Nodes
544 Maximum Sum With Exactly K Elements
545 Number of Students Unable to Eat Lunch
546 Check if Number Has Equal Digit Count and Digit Value
547 Sum Of Two Integers
548 Check if a String Is an Acronym of Words
549 Search Insert Position
550 Max Pair Sum in an Array
551 Longest Univalue Path
552 Maximum Depth of N-ary Tree
553 Thousand Separator
554 Add Binary
555 Convert Binary Number in a Linked List to Integer
556 Sorting the Sentence
557 Replace Elements with Greatest Element on Right Side
558 Matrix Diagonal Sum
559 Check Array Formation Through Concatenation
560 Water Bottles
561 Add to Array-Form of Integer
562 Prime In Diagonal
563 Pass the Pillow
564 Missing Number In Arithmetic Progression
565 Divide Array Into Equal Pairs
566 Maximum Value of a String in an Array
567 Maximum Number of Balls in a Box
568 Mean of Array After Removing Some Elements
569 N-Repeated Element in Size 2N Array
570 Redistribute Characters to Make All Strings Equal
571 Remove All Adjacent Duplicates In String
572 Minimum Absolute Difference in BST
573 Image Smoother
574 Find the Difference of Two Arrays
575 How Many Apples Can You Put into the Basket
576 Second Minimum Node in a binary tree
577 Excel Sheet Column Number
578 Same Tree
579 Count Odd Numbers in an Interval Range
580 String Without AAA or BBB
581 Find Greatest Common Divisor of Array
582 Longest Word in Dictionary
583 Happy Number
584 Array Transformation
585 Design Compressed String Iterator
586 Reverse words in a String III
587 Rank Transform of an Array
588 First Bad Version
589 Sort Integers by The Number of 1 Bits
590 Split With Minimum Sum
591 Construct String from Binary Tree
592 Maximum Number of Words Found in Sentences
593 Toeplitz Matrix
594 Find Maximum Number of String Pairs
595 Finding 3-Digit Even Numbers
596 Valid Word Abbreviation
597 Second Largest Digit in a String
598 Valid Palindrome
599 Relative Sort Array
600 Minimum Cuts to Divide a Circle
601 Path In Zigzag Labelled Binary Tree
602 Shortest Completing Word
603 Nim Game
604 Count Substrings with Only One Distinct Letter
605 Average of Levels in Binary Tree
606 Merge Strings Alternately