VOOZH about

URL: https://www.geeksforgeeks.org/dsa/first-uppercase-letter-in-a-string-iterative-and-recursive/

⇱ First uppercase letter in a string (Iterative and Recursive) - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

First uppercase letter in a string (Iterative and Recursive)

Last Updated : 9 Dec, 2022

Given a string find its first uppercase letter
Examples : 

Input : geeksforgeeKs
Output : K

Input : geekS
Output : S

Method 1: linear search 
Using linear search, find the first character which is capital 
 

Output: 

G

Time Complexity : O(N)

Auxiliary Space: O(1)

Method 2 (Using recursion) 
Recursively traverse the string and if any uppercase is found return that character 

Output : 

G 

Time Complexity : O(N)

Auxiliary Space: O(N) for call stack

Comment
Article Tags: