Count consecutive characters in string python


When it is required to get the count of consecutive identical elements in a list, an iteration, the ‘append’ method, and the ‘set’ method are used.

Example

Below is a demonstration of the same

my_list = [24, 24, 24, 15, 15, 64, 64, 71, 13, 95, 100]

print("The list is :")
print(my_list)

my_result = []
for index in range(0, len(my_list) - 1):

   if my_list[index] == my_list[index + 1]:
      my_result.append(my_list[index])

my_result = len(list(set(my_result)))

print("The result is :")
print(my_result)

Output

The list is :
[24, 24, 24, 15, 15, 64, 64, 71, 13, 95, 100]
The result is :
3

Explanation

  • A list is defined and is displayed on the console.

  • An empty list is defined.

  • The list is iterated over and if the element in the zeroth index and element in the first index are equivalent, the zeroth element is appended to the empty list.

  • This is converted to a set and then to a list, and its length is assigned to a variable.

  • This is the output that is displayed on the console.

Count consecutive characters in string python

Updated on 14-Sep-2021 11:08:13

  • Related Questions & Answers
  • Program to count operations to remove consecutive identical bits in Python
  • Python program to count pairs for consecutive elements
  • Check if three consecutive elements in an array is identical in JavaScript
  • Swap Consecutive Even Elements in Python
  • Python – Filter consecutive elements Tuples
  • Python – Reorder for consecutive elements
  • Count Subarrays with Consecutive elements differing by 1 in C++
  • Adding up identical elements in JavaScript
  • Consecutive elements pairing in list in Python
  • Python – Group Consecutive elements by Sign
  • Python – Summation of consecutive elements power
  • Python - Check if all elements in a list are identical
  • Check if array elements are consecutive in Python
  • Python – Grouped Consecutive Range Indices of Elements
  • Sum identical elements within one array in JavaScript

Consecutive Characters LeetCode Solution – The power of the string is the maximum length of a non-empty substring that contains only one unique character.

Given a string s, return the power of s.

we need to find the Longest Substring with the same characters.

We can iterate over the given string, and use a variable count to record the length of that substring.

When the next character is the same as the previous one, we increase count by one. Else, we reset count to 1.

With this method, when reaching the end of a substring with the same characters, count will be the length of that substring, since we reset the count when that substring starts, and increase count when iterating that substring.

Increase the counter by 1 if the current char is the same as the previous one; otherwise, reset the counter to 1;

Update the max value of the counter during each iteration.

If the current char is not equal to the previous one then it means that more than one unique characters are present in the current substring, thus we reset the counter to 1 to recheck the following strings from now on.

S.NoInterview QuestionNumber of times has been asked1 Delete a node in doubly linked list 2881 2 Java program to find the number of Nodes in a Binary Tree 2538 3 Reverse a string without affecting special characters 2519 4 Palindrome using Recursion 2485 5 Delete a node of a linked list at given position 2017 6 Quick Sort 1766 7 Insert nodes in a linked list in a sorted way (Ascending Order) 1705 8 Find elements pair from array whose sum equal to number 1686 9 Sort Elements by Frequency of Occurrences 1671 10 Write a program to print all permutations of a given string 1652 11 Find Minimum Distance Between Two Numbers in an Array 1516 12 Create a Doubly Linked List 1480 13 Reverse an Array 1459 14 Smallest window in a string containing all characters of another string 1435 15 Recursively remove all adjacent duplicates 1398 16 Find a Triplet That Sum to a Given Value 1384 17 First Repeating Element 1382 18 Sum of numbers in String 1360 19 Arrange Even and Odd number such that Odd comes after Even 1356 20 Smallest Positive Number Missing in an Unsorted Array 1321 21 Check if the Elements of an Array are Consecutive 1289 22 Detect a loop in the Linked List 1267 23 Largest Sum Contiguous Subarray 1260 24 Quick Sort on SIngly Linked List 1254 25 Print all Possible Combinations of R Elements in a given Array of size N 1245 26 Subarray with Given Sum 1244 27 Recursive function to do substring search 1242 28 Find the Maximum Repeating Number in Array 1201 29 Find the First and Second Smallest Elements 1153 30 Binary Tree Level order traversal in Java 1151 31 Check if two linked lists are identical 1140 32 Maximum Subarray Sum using Divide and Conquer 1137 33 Remove characters from first string which are in second 1107 34 Find Leaders in an Array 1091 35 Swap nodes in the linked list 1080 36 Find the second most frequent character 1033 37 Find the Number Occurring Odd Number of Times in an Array 1031 38 Arrange given Numbers to Form the Biggest Number II 1024 39 Given a string find its first non-repeating character 1007 40 Find Triplet in Array With a Given Sum 999 41 Given a sorted array and a number x, find the pair in array whose sum is closest to x 990 42 A Program to check if strings are rotations of each other or not 983 43 Total number of occurrences of a given item in the linked list 983 44 Print all possible words from phone digits 968 45 Find the Missing Number 961 46 Rearrange Positive and Negative Numbers Alternatively in Array 948 47 Longest Palindromic Substring 943 48 Segregate even and odd nodes in a linked list 926 49 Print Longest common subsequence 922 50 Transform one string to another using minimum number of given operations 909 51 Union and Intersection of Two Linked Lists 902 52 Check rearranged string can form a palindrome 895 53 Rearrange given Array in Maximum Minimum Form 874 54 Iterative Implementation of Quick Sort 866 55 Count Possible Triangles 852 56 Insertion Sort 852 57 Multiplication of Two Matrices 837 58 Count of Triplets With Sum Less than Given Value 828 59 Stock Buy Sell to Maximize Profit 826 60 Rotate a Linked List 822 61 Check if the linked list is palindrome 821 62 Concatenation of two strings 799 63 Tug of War 793 64 Print all duplicates in the input string 792 65 Count Number of Substrings with K Distinct Character’s 787 66 Find Nearest Greater and Smaller Element 779 67 Reverse String Without Temporary Variable 775 68 The Celebrity Problem 767 69 Remove ‘b’ and ‘ac’ from a given string 767 70 Find Pythagorean Triplets from Array 764 71 Find all Common Elements in Given Three Sorted Arrays 760 72 Find the Row with Maximum Number of 1’s 735 73 Remove all duplicates in an unsorted linked list 733 74 Remove Minimum Characters so that Two Strings Become Anagrams 732 75 Find the Peak Element from an Array 732 76 Find the subarray whose sum is equal to a given number X 731 77 Find Smallest Missing Number in a Sorted Array 723 78 Addition of Two Matrices 721 79 Generate all Binary Strings Without Consecutive 1’s 718 80 A Product Array Puzzle 718 81 Maximum Sum of Non Consecutive Elements 706 82 Implement Two Stacks in an Array 700 83 Lexicographic rank of string 688 84 Check if Two given Matrices are Identical 687 85 Maximum Product Subarray II 684 86 Multiplication of Previous and Next 677 87 Subtraction of Two Matrices 671 88 Merge K Sorted Arrays and Print Sorted Output 664 89 Move All the Zeros to the End of the Given Array 663 90 Online Algorithm for Checking Palindrome in a Stream 661 91 Form Minimum Number from Given Sequence of D’s and I’s 659 92 Divide a string in N equal parts 657 93 Check whether two strings are anagram of each other 655 94 Remove recurring digits in a given number 650 95 Sort a stack using a temporary stack 646 96 Maximum Circular Subarray Sum 642 97 Sort a linked list that is sorted alternating ascending and descending 639 98 Subarray and Subsequence 636 99 Find the Minimum Element in a Sorted and Rotated Array 636 100 Move last element of the Linked List at first place 630 101 First Circular Tour to Visit all the Petrol Bunks 627 102 3Sum Leetcode Solution 624 103 Largest Subarray with Equal Number of 0’s and 1’s 624 104 Palindrome Permutations of a String 623 105 Compare two strings(linked lists) 622 106 Maximum Element in an Array which is Increasing and then Decreasing 621 107 Flattening a linked list 616 108 Palindromes in a given range 615 109 Pangram Checking 614 110 Run length encoding 613 111 Minimum insertions to form a shortest palindrome 613 112 Majority Element 611 113 Print all permutations with repetition 611 114 Elements Appear more than N/K times in Array 607 115 Minimum Characters to be Added at Front to Make String Palindrome 603 116 Most repeating character in a string 601 117 Two Sum Leetcode Solution 601 118 Rotate string to get lexicographically minimum string 598 119 Repeated Subsequence of Length Two or More 596 120 Remove all duplicates in a sorted linked list 590 121 Minimum number of Merge Operations to make an Array Palindrome 589 122 Merge a linked list into another at alternate positions 589 123 Rearrange a given linked list in-place 589 124 Print all anagrams together in a sequence of words 584 125 Pancake Sorting Problem 574 126 Reorder an Array According to the Given Indexes 572 127 Clone a Linked List with next and random pointer 563 128 Merge Overlapping Intervals II 562 129 Transpose of a Matrix 561 130 Remove duplicates from a string 560 131 Longest Palindrome can be Formed by Removing or Rearranging Characters 559 132 Remove Extra Spaces from a String 558 133 Smallest Palindrome after Replacement 558 134 Removing Spaces from a String using stringstream 555 135 Maximum Sum Increasing Subsequence 554 136 Check if a given string is a rotation of a palindrome 554 137 Size of The Subarray With Maximum Sum 554 138 Partition Problem 548 139 Check whether Strings are K Distance Apart or Not 542 140 Generate all Binary Strings from Given Pattern 542 141 Length of Longest valid Substring 538 142 Delete Last Occurrence 534 143 Check if Two given Strings are Isomorphic to each other 528 144 Insert Node in the Sorted Linked List 527 145 Find Zeros to be Flipped so that Number of Consecutive 1’s is Maximized 527 146 Program to Toggle all Characters in a String 524 147 Maximum difference between two elements such as larger element comes after smaller 522 148 Given string is interleaving of two other strings or not 519 149 Number of Smaller Elements on Right Side 511 150 Count Minimum Steps to Get the given Array 510 151 Check length of a String is Equal to the Number Appended at its Last 506 152 Check if all Rows of a Matrix are Circular Rotations of Each Other 505 153 Find Pair with Given Difference 504 154 Merge sort better than quick sort for linked lists 501 155 Longest Common Prefix using Divide and Conquer 500 156 Print Reverse of a string (Recursion) 494 157 Compare Two Version Numbers 494 158 Find nth node of the Linked list from the end 494 159 Median of Two Sorted Arrays LeetCode Solution 490 160 Print all interleavings of given two strings 490 161 Sort 0s 1s and 2s in an Array 490 162 Find a Fixed Point in a Given Array 489 163 Reorder Array Using Given Indexes 488 164 Reverse words in a given string 485 165 Find the Subarray of given length with Least Average 480 166 Merge two sorted linked lists such that merged list is in reverse order 480 167 Split linked list using alternate nodes 475 168 Print string of odd length in ‘X’ format 470 169 Print all Palindromic Partitions of a String 469 170 Find Element Using Binary Search in Sorted Array 462 171 Find K Length Subarray of Maximum Average 461 172 Swap Kth Node from beginning with Kth Node from End 459 173 Find Duplicates in an Array in Most Efficient Way 456 174 print all palindromic partitions 450 175 Check if String Follows Order of Characters by a Pattern or not 449 176 Shortest Superstring Problem 448 177 Maximum Length of Chain Pairs 446 178 Sort a String According to Another String 444 179 Flatten a multilevel linked list 439 180 Sorting a K Sorted Array 437 181 Program to add two binary digits 428 182 Find a Sorted Subsequence of size 3 425 183 Longest Span with same Sum in two Binary Arrays II 423 184 Caesar Cipher 421 185 Longest Common Prefix Using Binary Search II 421 186 Reverse a Linked List in groups 421 187 Find the two Numbers with Odd Occurrences in an Unsorted Array 420 188 Recursively print all the sentences that can be formed from list of word lists 420 189 Kth Non-repeating Character 417 190 Reverse a Singly Linked List (Iterative/Non-Recursive) 414 191 Check if String can Become Empty by Recursively Deleting given Substring 412 192 Longest Common Prefix Word by Word Matching 404 193 Rearrange a linked list in Zig-Zag 404 194 Rotate Image by 90 degrees 403 195 Perfect Reversible String 400 196 Pancake Sorting 400 197 Permutations of a Given String Using STL 400 198 Find First non-repeating character in a string 398 199 Merging Two Sorted Arrays 397 200 1`s and 2`s complement of binary number 393 201 Increasing Subsequence of Length three with Maximum Product 392 202 Maximum occurring character in a string 389 203 List items containing all characters of a given word 389 204 Find the point where a monotonically increasing function becomes positive first time 388 205 Sort a linked list with 0s, 1s and 2s 385 206 Four Elements that Sum to Given 383 207 Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes 383 208 Longest Common Prefix using Character by Character Matching 383 209 Count Number of Occurrences in a Sorted Array 378 210 Palindrome string (number) 378 211 Delete N nodes after M 375 212 Minimum Characters to be Removed to Make a Binary String Alternate 373 213 Valid Parentheses LeetCode Solution 373 214 Split a string 372 215 Even Substring Count 370 216 Sorting the array of strings 367 217 Convert a String that is Repetition of a Substring of Length K 366 218 Recursive Implementation of atoi() 364 219 Check if a Linked list of Strings form a Palindrome 362 220 Print Shortest Path to Print a String on Screen 362 221 Maximum Subarray Leetcode Solution 358 222 Convert string1 to string2 in one edit 357 223 Reverse a String using Stack 357 224 Print All Distinct Elements of the Array 356 225 Nth Character in Concatenated Decimal String 355 226 Reverse a singly linked list recursively 354 227 Find the first Repeating Number in a Given Array 352 228 wildcard character matching 352 229 Count the number of words 352 230 Can we reverse a linked list in less than O(n) time ? 349 231 Matrix Chain Multiplication using Dynamic Programming 348 232 Lower Case To Upper Case 348 233 Binary Tree to Doubly linked list 343 234 Sort Elements by Frequency II 342 235 Merge Two Sorted Arrays 339 236 Find the Lost Element From a Duplicated Array 339 237 Longest Common Subsequence with Permutations 339 238 Split Four Distinct Strings 338 239 Roman to Integer Leetcode Solution 333 240 Find middle of the Linked List 333 241 Count the Pairs at Same Distance as in English Alphabets 331 242 Palindrome Permutation 324 243 Toeplitz Matrix 324 244 Next Greater Element in an Array 321 245 Move all negative elements to one side of array 321 246 Word Search Leetcode Solution 319 247 N queen problem 317 248 First non Repeating Element 312 249 Count Pairs With Given Sum 312 250 Searching a node in a Binary Search Tree 312 251 Find All Pairs With a Given Difference 312 252 Find Nth Node 311 253 String(represents an integer) to value 310 254 Reverse Bits 310 255 Number of Islands LeetCode Solution 310 256 Print all Possible Ways to Break a String in Bracket Form 308 257 Sudoku Solver 308 258 Reverse a String 308 259 Triplet from three linked lists with given sum 307 260 Delete a Tree 307 261 Repeated Substring Pattern 307 262 Types of Binary Tree 306 263 Meeting Rooms II LeetCode Solution 306 264 Change Gender of a given String 306 265 How to Efficiently Implement k Stacks in a Single Array? 305 266 Sort an array of strings 303 267 Longest Palindromic Substring LeetCode Solution 303 268 Delete a node under given conditions 302 269 Number of sub-strings which recursively add up to 9 302 270 Min Stack 301 271 Fibonacci numbers 299 272 Reverse a linked list 298 273 Binary Tree 296 274 House Robber Leetcode Solution 295 275 Most Frequent Element in an Array 295 276 Dijkstra Algorithm 295 277 Longest Common Extension 295 278 Cuckoo sequence program 293 279 Remove spaces from a string 293 280 Max stack 290 281 Shuffle a given Array 288 282 Word Search 288 283 Best Time to Buy and Sell Stock  II Leetcode Solution 288 284 KMP Algorithm 286 285 Minimize the maximum difference between the heights 286 286 Subset Leetcode 286 287 Remove middle points in a linked list of line segments 285 288 Expression Evaluation 284 289 Plus One Leetcode Solution 284 290 Find, second, frequent, character 283 291 Number Of 1 bits 281 292 Combination Sum Leetcode Solution 281 293 Search Insert Position Leetcode Solution 279 294 Reverse words in a string 278 295 Pair of Positive Negative Values in an Array 277 296 Evaluation of Postfix Expression 277 297 Set Matrix Zeroes 276 298 Min Stack Leetcode Solution 274 299 Valid Palindrome Leetcode Solution 274 300 Subarray with 0 sum 273 301 Sliding Window Technique 273 302 Backspace String Compare 272 303 Rabin Karp Algorithm 272 304 Common elements in all rows of a given matrix 269 305 Sort linked which is sorted on absolute values 268 306 Merge Sorted Arrays Leetcode Solution 267 307 Clone a linked list with next and random pointer (Hashing) 265 308 Sqrt(x) Leetcode Solution 265 309 Reversing a Queue 264 310 Delete middle element of a stack 264 311 Contains Duplicate II Leetcode Solution 262 312 Implementation of Deque using Doubly Linked List 261 313 Tower Of Hanoi 260 314 Combination Sum 260 315 Product of array except self 260 316 Intersection of Two Arrays II Leetcode Solution 259 317 Reverse individual words 259 318 Find Top K (or Most Frequent) Numbers in a Stream 259 319 Count of index pairs with equal elements in an array 259 320 Contains Duplicate 258 321 Minimum swaps required to bring all elements less than or equal to k together 258 322 How to Delete a Linked List 258 323 Pascal Triangle Leetcode 258 324 Integer to Roman Leetcode Solution 257 325 String Compression 257 326 Count subarrays with equal number of 1’s and 0’s 257 327 Page Replacement Algorithms in Operating Systems 256 328 Count Odd Numbers in an Interval Range Leetcode Solution 256 329 Single Number Leetcode Solution 255 330 Group Words With Same Set of Characters 254 331 Segregate even and odd numbers 254 332 Sum of minimum and maximum elements of all subarrays of size k 254 333 Sort elements by frequency 253 334 Minimum Value to Get Positive Step by Step Sum Leetcode Solution 253 335 Find sum of non-repeating elements (distinct) elements in an array 253 336 Arithmetic Expression Evaluation 252 337 Smallest Subarray with k Distinct Numbers 252 338 Add Binary Leetcode Solution 252 339 Postfix to Infix Conversion 252 340 Second Most Repeated Word in a Sequence 251 341 Construct Binary Tree from Given Inorder and Preorder Traversals 251 342 K-th Smallest Element in a Sorted Matrix 250 343 Minimum operation to make all elements equal in array 250 344 Pow(x, n) Leetcode Solution 249 345 Maximum Number of Balloons Leetcode Solution 249 346 Next Permutation 248 347 Top K Frequent Words 248 348 Bellman Ford Algorithm 248 349 Count subarrays having total distinct elements same as original array 248 350 Longest Common Prefix Leetcode Solution 247 351 Palindrome Linked List Leetcode Solution 247 352 Sorting array using Stacks 246 353 Convex Hull Algorithm 246 354 Majority Element Leetcode Solution 245 355 Scramble String 245 356 Given two unsorted arrays find all pairs whose sum is x 244 357 Permutations Leetcode Solution 244 358 Kruskal Algorithm 244 359 Longest Substring Without Repeating Characters LeetCode Solution 244 360 Design a stack that supports getMin() in O(1) time and O(1) extra space 244 361 Evaluate Division 244 362 First element occurring k times in an array 244 363 Reverse a Number Using Stack 242 364 Special Number 242 365 Find Lucky Integer in an Array Leetcode Solution 242 366 Number of Good Pairs Leetcode Solution 241 367 Running Sum of 1d Array Leetcode Solution 241 368 Find Numbers with Even Number of Digits Leetcode Solution 240 369 Spiral Matrix LeetCode Solution 240 370 Find duplicates in a given array when elements are not limited to a range 239 371 Reversing the First K elements of a Queue 239 372 Third Maximum Number Leetcode Solution 238 373 Minimum Path Sum 237 374 Fizz Buzz Leetcode 237 375 Maximum Subarray 237 376 Minimum Steps to reach target by a Knight 237 377 Swap Nodes in Pairs Leetcode Solutions 237 378 Prefix to Infix Conversion 237 379 Find the Town Judge Leetcode Solution 237 380 Unique Paths 236 381 Check if two arrays are equal or not 236 382 Single Number 236 383 Find the Closest Palindrome number 236 384 Maximum possible difference of two subsets of an array 236 385 Maximum Distance Between two Occurrences of Same Element in Array 236 386 Minimum Absolute Difference Leetcode Solution 236 387 Huffman Coding 236 388 Maximal Square 236 389 Sort Array by Increasing Frequency Leetcode Solution 235 390 Group Anagrams 235 391 Count Primes Leetcode Solutions 235 392 Convert String To Int 234 393 Range Sum Query 2D – Immutable Leetcode Solution 233 394 Pascal’s Triangle II Leetcode Solution 233 395 Matrix Diagonal Sum Leetcode Solution 232 396 Missing Number Leetcode Solution 232 397 Power of Two Leetcode Solution 232 398 Smallest Element Repeated Exactly K Times 232 399 Sort Integers by The Number of 1 Bit Leetcode Solution 231 400 Bipartite Graph 231 401 Top K Frequent Elements 231 402 Find All Numbers Disappeared in an Array Leetcode Solution 231 403 Zigzag Conversion 231 404 Check if Array Contains Contiguous Integers With Duplicates Allowed 231 405 Remove Minimum Number of Elements Such That no Common Element Exist in both Array 231 406 Sorting using trivial hash function 231 407 Leetcode Permutations 231 408 Palindrome Substring Queries 231 409 Merge Two Sorted Lists Leetcode Solutions 230 410 Find the first repeating element in an array of integers 230 411 Find top three repeated in array 230 412 Implement Stack and Queue using Deque 230 413 Find Number of Employees Under every Employee 230 414 How to Implement Stack Using Priority Queue or Heap? 230 415 Letter Case Permutation 230 416 House Robber II Leetcode Solution 229 417 Print All Distinct Elements of a Given Integer Array 229 418 Cumulative Frequency of Count of Each Element in an Unsorted Array 228 419 Decode String 228 420 Difference between highest and least frequencies in an array 228 421 Expression Contains Redundant Bracket or Not 228 422 Maximum Depth of Binary Tree Leetcode Solution 228 423 Unique Paths Leetcode Solution 227 424 Happy Number Leetcode Solution 227 425 Check If N and Its Double Exist Leetcode Solution 227 426 Coin Change 2 Leetcode Solution 227 427 Prim’s Algorithm 227 428 Search in Rotated Sorted Array Leetcode Solution 227 429 Print all subarrays with 0 sum 227 430 Length of the largest subarray with contiguous elements 227 431 Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution 226 432 Capacity To Ship Packages Within D Days Leetcode Solution 226 433 Count Substrings with equal number of 0s, 1s and 2s 226 434 Subarray Sum Equals k 226 435 Max Consecutive Ones Leetcode Solution 226 436 Subset sum problem 226 437 Find Median from data Stream 225 438 Sort a stack using recursion 225 439 Reverse Integer 225 440 Fizz Buzz 225 441 Find Winner on a Tic Tac Toe Game Leetcode Solution 225 442 LRU Cache Implementation 224 443 Nth Catalan Number 224 444 Trapping Rain Water Leetcode Solution 223 445 Monotonic Array LeetCode Solution 223 446 How Many Numbers Are Smaller Than the Current Number Leetcode Solution 223 447 Find The Duplicate Number 223 448 Reverse Vowels of a String Leetcode Solution 223 449 Find elements which are present in first array and not in second 223 450 Find the Difference Leetcode Solution 223 451 Edit Distance 222 452 Find all pairs (a, b) in an array such that a % b = k 222 453 Reverse a Stack Using Recursion 222 454 Subtract the Product and Sum of Digits of an Integer Leetcode Solution 221 455 Target Sum 221 456 Remove Duplicates from Sorted Array Leetcode Solution 221 457 Subarrays with distinct elements 221 458 Text Justification LeetCode Solution 220 459 Kth largest element in an Array Leetcode Solutions 220 460 Count pairs from two linked lists whose sum is equal to a given value 220 461 Fibonacci Number LeetCode Solution 220 462 Integer to English words 220 463 Priority Queue Using Singly Linked List 220 464 Longest subarray not having more than K distinct elements 220 465 Find Index of Closing Bracket for a Given Opening Bracket in an Expression 219 466 Sum of Subarray Ranges Leetcode Solution 219 467 Count and Say 219 468 Find Minimum In Rotated Sorted Array 219 469 Subarray Sum Equals K LeetCode Solution 219 470 Reverse a String 218 471 Best Time to Buy and Sell Stock III Leetcode Solution 218 472 Design Parking System Leetcode Solution 218 473 Jump Game Leetcode Solution 218 474 Find distinct elements common to all rows of a matrix 217 475 Delete a Node from linked list without head pointer 217 476 The K Weakest Rows in a Matrix Leetcode Solution 217 477 Find any one of the multiple repeating elements in read only array 217 478 Pair with given product 217 479 Valid Parenthesis String 217 480 MiniMax Algorithm 216 481 Floyd Warshall Algorithm 216 482 Find four elements that sum to a given value (Hashmap) 216 483 Top View of Binary Tree 216 484 Multiply Strings Leetcode Solution 216 485 Find missing elements of a range 216 486 Generate a String With Characters That Have Odd Counts Leetcode Solution 216 487 Shuffle String Leetcode Solution 216 488 Iterative Tower of Hanoi 216 489 Shortest Palindrome 216 490 Find Common Characters Leetcode Solution 216 491 Flood Fill LeetCode 216 492 Intersection of Two Arrays 215 493 Shuffle the Array Leetcode Solution 215 494 Excel Sheet Column Number Leetcode Solution 215 495 Longest Common Prefix using Trie 215 496 Degree of an array 215 497 Prefix to Postfix Conversion 215 498 Word Ladder LeetCode Solution 215 499 Number of Steps to Reduce a Number to Zero Leetcode Solution 214 500 Kids With the Greatest Number of Candies Leetcode Solution 214 501 Check if a given array contains duplicate elements within k distance from each other 214 502 Sorting a Queue without Extra Space 214 503 Rearrange a binary string as alternate x and y occurrences 214 504 Balanced Binary Tree Leetcode Solution 214 505 Substring With Concatenation Of All Words 213 506 The Stock Span Problem 213 507 Merge Two Sorted Linked Lists 213 508 Best Time to Buy and Sell Stock LeetCode Solution 213 509 Next Greater Element I Leetcode Solution 213 510 Find subarray with given sum (Handles Negative Numbers) 213 511 Recursion 213 512 Valid Sudoku 212 513 Implement a stack using single queue 212 514 Concatenation of Array LeetCode Solution 212 515 Iterative Inorder Traversal of a Binary Tree 212 516 Peak Index in a Mountain Array 212 517 Move Zeroes LeetCode Solution 212 518 K-th Distinct Element in an Array 212 519 Count number of triplets with product equal to given number 212 520 Count and Say Leetcode Solution 212 521 Longest Common Subsequence 212 522 Minimum Knight Moves LeetCode Solution 211 523 Implement Stack using Queues 211 524 Find the Duplicate Element 211 525 Priority Queue in C++ 211 526 Sum of Left Leaves Leetcode Solutions 211 527 Slowest Key Leetcode Solution 210 528 Kth Largest Element in a Stream Leetcode Solution 210 529 Container with Most Water 210 530 Max Area of Island 210 531 Merge Overlapping Intervals 210 532 Longest Common Prefix using Sorting 210 533 Check for Balanced Parentheses in an Expression 210 534 Reverse Words in a String III LeetCode Solution 210 535 Largest Sum Contiguous Subarray 209 536 Find First and Last Position of Element in Sorted Array Leetcode Solution 209 537 Postfix to Prefix Conversion 209 538 Arrange given numbers to form the biggest number 208 539 Next Greater Frequency Element 208 540 Minimum Moves to Equal Array Elements Leetcode Solution 208 541 Delete Node in a Linked List Leetcode Solution 208 542 Excel Sheet Column Title Leetcode Solution 208 543 Find N Unique Integers Sum up to Zero Leetcode Solution 208 544 Zigzag Conversion LeetCode Solution 208 545 Minimum Delete Operations to make all Elements of Array Same 208 546 Convert array into Zig-Zag fashion 208 547 Jewels and Stones Leetcode Solution 208 548 Isomorphic Strings Leetcode Solution 207 549 Gold Mine Problem 207 550 Largest Perimeter Triangle Leetcode Solution 207 551 Smallest Subarray With all Occurrences of a Most Frequent Element 207 552 Contiguous Array Leetcode 206 553 Hamming Distance 206 554 Minimum Bracket Reversals 206 555 How to check if two given sets are disjoint? 206 556 Shuffle an Array 206 557 Summary Ranges Leetcode Solution 206 558 Mobile Numeric Keypad Problem 206 559 Koko Eating Bananas Leetcode Solution 206 560 Length of Last Word Leetcode Solution 206 561 Is Subsequence Leetcode Solution 206 562 Linked List Cycle II LeetCode Solution 206 563 Group Multiple Occurrence of Array Elements Ordered by first Occurrence 206 564 Change the Array into Permutation of Numbers From 1 to N 205 565 Implementation of Deque using circular array 205 566 Maximum sum rectangle in a 2D matrix 205 567 Find Sum of all unique sub-array sum for a given array 205 568 Convert a normal BST to Balanced BST 205 569 Last Stone Weight 205 570 Distribute Candies to People Leetcode Solution 204 571 3Sum Closest LeetCode Solution 204 572 Find Words That Can Be Formed by Characters Leetcode Solution 204 573 Integer to Roman 204 574 Rotate Image LeetCode Solution 204 575 Count the number of nodes at given level in a tree using BFS 204 576 Minimum Cost to Hire K Workers 203 577 First negative integer in every window of size k 203 578 Number of Provinces Leetcode Solution 203 579 Minimum number of subsets with distinct elements 203 580 LRU Cache LeetCode Solution 203 581 Maximum path sum in a triangle 203 582 Check if a queue can be sorted into another queue using a stack 203 583 Trapping Rain Water LeetCode Solution 203 584 Shortest Path in a Grid with Obstacles Elimination LeetCode Solution 202 585 Remove All Occurrences of a Substring LeetCode Solution 202 586 Valid Anagrams 202 587 Best Time to Buy and Sell Stock 202 588 Find if an Expression has Duplicate Parenthesis or Not 202 589 Island Perimeter Leetcode Solution 202 590 Build Array From Permutation Leetcode Solution 201 591 Longest Increasing Subsequence 201 592 N-th Tribonacci Number Leetcode Solution 201 593 Minimum number of distinct elements after removing m items 201 594 Minimum Operations to convert X to Y 201 595 Combinations Leetcode Solution 201 596 Decode Ways 201 597 Maximum Distance in Array 201 598 Iterative Method to find Height of Binary Tree 201 599 Frog Jump Leetcode Solution 200 600 01 Matrix LeetCode Solution 200 601 Rotate List Leetcode Solution 200 602 Maximum Number of Occurrences of a Substring Leetcode Solution 200 603 Sieve of Eratosthenes 200 604 Non-overlapping sum of two sets 200 605 Maximum difference between first and last indexes of an element in array 200 606 Smallest Good Base 200 607 Sort Characters By Frequency LeetCode Solution 200 608 Delete consecutive same words in a sequence 199 609 Assign Cookies Leetcode Solution 199 610 Remove Linked List Elements Leetcode Solution 198 611 Relative Sort Array Leetcode Solution 198 612 Word Pattern 198 613 Count all subsequences having product less than K 198 614 XOR Operation in an Array Leetcode Solution 198 615 Reverse a stack without using extra space in O(n) 197 616 Find the smallest positive integer value that cannot be represented as sum of any subset of a given array 197 617 Minimum insertions to form a palindrome with permutations allowed 197 618 Find the Duplicate Number LeetCode Solution 197 619 Permutation in String Leetcode Solution 197 620 Reorganize String 196 621 GCD Of Two Numbers 196 622 Optimal Account Balancing LeetCode Solution 196 623 Applications of Breadth First Search and Depth First Search 196 624 Find minimum difference between any two elements 196 625 Bubble sort using two Stacks 196 626 The Knapsack Problem 196 627 Distance Between Bus Stops Leetcode Solution 195 628 Longest Increasing Path in a Matrix LeetCode Solution 195 629 Same Tree LeetCode Solution 195 630 Printing brackets in Matrix Chain Multiplication Problem 195 631 Find Largest d in Array such that a + b + c = d 195 632 Defanging an IP Address Leetcode Solution 195 633 Insert Interval Leetcode Solution 195 634 Strobogrammatic Number LeetCode Solution 194 635 Word Wrap Problem 194 636 Tracking current Maximum Element in a Stack 194 637 First Unique Character in a String LeetCode Solution 194 638 Reducing Dishes LeetCode Solution 194 639 Employee Free Time LeetCode Solution 194 640 House Robber 194 641 Isomorphic Strings 194 642 How to Create Mergable Stack? 194 643 Sum of f(a[i], a[j]) over all pairs in an array of n integers 194 644 Convert Sorted Array to Binary Search Tree Leetcode Solution 194 645 Unique Binary Search Trees 194 646 Stone Game LeetCode 193 647 Minimum Number of Steps to Make Two Strings Anagram Leetcode Solutions 193 648 Count Good Nodes in Binary Tree Leetcode Solution 193 649 License Key Formatting Leetcode Solution 193 650 Find pairs with given sum such that elements of pair are in different rows 193 651 K Empty Slots 193 652 Robot Room Cleaner Leetcode Solution 192 653 Maximum Number of Chocolates to be Distributed Equally Among k Students 192 654 Replace Elements with Greatest Element on Right Side Leetcode Solution 192 655 Check If It Is a Straight Line Leetcode Solution 192 656 Convert an array to reduced form 192 657 Letter Combinations of a Phone Number 192 658 Maximum Consecutive Numbers Present in an Array 191 659 Power of Four Leetcode Solution 191 660 Find Pair with Greatest Product in Array 191 661 Maximum Product of Two Elements in an Array Leetcode Solution 191 662 Kth Missing Positive Number Leetcode Solution 191 663 String to Integer (atoi) LeetCode Solution 190 664 Sort Array By Parity LeetCode Solution 190 665 Moving Average from Data Stream Leetcode Solution 190 666 Valid Palindrome II Leetcode Solution 190 667 K Empty Slots LeetCode 190 668 Partition Labels LeetCode Solution 190 669 Longest Substring with At Most K Distinct Characters LeetCode Solution 190 670 Form minimum number from given sequence 190 671 Reservoir Sampling 190 672 Segregate 0s and 1s in an Array 190 673 Wiggle Sort 189 674 Distance of nearest cell having 1 in a binary matrix 189 675 Minimum Depth of Binary Tree Leetcode Solution 189 676 Find Maximum Level sum in Binary Tree 189 677 Painting Fence Algorithm 189 678 String Compression LeetCode Solution 189 679 Sum of All Odd Length Subarrays Leetcode Solution 189 680 Find the node with minimum value in a Binary Search Tree 189 681 Find the Distance Value Between Two Arrays Leetcode Solution 189 682 Longest Substring with At Least K Repeating Characters LeetCode Solution 189 683 Coin Change Problem 189 684 Partition Array Into Three Parts With Equal Sum Leetcode Solution 189 685 Convert a Number to Hexadecimal Leetcode Solution 189 686 Valid Palindrome 188 687 Merge Two Balanced Binary Search Trees 188 688 Unique Paths II Leetcode Solution 188 689 Print the Fibonacci numbers in reverse order 188 690 Inorder Successor of a node in Binary Tree 188 691 Find unique character in a string 188 692 Remove Invalid Parentheses Leetcode Solution 188 693 Longest Span with same Sum in two Binary arrays 187 694 Flipping an Image LeetCode Solution 187 695 Permutation Sequence LeetCode Solution 187 696 Rearrange an array in order – smallest, largest, 2nd smallest, 2nd largest 187 697 Generate all possible sorted arrays from alternate elements of two given sorted arrays 187 698 Find the Smallest Divisor given a Threshold Leetcode Solution 187 699 Path With Maximum Minimum Value LeetCode Solution 187 700 Largest subarray with equal number of 0s and 1s 187 701 Maximum Number of Coins You Can Get Leetcode Solution 187 702 Number of Dice Rolls With Target Sum LeetCode Solution 187 703 Find the largest multiple of 3 187 704 Dynamic Programming Basics 187 705 Best Time to Buy and Sell Stock with Cooldown Leetcode Solution 187 706 Find Leaves of Binary Tree LeetCode Solution 186 707 Numbers with prime frequencies greater than or equal to k 186 708 Count quadruples from four sorted arrays whose sum is equal to a given value x 186 709 BFS vs DFS for Binary Tree 186 710 To Lower Case Leetcode Solution 185 711 Reversing a Queue using Recursion 185 712 Keyboard Row Leetcode Solution 185 713 Binary Tree Maximum Path Sum LeetCode Solution 185 714 Check If Two String Arrays are Equivalent Leetcode Solution 185 715 Maximum 69 Number Leetcode Solution 185 716 Snakes and Ladders LeetCode Solution 185 717 Non-decreasing Array LeetCode Solution 185 718 Find whether an array is subset of another array 185 719 Bulb Switcher LeetCode Solution 185 720 Merge Two Binary Trees LeetCode Solution 184 721 Lucky Numbers in a Matrix Leetcode Solution 184 722 Rank Transform of an Array Leetcode Solution 184 723 Morris Traversal 184 724 Increasing Decreasing String Leetcode Solution 184 725 Majority Element II Leetcode Solution 184 726 Find if Path Exists in Graph Leetcode Solution 184 727 Valid Perfect Square Leetcode Solution 184 728 Edit Distance LeetCode Solution 184 729 Reverse Only Letters LeetCode Solution 184 730 Subset Sum Leetcode 184 731 Check If Array Pairs Are Divisible by k LeetCode Solution 184 732 Delete Nth node from the end of the given linked list 184 733 Maximum Profit in Job Scheduling Leetcode Solution 184 734 Queries for counts of array elements with values in given range 184 735 Race Car LeetCode Solution 183 736 Find Median from Data Stream LeetCode Solution 183 737 Valid Number 183 738 Sort Array by Increasing Frequency Leetcode Solution 183 739 Ugly Number Leetcode Solution 183 740 Recover Binary Search Tree 183 741 k-th missing element in increasing sequence which is not present in a given sequence 183 742 Populating Next Right Pointers in Each Node 183 743 Find Maximum Depth of Nested Parenthesis in a String 183 744 Binary Tree Zigzag Level Order Traversal LeetCode Solution 183 745 Elements to be added so that all elements of a range are present in array 183 746 Tiling Problem 183 747 Program for Bridge and Torch problem 182 748 Find All Duplicates in an Array LeetCode Solution 182 749 Student Attendance Record I Leetcode Solution 182 750 Largest Rectangle in Histogram LeetCode Solution 182 751 Base 7 Leetcode Solution 182 752 Minimum Cost For Tickets Leetcode Solution 182 753 Minimum Height Trees 182 754 Stack Permutations (Check if an array is stack permutation of other) 182 755 Best Meeting Point LeetCode Solution 182 756 Binary Tree zigzag level order Traversal 182 757 Merge Sorted Array LeetCode Solution 182 758 Factorial Trailing Zeroes Leetcode Solution 182 759 Add and Search Word – Data structure design LeetCode 182 760 Check if Two Expressions With Brackets are Same 182 761 Maximum Length of a Concatenated String with Unique Characters Leetcode Solution 182 762 Minimum Distance Between BST Nodes Leetcode Solution 181 763 Decompress Run-Length Encoded List Leetcode Solution 181 764 Total Numbers With no Repeated Digits in a Range 181 765 Construct BST from given Preorder Traversal 181 766 Perform String Shifts Leetcode 181 767 Remove brackets from an algebraic string containing + and – operators 181 768 Number of NGEs to the Right 181 769 Maximum Product of Three Numbers LeetCode Solution 181 770 Finding K closest element 181 771 Evaluate Reverse Polish Notation LeetCode Solution 181 772 Sorted Linked List to Balanced BST 180 773 Partition to K Equal Sum Subsets Leetcode Solution 180 774 Find All Possible Recipes from Given Supplies LeetCode Solution 180 775 Symmetric Tree Leetcode Solution 180 776 Check for Palindrome after every character replacement Query 180 777 Invert Binary Tree LeetCode Solution 180 778 String comparison containing wildcards 180 779 Balanced Expression with Replacement 180 780 Print a Binary Tree in Vertical Order 180 781 Maximum Nesting Depth of the Parentheses Leetcode Solution 180 782 N-Queens LeetCode Solution 180 783 Priority Queue using doubly linked list 179 784 Special Array With X Elements Greater Than or Equal X Leetcode Solution 179 785 Regular Expression Matching 179 786 Restore IP Addresses Leetcode Solution 179 787 Growable array based stack 179 788 Number of Days Between Two Dates LeetCode Solution 179 789 Form Minimum Number From Given Sequence 179 790 Hamming Distance Leetcode Solution 179 791 Word Pattern LeetCode Solution 179 792 Split a String in Balanced Strings Leetcode Solution 178 793 Nested List Weight Sum II LeetCode Solution 178 794 Binomial Coefficient 178 795 Remove Nth Node From End of List Leetcode Solution 178 796 Maximum Depth of N-ary Tree Leetcode Solution 178 797 Search in a Binary Search Tree Leetcode Solution 178 798 Top K Frequent Words LeetCode Solution 178 799 Minimize Maximum Pair Sum in Array LeetCode Solution 178 800 Merge K Sorted Linked Lists 178 801 Minimum sum of multiplications of n numbers 178 802 Jump Game 178 803 Brick Wall LeetCode Solution 178 804 Count items common to both the lists but with different prices 178 805 Identify and Mark Unmatched Parenthesis in an Expression 178 806 Queue based approach for first non-repeating character in a stream 178 807 Linked List Cycle 178 808 Search a 2D Matrix II Leetcode Solution 177 809 Number of Islands II LeetCode Solution 177 810 One Edit Distance LeetCode Solution 177 811 Largest rectangular sub-matrix whose sum is 0 177 812 Repeated Substring Pattern LeetCode Solution 177 813 Kth ancestor of a node in binary tree 177 814 Circular Queue 177 815 Relative Ranks Leetcode Solution 177 816 Minimum time required to rot all oranges 177 817 Diagonal Traversal of Binary Tree 176 818 Minimum Swaps to Make Strings Equal Leetcode Solution 176 819 Longest Subarray Having Count of 1s One More than Count of 0s 176 820 Course Schedule II – LeetCode 176 821 Final Prices With a Special Discount in a Shop Leetcode Solution 176 822 Given an Array of Pairs Find all Symmetric Pairs in it 176 823 Maximum Difference Between Increasing Elements LeetCode Solution 176 824 Transpose Graph 176 825 Minimum Time Visiting All Points Leetcode Solution 175 826 Sort Array By Parity II Leetcode Solution 175 827 Deletion in a Binary Tree 175 828 Nearest Exit from Entrance in Maze LeetCode Solution 175 829 Sort an array according to the order defined by another array 175 830 Check if stack elements are pairwise consecutive 175 831 Remove Duplicates from Sorted List LeetCode Solution 175 832 Minimum Jumps to Reach Home LeetCode Solution 174 833 Interval Tree 174 834 A Space Optimized DP solution for 0-1 Knapsack Problem 174 835 Insert Delete GetRandom 174 836 Design Browser History LeetCode Solution 174 837 Tree Traversal (Preorder, Inorder & Postorder) 174 838 Last Stone Weight II LeetCode Solution 174 839 Make Two Arrays Equal by Reversing Sub-arrays Leetcode Solution 174 840 Minimum number of jumps to reach end 173 841 LCS (Longest Common Subsequence) of three strings 173 842 Remove Duplicates from Sorted List II 173 843 Iterative Preorder Traversal 173 844 Subarray Product Less Than K LeetCode Solution 173 845 Missing Element in Sorted Array LeetCode Solution 173 846 Dividing Array into Pairs With Sum Divisible by K 173 847 Check if a given array can represent Preorder Traversal of Binary Search Tree 173 848 Minimum swaps to make sequences increasing 173 849 Find Maximum Sum Possible Equal Sum of Three Stacks 173 850 Minimum Number of Taps to Open to Water a Garden LeetCode Solution 173 851 Can Place Flowers LeetCode Solution 173 852 Check if an Array is Stack Sortable 172 853 Crawler Log Folder Leetcode Solution 172 854 An Interesting Method to generate Binary Numbers from 1 to n 172 855 Sum of nearest smaller and greater number 172 856 Reorder Data in Log Files LeetCode Solution 172 857 Number Complement Leetcode Solution 172 858 Valid Parentheses Leetcode Solution 172 859 Clone Graph LeetCode Solution 172 860 Maximum size subarray sum equals k 172 861 Subsequence of Size K With the Largest Even Sum LeetCode Solution 172 862 Find all permuted rows of a given row in a matrix 172 863 Alien Dictionary LeetCode Solution 172 864 Daily Temperatures Leetcode Solution 172 865 Binary Search Tree Search and Insertion 172 866 Best Time to Buy and Sell Stock with Transaction Fee Leetcode Solution 171 867 Check whether a given Binary Tree is Complete or not 171 868 Split Array Into Consecutive Subsequences 171 869 Brightest Position on Street LeetCode Solution 171 870 Partition List Leetcode Solution 171 871 Infix to Postfix 171 872 Find all triplets with zero sum 171 873 Level order Traversal in Spiral Form 171 874 Find the subarray with least average 171 875 Guess Number Higher or Lower LeetCode Solution 171 876 Minimum Sum Path in a Triangle 171 877 Water Bottles Leetcode Solution 171 878 Count ways to reach the nth stair using step 1, 2 or 3 170 879 Get Maximum in Generated Array Leetcode Solution 170 880 Sliding Window Maximum 170 881 Union and Intersection of two Linked Lists 170 882 Distinct adjacent elements in an array 170 883 Least Number of Unique Integers after K Removals Leetcode Solution 170 884 Sort Colors 170 885 Lexicographical Numbers Leetcode Solution 170 886 Friends Pairing Problem 170 887 Permutation Coefficient 170 888 Design a Stack With Increment Operation Leetcode Solution 170 889 Find the Only Repetitive Element Between 1 to N-1 169 890 Delete And Earn 169 891 Path with maximum average value 169 892 A program to check if a binary tree is BST or not 169 893 Maximum Score After Splitting a String Leetcode Solution 169 894 Convert BST to Min Heap 169 895 Diagonal Traverse LeetCode Solution 169 896 GCDs of given index ranges in an array 169 897 Sorted Array to Balanced BST 169 898 Subset with sum divisible by m 169 899 Spiral Matrix II Leetcode Solution 169 900 Robot Bounded In Circle LeetCode Solution 168 901 Iterative Postorder Traversal Using Two Stacks 168 902 Pattern Occurrences using Stack 168 903 Count Negative Numbers in a Sorted Matrix LeetCode Solution 168 904 Alien Dictionary 168 905 Rearrange Array such that arr[i] >= arr[j] if i is even and arr[i] <= arr[j] if i is odd and j < i 168 906 Time Based Key-Value Store LeetCode Solution 168 907 Lemonade Change Leetcode Solution 168 908 Sequences of given length where every element is more than or equal to twice of previous 168 909 Minesweeper LeetCode Solution 168 910 Range sum queries without updates 168 911 Range LCM Queries 168 912 All Unique Triplets that Sum up to a Given Value 168 913 Count Distinct Elements in Every Window of Size K 168 914 Analyze User Website Visit Pattern LeetCode Solution 167 915 Destination City Leetcode Solution 167 916 Find distance between two nodes of a Binary Tree 167 917 Find Common Characters Leetcode Solution 167 918 Binary array after M range toggle operations 167 919 Construct Complete Binary Tree from its Linked List Representation 167 920 Climbing stairs 167 921 Count Submatrices With All Ones LeetCode Solution 167 922 Diagonal Traversal LeetCode Solution 167 923 Three way partitioning of an array around a given range 167 924 My Calendar I LeetCode Solution 167 925 Queue using Stacks 167 926 Product of Array Except Self LeetCode Solution 167 927 Matrix Chain Multiplication 167 928 Number of Distinct Islands Leetcode Solution 167 929 Convert Sorted List to Binary Search Tree 166 930 Shortest Word Distance Leetcode Solution 166 931 Insert into a Binary Search Tree Leetcode Solution 166 932 Averages of Levels in Binary Tree 166 933 Construct the Rectangle Leetcode Solution 166 934 Guess Number Higher or Lower II 166 935 BFS for Disconnected Graph 165 936 Largest area rectangular sub-matrix with equal number of 1’s and 0’s 165 937 Difference Array | Range update query in O(1) 165 938 Check if the given array can represent Level Order Traversal of Binary Search Tree 165 939 Intersection of Two Linked Lists LeetCode Solution 165 940 Remove Duplicates from Sorted List II LeetCode Solution 165 941 Median of Two Sorted Arrays 165 942 Rearrange Spaces Between Words Leetcode Solution 165 943 Binary Tree Longest Consecutive Sequence LeetCode Solution 165 944 Construct BST from its given Level Order Traversal 165 945 Check if any two intervals overlap among a given set of intervals 164 946 Count Subarrays with Same Even and Odd Elements 164 947 Number of Equivalent Domino Pairs Leetcode Solution 164 948 Vertical sum in a given binary tree 164 949 Rearrange an Array Such that arr[i] is equal to i 164 950 Queries for GCD of all numbers of an array except elements in a given range 164 951 Unique Paths II 164 952 Set Matrix Zeroes Leetcode Solution 164 953 Minimum Height Trees LeetCode Solution 164 954 4Sum 164 955 K’th Largest Element in BST when modification to BST is not allowed 164 956 3 Sum 164 957 Maximum Product Subarray 163 958 Three Consecutive Odds Leetcode Solution 163 959 Spiral Matrix III LeetCode Solution 163 960 Create Maximum Number 163 961 Combination Sum IV LeetCode Solution 163 962 Special Positions in a Binary Matrix Leetcode Solution 163 963 Trim a Binary Search Tree 163 964 Merging Intervals 163 965 Count Primes in Ranges 163 966 Maximum Frequency Stack Leetcode Solution 163 967 Kth Smallest Element in a BST Leetcode Solution 163 968 Count subarrays where second highest lie before highest 162 969 Merge Two Sorted Lists Leetcode 162 970 Design Hit Counter LeetCode Solution 162 971 Depth First Search (DFS) for a Graph 162 972 Valid Boomerang Leetcode Solution 162 973 Breadth First Search (BFS) for a Graph 162 974 Number of palindromic paths in a matrix 161 975 Reverse Nodes in K-Group 161 976 Maximum Subarray Sum Excluding Certain Elements 161 977 Largest divisible pairs subset 161 978 Stone Game II Leetcode 161 979 Print Fibonacci sequence using 2 variables 161 980 Sign of the Product of an Array LeetCode Solution 161 981 Symmetric Tree 161 982 Can Make Arithmetic Progression From Sequence Leetcode Solution 161 983 Word Break 161 984 The Maze III LeetCode Solution 161 985 Find Maximum of Minimum for Every Window Size in a Given Array 161 986 Longest subsequence such that difference between adjacents is one 161 987 Maximize Sum of Array after K Negations Leetcode Solution 161 988 Palindrome Partitioning 161 989 Longest Nice Substring LeetCode Solution 161 990 K Closest Points to Origin Leetcode Solution 161 991 Strongly Connected Component 161 992 Count pair with Given Sum 161 993 Longest Palindromic Subsequence 161 994 Next Permutation Leetcode Solution 161 995 Kth Smallest Element in a Sorted Matrix LeetCode Solution 160 996 Largest Number Leetcode Solution 160 997 String Matching in an Array Leetcode Solution 160 998 Serialize and Deserialize Binary Tree 160 999 Palindrome Partitioning Leetcode Solution 160 1000 Find number of pairs in an array such that their XOR is 0 160 1001 Segment Tree 159 1002 Minimum Index Sum of Two Lists 159 1003 Length of Longest Fibonacci Subsequence 159 1004 Move all negative elements to end in order with extra space allowed 159 1005 Find the Difference Leetcode Solution 159 1006 Asteroid Collision LeetCode Solution 159 1007 Number Of Longest Increasing Subsequence 159 1008 Maximum Product of Indexes of Next Greater on Left and Right 159 1009 Count pairs from two sorted arrays whose sum is equal to a given value x 159 1010 Balanced Binary Tree 159 1011 Validate Binary Search Tree 159 1012 Height of a generic tree from parent array 158 1013 Maximum difference between frequency of two elements such that element having greater frequency is also greater 158 1014 Level Order Traversal of Binary Tree 158 1015 First missing positive 158 1016 Graph Valid Tree LeetCode Solution 158 1017 Binary Search Tree 158 1018 Maximum Length of Repeated Subarray 158 1019 Largest Substring Between Two Equal Characters Leetcode Solution 158 1020 K maximum sums of overlapping contiguous sub-arrays 158 1021 Shortest Completing Word Leetcode Solution 158 1022 Merge Sort 158 1023 Shuffle 2n integers as a1-b1-a2-b2-a3-b3-..bn without using extra space 158 1024 Consecutive Characters LeetCode Solution 158 1025 Find a Peak Element II LeetCode Solution 157 1026 Insertion in a Binary Tree 157 1027 Decrypt String from Alphabet to Integer Mapping Leetcode Solution 157 1028 Scramble String LeetCode Solution 157 1029 Available Captures for Rook Leetcode Solution 157 1030 Check If a Word Occurs As a Prefix of Any Word in a Sentence Leetcode Solution 157 1031 Find postorder traversal of BST from preorder traversal 157 1032 Boundary Traversal of binary tree 157 1033 Maximum Number of Ways to Partition an Array LeetCode Solution 157 1034 Invalid Transactions LeetCode Solution 157 1035 Find Duplicate Subtrees 157 1036 Collect maximum points in a grid using two traversals 157 1037 Generate Parentheses Leetcode Solution 157 1038 Compute nCr % p 157 1039 Newman-Conway Sequence 157 1040 Count minimum steps to get the given desired array 157 1041 Maximum subsequence sum such that no three are consecutive 156 1042 The Painter’s Partition Problem 156 1043 Determine Whether Matrix Can Be Obtained By Rotation LeetCode Solution 156 1044 Binary Search Tree Delete Operation 156 1045 Remove Duplicates from Sorted Array II Leetcode Solution 156 1046 Build an Array With Stack Operations Leetcode Solution 156 1047 Construct Binary Tree from given Parent Array representation 156 1048 Friends Of Appropriate Ages LeetCode Solution 156 1049 Next Greater Element III LeetCode Solution 156 1050 Ugly Numbers 155 1051 Rearrange array such that even positioned are greater than odd 155 1052 Find the First Circular Tour that visits all the Petrol Pumps 155 1053 Subarrays with K Different Integers Leetcode Solution 155 1054 Make The String Great Leetcode Solution 155 1055 Print Next Greater Number of Q queries 155 1056 Custom Sort String Leetcode Solution 155 1057 Iterative Depth First Traversal of Graph 155 1058 Maximum length subsequence with difference between adjacent elements as either 0 or 1 155 1059 Maximum weight transformation of a given string 155 1060 Advantages of BST over Hash Table 155 1061 Level order traversal using two Queues 155 1062 Maximum Sum of 3 Non-Overlapping Subarrays 155 1063 Rearrange an array such that ‘arr[j]’ becomes ‘i’ if ‘arr[i]’ is ‘j’ 155 1064 Defanging an IP Address LeetCode Solution 154 1065 Rearrange array such that even index elements are smaller and odd index elements are greater 154 1066 Construction of Longest Increasing Subsequence (N log N) 154 1067 Regular Expression Matching Regular Expression Matching LeetCode Solution 154 1068 Remove duplicates from sorted array 154 1069 Recover Binary Search Tree Leetcode Solution 154 1070 Double the first element and move zero to end 154 1071 Minimum Size Subarray Sum 153 1072 Populating Next Right Pointers in Each Node Leetcode Solution 153 1073 Morris Inorder Traversal 153 1074 Ugly Number II LeetCode Solution 153 1075 Partition Equal Subset Sum 153 1076 Super Ugly Number 153 1077 Boolean Parenthesization Problem 153 1078 Path Sum II LeetCode Solution 153 1079 Employee Importance LeetCode Solution 153 1080 Add two numbers 153 1081 Kill Process LeetCode Solution 153 1082 Palindrome Permutation LeetCode Solution 153 1083 Number of siblings of a given Node in n-ary Tree 152 1084 Remove Palindromic Subsequences Leetcode Solution 152 1085 Valid Tic-Tac-Toe State LeetCode Solution 152 1086 Binary Tree Right Side View LeetCode Solution 152 1087 Largest BST Subtree LeetCode Solution 152 1088 Palindromic Substrings Leetcode Solution 152 1089 Bitwise AND of Numbers Range LeetCode Solution 152 1090 Construct Binary Tree from Preorder and Postorder Traversal LeetCode Solution 152 1091 Implement Trie (Prefix Tree) Leetcode Solution 152 1092 Divisible Pairs Counting 152 1093 Find maximum difference between nearest left and right smaller elements 152 1094 Lowest Common Ancestor 151 1095 Print Right View of a Binary Tree 151 1096 Kth Smallest Product of Two Sorted Arrays LeetCode Solution 151 1097 Increasing Triplet Subsequence LeetCode Solution 151 1098 Search in Sorted Rotated Array 151 1099 Smallest Common Region Leetcode Solution 151 1100 Find whether a subarray is in form of a mountain or not 151 1101 Iterative method to find ancestors of a given binary tree 150 1102 Find Peak Element 150 1103 Find the minimum distance between two numbers 150 1104 Maximize Distance to Closest Person LeetCode Solution 150 1105 Number of Closed Islands Leetcode Solution 150 1106 Print all triplets in sorted array that form AP 149 1107 Find Smallest Range Containing Elements from k Lists 149 1108 Cells with Odd Values in a Matrix LeetCode Solution 149 1109 Bus Routes Leetcode Solution 149 1110 Binary Tree Data Structure 149 1111 Serialize and Deserialize Binary Tree LeetCode Solution 149 1112 Longest Bitonic Subsequence 149 1113 Distinct Subsequences 148 1114 Construct K Palindrome Strings LeetCode Solution 148 1115 Reformat The String Leetcode Solution 148 1116 Level of Each node in a Tree from source node 148 1117 Products of ranges in an array 148 1118 Find Three Element From Different Three Arrays Such That a + b + c = sum 148 1119 Minimum Absolute Difference in BST Leetcode Solution 148 1120 Number of Students Doing Homework at a Given Time Leetcode Solution 148 1121 Day of the Year Leetcode Solution 148 1122 Moser-de Bruijn Sequence 148 1123 Path Sum 148 1124 Longest Increasing Consecutive Subsequence 148 1125 Convert BST into a Min-Heap without using array 147 1126 Count Largest Group Leetcode Solution 147 1127 Clone a Binary Tree with Random Pointers 147 1128 Find Two Non-overlapping Sub-arrays Each With Target Sum LeetCode Solution 147 1129 Sum of Even Numbers After Queries 146 1130 Longest Subarray of 1’s After Deleting One Element LeetCode Solution 146 1131 Longest Repeated Subsequence 146 1132 Maximum Product Subarray 146 1133 Print modified array after executing the commands of addition and subtraction 146 1134 Mean of Array After Removing Some Elements Leetcode Solution 146 1135 Bottom View of a Binary Tree 146 1136 Closest Binary Search Tree Value Leetcode Solution 146 1137 Topological Sorting 146 1138 Root to Leaf path with target sum Leetcode Solutions 145 1139 Delete Nodes and Return Forest Leetcode Solution 145 1140 Find maximum length Snake sequence 145 1141 Priority Queue 145 1142 Search Insert Position 145 1143 Prime Palindrome LeetCode Solution 145 1144 Minimum Score Triangulation of Polygon Leetcode Solution 145 1145 Thousand Separator Leetcode Solution 145 1146 Third Maximum Number Leetcode Solution 145 1147 Queries for Number of Distinct Elements in a Subarray 145 1148 Compare Strings by Frequency of the Smallest Character Leetcode Solution 145 1149 Search an Element in Sorted Rotated Array 145 1150 Web Crawler LeetCode Solution 145 1151 Cutting a Rod 144 1152 Diameter of N-Ary Tree LeetCode Solution 144 1153 Minimum sum of squares of character counts in a given string after removing k characters 144 1154 Search Suggestions System LeetCode Solution 144 1155 Subset Sum Problem in O(sum) space 144 1156 Reformat Date LeetCode Solution 144 1157 Write Code to Determine if Two Trees are Identical 144 1158 Constant time range add operation on an array 144 1159 Count even length binary sequences with same sum of first and second half bits 144 1160 Rotate Array 144 1161 Maximum Depth Of Binary Tree 143 1162 Maximum Value at a Given Index in a Bounded Array LeetCode Solution 143 1163 Minimum Moves to Equal Array Elements LeetCode Solution 143 1164 Swap Nodes In Pairs 143 1165 Transform a BST to Greater sum Tree 143 1166 Maximum Product of Splitted Binary Tree LeetCode Solution 143 1167 Minimum Swaps To Make Sequences Increasing LeetCode Solution 143 1168 Golomb sequence 142 1169 Kth Smallest Number in Multiplication Table Leetcode Solution 142 1170 Maximize sum of consecutive differences in a circular array 142 1171 Minimum Cost to Move Chips to The Same Position LeetCode Solution 142 1172 Count Pairs Whose Products Exist in Array 142 1173 Decision Tree 142 1174 First Bad Version 142 1175 Decrease Elements To Make Array Zigzag LeetCode Solution 142 1176 Maximum number of segments of lengths a, b and c 142 1177 Sum of Left Leaves LeetCode Solution 141 1178 Remove Max Number of Edges to Keep Graph Fully Traversable Leetcode Solution 141 1179 Possible Bipartition LeetCode Solution 141 1180 Closest Leaf in a Binary Tree LeetCode Solution 141 1181 Find the smallest binary digit multiple of given number 141 1182 Replace two consecutive equal values with one greater 141 1183 Contiguous Array LeetCode Solution 141 1184 Merge two BSTs with limited extra space 141 1185 Check Array Formation Through Concatenation Leetcode Solution 141 1186 Red-Black Tree Introduction 141 1187 Valid Triangle Number 141 1188 Minimum Sideway Jumps LeetCode Solution 140 1189 Divide Two Integers Leetcode Solution 140 1190 Maximum Binary Tree 140 1191 Given a binary tree, how do you remove all the half nodes? 140 1192 Find Largest Value in Each Tree Row LeetCode Solution 140 1193 Find a sorted subsequence of size 3 in linear time 140 1194 Binary Tree to Binary Search Tree Conversion 140 1195 K’th Largest element in BST using constant extra space 140 1196 Matchsticks to Square Leetcode Solution 140 1197 Swapping Nodes in a Linked List Leetcode Solution 139 1198 Queue Reconstruction by Height 139 1199 Factorial Trailing Zeroes LeetCode Solution 139 1200 Reverse a Path in BST using Queue 139 1201 Path Crossing Leetcode Solution 139 1202 Number of Orders in the Backlog Leetcode Solution 139 1203 Concatenation of Array LeetCode Solution 139 1204 Flatten 2D Vector LeetCode Solution 138 1205 Convert Sorted Array to Binary Search Tree LeetCode Solutions 138 1206 Champagne Tower LeetCode Solution 138 1207 Valid Perfect Square LeetCode Solution 138 1208 How to print maximum number of A’s using given four keys 138 1209 Maximum sum bitonic subarray 138 1210 Perfect Squares LeetCode Solution 138 1211 Guess The Word 137 1212 Kth Smallest Element in a BST 137 1213 Array Queries for multiply replacements and product 137 1214 Convert Integer to the Sum of Two No-Zero Integers Leetcode Solution 136 1215 Maximum sum of a path in a Right Number Triangle 136 1216 Design Skiplist LeetCode Solution 136 1217 Maximum sum of pairs with specific difference 136 1218 Moving Stones Until Consecutive Leetcode Solution 136 1219 Range Queries for Longest Correct Bracket Subsequence 136 1220 Queries on Probability of Even or Odd Number in given Ranges 136 1221 Integer Break LeetCode Solution 136 1222 Print n terms of Newman-Conway Sequence 135 1223 Count Subsets Having Distinct Even Numbers 135 1224 Graph and its representation 135 1225 New 21 Game 135 1226 Lowest Common Ancestor in Binary Search Tree 135 1227 Missing Number 135 1228 Sliding Window Median Leetcode Solution 135 1229 Lowest Common Ancestor of a Binary Tree Leetcode Solution 135 1230 LRU Cache Leetcode Solution 135 1231 Largest Plus Sign Leetcode Solution 135 1232 Filter Restaurants by Vegan-Friendly, Price and Distance Leetcode Solution 134 1233 The kth Factor of n Leetcode Solution 134 1234 Arithmetic Slices II – Subsequence LeetCode Solution 134 1235 BST to a Tree with Sum of all Smaller Keys 134 1236 Longest Common Prefix Using Word by Word Matching 134 1237 Find minimum number of merge operations to make an array palindrome 134 1238 Range Sum Query using Sparse Table 134 1239 Minimum Remove to Make Valid Parentheses LeetCode Solution 133 1240 Maximum Array from Two given Arrays Keeping Order Same 133 1241 Print modified array after multiple array range increment operations 133 1242 Maximum Sum Increasing Subsequence 133 1243 Maximum Product Subarray 133 1244 Check if all levels of two Binary Tree are anagrams or not 133 1245 Find Minimum in Rotated Sorted Array II LeetCode Solution 133 1246 Write a function to get the intersection point of two Linked Lists 132 1247 Mean of range in array 132 1248 Power of Two 132 1249 Merge k Sorted Lists Leetcode Solution 132 1250 Bold Words in String LeetCode Solution 132 1251 Contiguous Array 132 1252 Graph Cloning 132 1253 Maximize Elements Using Another Array 131 1254 Find k-th smallest element in BST (Order Statistics in BST) 131 1255 Check in binary array the number represented by a subarray is odd or even 130 1256 Check for Identical BSTs without building the trees 130 1257 Parallel Courses II LeetCode Solution 130 1258 Different Ways to Add Parentheses Leetcode Solution 130 1259 Minimum Time to Collect All Apples in a Tree LeetCode Solution 130 1260 Min Cost Climbing Stairs LeetCode Solution 130 1261 Check Completeness of a Binary Tree LeetCode Solution 130 1262 Symmetric Tree LeetCode Solution Leetcode Solution 129 1263 Check if each internal node of a BST has exactly one child 129 1264 Image Overlap LeetCode Solution 129 1265 Excel Sheet Column Title LeetCode Solution 129 1266 Print Ancestors of a Given Binary Tree Node Without Recursion 128 1267 Smallest Range II Leetcode Solution 128 1268 Check if two nodes are on the same path in a Tree 128 1269 Verify Preorder Serialization of a Binary Tree 128 1270 Merge Sorted Array 128 1271 Next greater element 127 1272 Orderly Queue LeetCode Solution 127 1273 Arranging Coins Leetcode Solution 125 1274 Vertical Order Traversal of Binary Tree LeetCode Solution 125 1275 Koko Eating Bananas LeetCode Solution 125 1276 Count and Toggle Queries on a Binary Array 124 1277 Palindrome Partitioning 124 1278 Check If a String Can Break Another String Leetcode Solution 124 1279 Largest Submatrix With Rearrangements LeetCode Solution 124 1280 Number of elements less than or equal to a given number in a given subarray 124 1281 Add Two Numbers II Leetcode Solution 122 1282 Palindrome Number LeetCode Solution 122 1283 Longest Substring Without Repeating Characters Leetcode Solution 122 1284 Find the Winner of the Circular Game LeetCode Solution 122 1285 Maximum product of an increasing subsequence 122 1286 Array Nesting Leetcode Solution 122 1287 Range Minimum Query (Square Root Decomposition and Sparse Table) 121 1288 Check if X can give change to every person in the Queue 121 1289 Find maximum average subarray of k length 121 1290 Insert Delete GetRandom O(1) Leetcode Solution 121 1291 Newman–Shanks–Williams prime 121 1292 Peeking Iterator LeetCode Solution 121 1293 Queries for Decimal Values of Subarrays of a Binary Array 120 1294 Continuous Subarray Sum LeetCode Solution 119 1295 Check given array of size n can represent BST of n levels or not 118 1296 Encoded String With Shortest Length LeetCode Solution 118 1297 Reach a Number LeetCode Solution 117 1298 Number of Subsequences That Satisfy the Given Sum Condition LeetCode solution 117 1299 Minimum Possible Integer After at Most K Adjacent Swaps On Digits LeetCode Solution 116 1300 Random Pick Index LeetCode Solution 116 1301 Minimum Number of People to Teach LeetCode Solution 116 1302 Jump Game IV LeetCode Solution 115 1303 Convert to Base -2 LeetCode Solution 115 1304 Binary Tree to Binary Search Tree Conversion using STL set 115 1305 Convert a BST to a Binary Tree such that sum of all greater keys is added to every key 115 1306 Number of indexes with equal elements in given range 115 1307 Design Underground System Leetcode Solution 113 1308 Minimum Total Space Wasted With K Resizing Operations LeetCode Solution 113 1309 Queries on XOR of greatest odd divisor of the range 112 1310 Design A Leaderboard Leetcode Solution 110 1311 Shifting Letters LeetCode Solution 109 1312 Print Maximum Length Chain of Pairs 108 1313 Top K Frequent Elements LeetCode Solution 107 1314 Detect Capital Leetcode Solution 107 1315 Minimum Swaps to Group All 1’s Together Leetcode Solution 106 1316 Count Sub Islands LeetCode Solution 105 1317 Minimum Path Sum Leetcode Solution 104 1318 Substring with Concatenation of All Words Leetcode Solution 103 1319 Monotonic Array Leetcode Solution 102 1320 Odd Even Linked List Leetcode Solution 102 1321 Decode String Leetcode Solution 100 1322 Binary Tree Inorder Traversal LeetCode Solution 98 1323 Maximum Population Year LeetCode Solution 98 1324 Longest Common Subsequence LeetCode Solution 97 1325 Find the Town Judge LeetCode Solution 97 1326 Shortest Unsorted Continuous Subarray LeetCode Solution 93 1327 Best Meeting Point LeetCode Solution 93 1328 Find the Town Judge LeetCode Solution 91 1329 Rectangle Overlap LeetCode Solution 90 1330 Maximum Population Year LeetCode Solution 88 1331 Sum Root to Leaf Numbers LeetCode Solution 88 1332 Flatten Binary Tree to Linked List LeetCode Solution 88 1333 Valid Triangle Number LeetCode Solution 86 1334 Design Add and Search Words Data Structure LeetCode Solution 86 1335 Stone Game IV LeetCode Solution 85 1336 Insert into a Sorted Circular Linked List LeetCode Solution 85 1337 Reveal Cards In Increasing Order Leetcode Solution 84 1338 Is Graph Bipartite? LeetCode Solution 84 1339 Score of Parenthesis LeetCode Solution 83 1340 Range Sum Query 2D – Immutable LeetCode Solution 81 1341 Divide Chocolate LeetCode Solution 76 1342 Step-By-Step Directions From a Binary Tree Node to Another LeetCode Solution 71 1343 Range Sum of BST LeetCode Solution 67 1344 Find K Closest Elements LeetCode Solution 63 1345 Reverse Integer Leetcode Solution 63 1346 Rotate String LeetCode Solution 61 1347 Maximum Side Length of a Square with Sum Less than or Equal to Threshold LeetCode Solution 60 1348 Sort Colors LeetCode Solution 59 1349 Excel Sheet Column Number LeetCode Solution 55 1350 Maximum Size Subarray Sum Equals k Leetcode Solution 48 1351 Most Stones Removed with Same Row or Column LeetCode Solution 42 1352 Valid Anagram Leetcode Solution 42 1353 Camelcase Matching Leetcode Solution 42 1354 H-Index Leetcode Solution 41 1355 Group Anagrams LeetCode Solution 40 1356 High Five LeetCode Solution 40 1357 Next Permutation LeetCode Solution 39 1358 Sliding Window Maximum LeetCode Solution 38 1359 Binary Search LeetCode Solution 37 1360 Container With Most Water LeetCode Solution 37 1361 Find Peak Element LeetCode Solution 37 1362 Pairs of Songs With Total Durations Divisible by 60 LeetCode Solution 35 1363 Flatten Binary Tree to Linked List LeetCode Solution 34 1364 Paint House LeetCode Solution 34 1365 Valid Triangle Number LeetCode Solution 34 1366 Next Greater Element I Leetcode Solution 33 1367 Minimum Number of Arrows to Burst Balloons LeetCode Solution 32 1368 Sentence Screen Fitting LeetCode Solution 32 1369 Count Good Nodes in Binary Tree LeetCode Solution 32 1370 Isomorphic Strings LeetCode Solution 31 1371 Insert Delete GetRandom O(1) – Duplicates allowed LeetCode Solution 30 1372 The Number of Weak Characters in the Game LeetCode Solution 29 1373 Closest Binary Search Tree Value II LeetCode Solution 29 1374 Peak Index in a Mountain Array LeetCode Solution 29 1375 Group Shifted Strings Leetcode Solution 29 1376 Swim in Rising Water LeetCode Solution 28 1377 Unique Binary Search Trees LeetCode Solution 28 1378 Split Linked List in Parts Leetcode Solution 26 1379 Validate Stack Sequences LeetCode Solution 26 1380 Best Time to Buy and Sell Stock IV LeetCode Solution 24 1381 Greatest Sum Divisible by Three LeetCode Solution 24 1382 All Possible Full Binary Trees LeetCode Solution 23 1383 Single Element in a Sorted Array LeetCode Solution 23 1384 Lowest Common Ancestor of a Binary Search Tree Leetcode Solution 22 1385 Implement Rand10() Using Rand7() Leetcode Solution 22 1386 Implement strStr() LeetCode Solution 22 1387 Break a Palindrome LeetCode Solution 21 1388 Max Sum of Two Non-Overlapping Subarrays LeetCode Solution 21 1389 Trapping Rain Water II LeetCode Solution 21 1390 Stone Game IV LeetCode Solution 20 1391 Minimum Increment to Make Array Unique Leetcode Solution 20 1392 Contains Duplicate LeetCode Solution 20 1393 Remove All Ones With Row and Column Flips Leetcode Solution 19 1394 Find First and Last Position of Element in Sorted Array LeetCode Solution 18 1395 Detect Squares LeetCode Solution 18 1396 Reverse Nodes in k-Group LeetCode Solution 16 1397 Fibonacci Number LeetCode Solution 16 1398 Design Bounded Blocking Queue LeetCode Solution 15 1399 Minimum Number of Operations to Move All Balls to Each Box LeetCode Solution 15 1400 Total Hamming Distance LeetCode Solution 12

How do you count consecutive characters in a string in Python?

Given a String, extract all the K-length consecutive characters. Input : test_str = 'geekforgeeeksss is bbbest forrr geeks', K = 3 Output : ['eee', 'sss', 'bbb', 'rrr'] Explanation : K length consecutive strings extracted.

How do you check if there are consecutive characters in a string?

The task is to check if the string contains consecutive letters and each letter occurs exactly once..
Sort the given string in ascending order..
Check if s[i]-s[i-1]==1, for every index i from 1 to n-1..
If the condition holds for every index, print “Yes”, else print “No”..

How do you find consecutive repeated words in a string in Python?

Given a substring K, the task is to write a Python Program to find the repetition of K string in each consecutive occurrence of K..
Example..
Method 1: Using split() + count() + list comprehension..
Output:.
Time Complexity: O(n).
Space Complexity: O(n).
Method 2: Using findall() + regex + len().
Output:.
Time Complexity: O(n).

How do you count consecutive values in Python?

“count consecutive values in python” Code Answer's.
#count consecutif 1 in list. list exemple l=['1','1','0','1','0','1,'1',1'].
cpt=0..
compte=[].
for i in ch:.
if i=='1':.
cpt +=1..
compte. append(cpt).