Register for our webinar

### How to Nail your next Technical Interview

1 hour
1
Enter details
2
Select webinar slot
*Invalid Name
*Invalid Name
Step 1
Step 2
Congratulations!
You have registered for our webinar
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
*All webinar slots are in the Asia/Kolkata timezone
Step 1
Step 2
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.

## You may be missing out on a 66.5% salary hike*

### Nick Camilleri

Head of Career Skills Development & Coaching
*Based on past data of successful IK students
Help us know you better!

## How many years of coding experience do you have?

Oops! Something went wrong while submitting the form.

## FREE course on 'Sorting Algorithms' by Omkar Deshpande (Stanford PhD, Head of Curriculum, IK)

Oops! Something went wrong while submitting the form.

# Number of Paths In a Matrix Problem

Consider a maze mapped to a matrix with the upper left corner at coordinates (row, column) = (0, 0). You can only move towards the right or down from a cell. Determine the number of distinct paths through the maze. You must always start from the top-left position (0, 0) and end at the bottom-right (n-1, m-1)

For example, consider the following diagram where “1” indicates an open cell and “0” indicates a blocked cell. You can only travel through open cells, so no path can go through the cell (0, 2)

There are two possible paths from cell (0, 0) to cell (1, 3) in this matrix. Complete the function numberOfPaths, such that function returns the number of paths through the matrix, modulo (10^9 + 7).

Here are a couple of examples to get you started:

Example One

``````
Input:
3
4
1 1 1 1
1 1 1 1
1 1 1 1
``````
``````
Output: 10
``````

There are 10 possible paths from cell (0, 0) to cell (2, 3).

Example Two

``````
Input:
2
2
1 1
0 1
``````
``````
Output: 1
``````

There is one possible path from cell (0, 0) to cell (1, 1).

Notes:

Input Parameters: The function contains a single argument — a two-dimensional integer array called “matrix.”

Output: Return an integer — the number of possible paths from (0, 0) to (n-1, m-1).

Constraints:

• 1 <= n*m <= 2*10^6
• Each cell, matrix[i][j], contains 1, indicating it is accessible, or 0, indicating it is not accessible, where 0<=i<n and 0<=j<m

Solution 1: Brute Force (brute_force_solution.java)

We have a matrix with n rows and m columns, where each cell, matrix[A][B], denotes whether it is accessible or not.

We will use recursion to solve this problem.

We know that the number of ways to reach a cell is the sum of the number of ways to reach the cell to its left and the number of ways to reach the cell above it. Therefore:

No. of ways to reach matrix[i][j] =
No. of ways to reach matrix[i-1][j] + No. of ways to reach matrix[i][j-1]

This is because we can only go right or downward from any cell.

Now, we start from a cell and perform recursion to find the number of ways to reach cell (n-1, m-1):

recur(matrix, n-1, m-1) = recur(matrix, n-2, m-1) + recur(matrix, n-1, m-2)

For each cell, we will check if it is accessible or not. If it is not, we simply return 0, as there is no way to reach it. The base condition would be that if cell (0,0) is accessible, then the number of ways to reach it is 1.

Time Complexity:

O(2^(rows+columns))

In each recursion step, we will either reduce n by 1 or m by 1. Hence, the recurrence relation will be:

T(n + m) = T(n - 1 + m) + T(n + m - 1) + O(1)

T(n + m) = 2 * T(n - 1 + m) + O(1)

Therefore, it is O(2^(n+m)).

Auxiliary Space Used:

O(rows+columns)

We do not create any auxiliary array for the solution. We use recursion, which uses O(rows+columns) stack space as the maximum steps can be rows+columns at a time.

Space Complexity:

O(rows*columns)

Input takes O(rows*columns) space, the auxiliary space used is O(rows+columns), and the output takes O(1). Summing these up, we get O(rows*columns).

``````
// -------- START --------
public static int numberOfPaths(List> matrix){
int n = matrix.size(), m = matrix.get(0).size(), MOD = 1000000007;
int ans = recur(matrix, n-1, m-1, MOD);
return ans;
}

public static int recur(List> matrix, int n, int m, int MOD) {
int ans = 0;
//stopping condition
if(n<0 || m<0) {
return 0;
}
//if a cell is restricted, there are 0 ways to reach there.
if(matrix.get(n).get(m)==0) {
return 0;
}
//base condition: if cell (0,0) is accessible, we have 1 way to reach it.
if(n==0 && m==0) {
return 1;
}
/*number of ways to reach cell
a[i][j] = number of ways to reach cell a[i-1][j] + number of ways to reach cell a[i][j-1]*/
ans += (recur(matrix, n-1, m, MOD) + recur(matrix, n, m-1, MOD))%MOD;
return ans;
}
// -------- END --------
``````

Solution 2: Optimal Solution Using Dynamic Programming (optimal_solution.java)

We have a matrix with n rows and m columns, where each cell, matrix[A][B], denotes whether it is accessible or not.

Solution 1 (recursive) was exponential. We are visiting multiple states over and over, and then recursing for them, which we can surely avoid. To avoid revisiting states that have already been visited, we can store them in a dp array, so that they can be accessed as and when needed. This approach is known as Dynamic Programming.

Here’s how we do it:

1. We know that for any cell (i, j), the number of paths to reach it would be the number of paths to reach cell (i-1, j) + the number of paths to reach cell (i, j-1).
2. For any accessible cell matrix[i][j], we maintain the count of number of paths to reach this cell in a separate two-dimensional array dp[i][j], where dp[i][j] = dp[i-1][j] + dp[i][j-1], given that cell (i, j) is accessible.
3. We return the value of dp[i][j] as the answer.

Time Complexity:

O(n*m), considering the number of rows is n and columns is m.

We traverse the entire array matrix once and simultaneously traverse the dp array to keep the number of ways to reach that cell from cell (0,0). So, we travel both arrays at most once, and hence, the time complexity is O(n*m).

Auxiliary Space Used:

O(n*m), considering the number of rows is n and columns is m

We create a two-dimensional array dp of size n*m to store the number of paths from cell (0,0) to the current cell. Hence, the auxiliary space used is O(n*m).

Space Complexity:

O(n*m), considering the number of rows is n and columns is m

#### Input complexity is O(n*m), auxiliary space used is O(n*m), and output space complexity is O(1). Hence, total complexity will be O(n*m).

``````
// -------- START --------
public static int numberOfPaths(List> matrix){
int n = matrix.size(), m = matrix.get(0).size(), MOD = 1000000007;
if(matrix.get(0).get(0)== 0 || matrix.get(n-1).get(m-1)==0) {
return 0;
}
int[][] dp = new int[n][m];
//if cell (0,0) is accessible, number of ways to reach it is 1
dp[0][0] = 1;
//filling for the cells in first row.
for(int i = 1; i < m ;i++){
if(matrix.get(0).get(i)==1 && dp[0][i-1] == 1){
dp[0][i] = 1;
}
}
//filling for the cells in the first column
for(int i = 1; i < n ;i++){
if(matrix.get(i).get(0)==1 && dp[i-1][0] == 1){
dp[i][0] = 1;
}
}
/*number of ways to reach
cell(i,j) = number of ways to reach cell(i-1,j) + number of ways to reach cell (i,j-1)*/
for(int i = 1; i < n; i++){
for(int j = 1; j``````

### `Try yourself in the Editor`

`Note: Input and Output will already be taken care of.`

# `Number of Paths In a Matrix Problem`

`Consider a maze mapped to a matrix with the upper left corner at coordinates (row, column) = (0, 0). You can only move towards the right or down from a cell. Determine the number of distinct paths through the maze. You must always start from the top-left position (0, 0) and end at the bottom-right (n-1, m-1). `

`For example, consider the following diagram where “1” indicates an open cell and “0” indicates a blocked cell. You can only travel through open cells, so no path can go through the cell (0, 2). `

`There are two possible paths from cell (0, 0) to cell (1, 3) in this matrix. Complete the function numberOfPaths, such that function returns the number of paths through the matrix, modulo (10^9 + 7).`

`Here are a couple of examples to get you started:`

`Example One`

``````
Input:
3
4
1 1 1 1
1 1 1 1
1 1 1 1
``````
``````
Output: 10
``````

`There are 10 possible paths from cell (0, 0) to cell (2, 3).`

`Example Two`

``````
Input:
2
2
1 1
0 1
``````
``````
Output: 1
``````

`There is one possible path from cell (0, 0) to cell (1, 1).`

`Notes:`

`Input Parameters: The function contains a single argument — a two-dimensional integer array called “matrix.”`

`Output: Return an integer — the number of possible paths from (0, 0) to (n-1, m-1).`

`Constraints:`

• `1 <= n*m <= 2*10^6`
• `Each cell, matrix[i][j], contains 1, indicating it is accessible, or 0, indicating it is not accessible, where 0<=i<n and 0<=j<m`

`‍Solution 1: Brute Force (brute_force_solution.java)`

`We have a matrix with n rows and m columns, where each cell, matrix[A][B], denotes whether it is accessible or not.`

`We will use recursion to solve this problem.`

`We know that the number of ways to reach a cell is the sum of the number of ways to reach the cell to its left and the number of ways to reach the cell above it. Therefore:`

`No. of ways to reach matrix[i][j] = No. of ways to reach matrix[i-1][j] + No. of ways to reach matrix[i][j-1]`

`This is because we can only go right or downward from any cell.`

`Now, we start from a cell and perform recursion to find the number of ways to reach cell (n-1, m-1): `

`recur(matrix, n-1, m-1) = recur(matrix, n-2, m-1) + recur(matrix, n-1, m-2)`

`For each cell, we will check if it is accessible or not. If it is not, we simply return 0, as there is no way to reach it. The base condition would be that if cell (0,0) is accessible, then the number of ways to reach it is 1.`

`Time Complexity:`

`O(2^(rows+columns))`

`In each recursion step, we will either reduce n by 1 or m by 1. Hence, the recurrence relation will be:`

`T(n + m) = T(n - 1 + m) + T(n + m - 1) + O(1)`

`T(n + m) = 2 * T(n - 1 + m) + O(1)`

`Therefore, it is O(2^(n+m)).`

`Auxiliary Space Used:`

`O(rows+columns)`

`We do not create any auxiliary array for the solution. We use recursion, which uses O(rows+columns) stack space as the maximum steps can be rows+columns at a time.`

`Space Complexity:`

`O(rows*columns)`

`Input takes O(rows*columns) space, the auxiliary space used is O(rows+columns), and the output takes O(1). Summing these up, we get O(rows*columns).`

``````
// -------- START --------
public static int numberOfPaths(List> matrix){
int n = matrix.size(), m = matrix.get(0).size(), MOD = 1000000007;
int ans = recur(matrix, n-1, m-1, MOD);
return ans;
}

public static int recur(List> matrix, int n, int m, int MOD) {
int ans = 0;
//stopping condition
if(n<0 || m<0) {
return 0;
}
//if a cell is restricted, there are 0 ways to reach there.
if(matrix.get(n).get(m)==0) {
return 0;
}
//base condition: if cell (0,0) is accessible, we have 1 way to reach it.
if(n==0 && m==0) {
return 1;
}
/*number of ways to reach cell
a[i][j] = number of ways to reach cell a[i-1][j] + number of ways to reach cell a[i][j-1]*/
ans += (recur(matrix, n-1, m, MOD) + recur(matrix, n, m-1, MOD))%MOD;
return ans;
}
// -------- END --------
``````

`Solution 2: Optimal Solution Using Dynamic Programming (optimal_solution.java)`

`We have a matrix with n rows and m columns, where each cell, matrix[A][B], denotes whether it is accessible or not. `

`Solution 1 (recursive) was exponential. We are visiting multiple states over and over, and then recursing for them, which we can surely avoid. To avoid revisiting states that have already been visited, we can store them in a dp array, so that they can be accessed as and when needed. This approach is known as Dynamic Programming.`

`Here’s how we do it:`

1. `We know that for any cell (i, j), the number of paths to reach it would be the number of paths to reach cell (i-1, j) + the number of paths to reach cell (i, j-1).`
2. `For any accessible cell matrix[i][j], we maintain the count of number of paths to reach this cell in a separate two-dimensional array dp[i][j], where dp[i][j] = dp[i-1][j] + dp[i][j-1], given that cell (i, j) is accessible.`
3. `We return the value of dp[i][j] as the answer.`

`Time Complexity:`

`O(n*m), considering the number of rows is n and columns is m.`

`We traverse the entire array matrix once and simultaneously traverse the dp array to keep the number of ways to reach that cell from cell (0,0). So, we travel both arrays at most once, and hence, the time complexity is O(n*m).`

`Auxiliary Space Used:`

`O(n*m), considering the number of rows is n and columns is m. `

`We create a two-dimensional array dp of size n*m to store the number of paths from cell (0,0) to the current cell. Hence, the auxiliary space used is O(n*m).`

`Space Complexity:`

`O(n*m), considering the number of rows is n and columns is m. `

#### `Input complexity is O(n*m), auxiliary space used is O(n*m), and output space complexity is O(1). Hence, total complexity will be O(n*m).`

``````
// -------- START --------
public static int numberOfPaths(List> matrix){
int n = matrix.size(), m = matrix.get(0).size(), MOD = 1000000007;
if(matrix.get(0).get(0)== 0 || matrix.get(n-1).get(m-1)==0) {
return 0;
}
int[][] dp = new int[n][m];
//if cell (0,0) is accessible, number of ways to reach it is 1
dp[0][0] = 1;
//filling for the cells in first row.
for(int i = 1; i < m ;i++){
if(matrix.get(0).get(i)==1 && dp[0][i-1] == 1){
dp[0][i] = 1;
}
}
//filling for the cells in the first column
for(int i = 1; i < n ;i++){
if(matrix.get(i).get(0)==1 && dp[i-1][0] == 1){
dp[i][0] = 1;
}
}
/*number of ways to reach
cell(i,j) = number of ways to reach cell(i-1,j) + number of ways to reach cell (i,j-1)*/
for(int i = 1; i < n; i++){
for(int j = 1; j``````

## `Worried About Failing Tech Interviews?`

`Attend our free webinar to amp up your career and get the salary you deserve.`

`Hosted ByRyan VallesFounder, Interview Kickstart`
`Accelerate your Interview prep with Tier-1 tech instructors`
`360° courses that have helped 14,000+ tech professionals`
`100% money-back guarantee*`
`Register for Webinar`

#### `Recommended Posts`

`Closest Values In A BST Problem`
`Add Two Numbers Represented By Lists Problem`
`Add Binary Strings Problem`
`All Posts`
``` if(performance.navigation.type == 2) {location.reload(true);} const utmurl = new URL(window.location.href); const leadType = utmurl.searchParams.get('leadtype'); let short_url = window.location.pathname; let full_url = window.location.href; let hashcode = short_url.substring(short_url.indexOf('/su/') + 4); let host_name = window.location.hostname + "/su/"; let api_url = "https://uplevel.interviewkickstart.com/api/v1/shorten_url/"+hashcode; var webinarType,webinarUI,isSwitchUp="No",useEffect="No"; if(full_url.indexOf(host_name) != -1){ var xhr = new XMLHttpRequest(); xhr.open('GET',api_url,true); xhr.setRequestHeader("X-Api-Key","gEgBhrCG.K8GNtHzbd81hUggTIrDoWgQtbu1w092L"); xhr.onload = function(){ if(this.status == 200){ location.href = JSON.parse(this.response).long_url; }else{ location.href = "https://"+window.location.hostname; } } xhr.onerror = function(){ location.href = "https://"+window.location.hostname; } xhr.send(full_url); } var singlesignup,bcExitIntentOnBrowserTab="true"; var registration_type="calendly"; var utz, v_region, visitor_id,int_phone,v_country="",v_ip="",v_city="",v_ccode="",v_timezone="", //v_timezone=Intl.DateTimeFormat().resolvedOptions().timeZone, iksite_url=window.location.hostname; \$.getJSON("https://get.geojs.io/v1/ip/geo.json", function(t) {}).done(function(t) { v_timezone = t.timezone; }).fail(function(t) {}); var webinarScheduleIndia = [ {"date": "02/19/2024","time": "06:00:00 PM"}, {"date": "02/20/2024","time": "06:00:00 PM"}, {"date": "02/21/2024","time": "06:00:00 PM"}, {"date": "02/22/2024","time": "06:00:00 PM"}, {"date": "02/23/2024","time": "06:00:00 PM"}, {"date": "02/24/2024","time": "11:00:00 AM"}, {"date": "02/26/2024","time": "06:00:00 PM"}, {"date": "02/27/2024","time": "06:00:00 PM"}, {"date": "02/28/2024","time": "06:00:00 PM"}, {"date": "02/29/2024","time": "06:00:00 PM"}, ]; var webinarScheduleUSA = [ {"date": "02/19/2024","time": "07:30:00 PM"}, {"date": "02/20/2024","time": "08:30:00 PM"}, {"date": "02/21/2024","time": "07:30:00 PM"}, {"date": "02/22/2024","time": "08:30:00 PM"}, {"date": "02/23/2024","time": "07:30:00 PM"}, {"date": "02/25/2024","time": "08:30:00 PM"}, {"date": "02/26/2024","time": "07:30:00 PM"}, {"date": "02/27/2024","time": "08:30:00 PM"}, {"date": "02/28/2024","time": "07:30:00 PM"}, {"date": "02/29/2024","time": "08:30:00 PM"}, ]; \$(document).ready(function(){ \$('.stats__enrolled-engineers').text("17,000+"); \$('.stats__salary-hike-range').text("\$75K - \$200K"); \$('.stats__years-of-traning').text("7"); \$('.stats__highest-offers').text("18"); \$('.stats__instructors').text("500+"); \$('.stats__highest-compensation').text("\$1.2M"); setHiddenFields(); let gs_params = getAllUrlParams(); if(gs_params['gh_jid'] == "4017713004"){ \$('.sendinblue').css("max-width","100%"); } if(gs_params['utm_source'] == "tldr"){ \$('.text-block-9').html("You've unlocked free access to the 'Sorting Algorithms' course, worth \$399. Stay tuned for an email with instructions to login and get started."); \$('.text-block-9').css("font-size","16px"); \$('.text-block-9').css("text-align","center"); } \$("input[name='years-of-experience']").change(function(){ setHiddenFields(); dataLayer.push({ 'event': 'on_page_coding_survey', 'eventCategory': 'on_page_coding_survey', 'eventAction': 'select_option', 'eventLabel': \$(this).val() }); \$('.coding-experience-experiment').submit(); setCookie("coding-experience-experiment","True"); setTimeout(function(){ \$(".webinar__lightbox-card").css("display","flex"); \$(".webinar__lightbox-coding-exp").css("display","none"); \$(".webinar__lightbox").css("display","none"); }, 500); }); \$('.webinar-lightbox-coding-survey-close').click(function(){ \$(".webinar__lightbox-card").css("display","flex"); \$(".webinar__lightbox-coding-exp").css("display","none"); \$(".webinar__lightbox").css("display","none"); dataLayer.push({ 'event': 'on_page_coding_survey', 'eventCategory': 'on_page_coding_survey', 'eventAction': 'close', 'eventLabel': 'close' }); }); //GEOJS const t = new Date(); var e = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; if (1 <= t.getDate() && t.getDate() <= 15) { \$(".cohort-month").html(e[t.getMonth()] + " " + t.getFullYear()); \$(".cohort-month-full").html(e[t.getMonth() - 1] + " " + t.getFullYear()); } else { \$(".cohort-month").html(e[t.getMonth() + 1] + " " + t.getFullYear()); \$(".cohort-month-full").html(e[t.getMonth()] + " " + t.getFullYear()); } \$('.calendly-popup, .direct-link, .btn-webinar-popup, .lpv5-home-form, .calendly-link-widget').click(function(){ var getUtmParam = getAllUrlParams(); if(v_timezone_formatted == "Asia/Kolkata" && v_country=="India"){ webinarType = "REGULAR" } if(webinarType == "SWITCH_UP"){ \$('.webinar__lightbox-title').text("Future-proof your career with AI/ ML, Data Science"); \$('input[name="Event Name"]').val("Future-proof your career with AI/ ML, Data Science"); }else if((webinarType == "REGULAR") || (webinarType == undefined)){ \$('.webinar__lightbox-title').text("How to Nail your next Technical Interview"); \$('input[name="Event Name"]').val("How to Nail your next Technical Interview"); } if(registration_type == "byecalendly"){ //if(registration_type == "calendly" && registration_type == "byecalendly"){ \$('body').css('overflow','hidden'); \$('.webinar__lightbox').css('display','flex'); if(useEffect == "Yes"){ \$(".webinar__lightbox-card").css("right","-100%"); \$(".webinar__lightbox-card").animate({right: '0px',}, 500); } }else{ showCalendly("v1"); } }); \$('.direct-link-v2').click(function(){ if(registration_type == "byecalendly"){ \$('body').css('overflow','hidden'); \$('.webinar__lightbox').css('display','flex'); if(useEffect == "Yes"){ \$(".webinar__lightbox-card").css("right","-100%"); \$(".webinar__lightbox-card").animate({right: '0px',}, 500); } //showCalendly("v1"); }else{ showCalendly("v2"); } }); var hubspot_url = generateCalendlyLink("hubspot"); let domel = '<div class="meetings-iframe-container" data-src="'+hubspot_url+'"></div>'; \$(".letstalk-hubspot").append(domel); \$.getScript("https://static.hsappstatic.net/MeetingsEmbed/ex/MeetingsEmbedCode.js"); }); window.cookieconsent.initialise({palette:{popup:{background:"#3996d2",text:"#ffffff"},button:{background:"#00d1b4",text:"#ffffff"}},theme:"classic",content:{message:"We use cookies to enable the best possible experience on our site and to optimize the content for you. If you continue surfing you agree.",href:"https://www.interviewkickstart.com/privacy-policy"}}); function getAllUrlParams(t){var t=t?t.split("?")[1]:window.location.search.slice(1),e={};if(t)for(var r=(t=t.split("#")[0]).split("&"),a=0;a<r.length;a++){var i,l=r[a].split("="),s=l[0],o=void 0===l[1]||l[1];(s=s.toLowerCase()).match(/\[(\d+)?\]\$/)?(e[i=s.replace(/\[(\d+)?\]/,"")]||(e[i]=[]),s.match(/\[\d+\]\$/)?(l=/\[(\d+)\]/.exec(s)[1],e[i][l]=o):e[i].push(o)):e[s]?(e[s]&&"string"==typeof e[s]&&(e[s]=[e[s]]),e[s].push(o)):e[s]=o}return e} function create_UUID() { var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0; var v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); var timestamp = new Date().getTime(); return uuid + '-' + timestamp; } var visitor_id = getCookie("unique_visitor_id6"); var expdate = new Date(); expdate.setTime(expdate.getTime()+(365*24*60*60*1000)); if(visitor_id == ""){ setCookie("unique_visitor_id6",create_UUID()); visitor_id = getCookie("unique_visitor_id6"); } var referrer = document.referrer; var cta_lp = window.location.pathname; if((referrer != "") && (referrer.indexOf(window.location.host.toString()) == -1) && (referrer.indexOf("calendly.com") == -1)){ if(window.location.pathname == '/'){ setCookie("ik-landingpage-v2",'/home'); }else{ if((referrer.indexOf("signup-final-step") == -1)) setCookie("ik-landingpage-v2",window.location.pathname); } } var utm_params_url; var iksite_url = window.location.hostname; let calendly_param = getAllUrlParams(); \$(".iksiteurl").val(iksite_url); \$(".salesforce_uuid").val(decodeURIComponent(calendly_param['salesforce_uuid'])); if(calendly_param['invitee_first_name'] != undefined){ \$(".wr__whatsappconsent").val(decodeURIComponent(calendly_param['whatsapp_consent'])); \$(".invitee_first_name").val(decodeURIComponent(calendly_param['invitee_first_name'])); \$(".invitee_last_name").val(decodeURIComponent(calendly_param['invitee_last_name'])); \$(".invitee_email").val(decodeURIComponent(calendly_param['invitee_email'])); \$(".answer_1").val(decodeURIComponent(calendly_param['answer_1'])); \$(".utm_source").val(decodeURIComponent((calendly_param['utm_source'] != undefined) ? calendly_param['utm_source'] : "")); \$(".utm_medium").val(decodeURIComponent((calendly_param['utm_medium'] != undefined) ? calendly_param['utm_medium'] : "")); \$(".utm_campaign").val(decodeURIComponent((calendly_param['utm_campaign'] != undefined) ? calendly_param['utm_campaign'] : "")); \$(".salesforce_uuid").val(decodeURIComponent((calendly_param['salesforce_uuid'] != undefined) ? calendly_param['salesforce_uuid'] : "")); \$(".gclid").val(decodeURIComponent((calendly_param['gclid'] != undefined) ? calendly_param['gclid'] : "")); \$(".msclkid").val(decodeURIComponent((calendly_param['msclkid'] != undefined) ? calendly_param['msclkid'] : "")); \$(".fbclid").val(decodeURIComponent((calendly_param['fbclid'] != undefined) ? calendly_param['fbclid'] : "")); \$(".event_start_time").val(decodeURIComponent((calendly_param['event_start_time'] != undefined) ? calendly_param['event_start_time'] : "")); \$(".event_end_time").val(decodeURIComponent((calendly_param['event_end_time'] != undefined) ? calendly_param['event_end_time'] : "")); \$(".user_id").val(visitor_id); \$(".iksiteurl").val(window.location.hostname); utm_params_url = {}; }else{ utm_params_url = getAllUrlParams(); } if(utm_params_url['gh_jid'] != undefined){ utm_params_url = {}; \$('.careers-sec1, .careers-sec2, .careers-sec3, .careers-sec4,.section.hero-careers-sec, .career-section, .life-ik, .we-were-here-section, .ik-member, .ik-talks, .careers-imgages, .our-values, .careers-sec7, .who-we-are, .careers-sec6, .careers-sec5, .careers-sec4, .life-ik, .careers-sec3, .careers-sec2, .careers-sec1').hide(); } if((utm_params_url['lm'] != undefined) || (utm_params_url['stayhere'] != undefined) || (utm_params_url['forceuswebinar'] != undefined)){ utm_params_url = read_cookie("v_latest"); } let isEmpty = jQuery.isEmptyObject(utm_params_url); let r_visit = read_cookie("v_latest"); \$(document).ready(function(){ \$.getJSON("https://get.geojs.io/v1/ip/geo.json",function(t){}).done(function(t){ var getUtmParam = getAllUrlParams(); if (getUtmParam.forceuswebinar == "true") {v_region="Texas",utz=t.timezone,v_city="Houston",v_ccode=t.country_code,v_ip=t.ip, v_country="United States",\$('.v_country').val(v_country);\$(".wr__region").val(v_region);\$(".wr__city").val(v_city); }else{v_region=t.region,utz=t.timezone,v_city=t.city,v_ccode=t.country_code,v_ip=t.ip,v_country=t.country,\$('.v_country').val(t.country);\$(".wr__region").val(t.region);\$(".wr__city").val(t.city);\$(".user_timezone").val(t.timezone); } if(isEmpty && (r_visit == null)){ bake_organic_cookie(); } else if(!isEmpty && (r_visit == null)){ bake_cookie("v_latest", utm_params_url); if(referrer == null || referrer.indexOf(window.location.host.toString()) == -1) bake_cookie_history("v_history", utm_params_url); } else if(isEmpty && (r_visit != null)){ if(r_visit['utm_source'] != "") { bake_organic_cookie(); } } else{ if(!isDuplicateCookie(utm_params_url, r_visit)){ bake_cookie("v_latest", utm_params_url); if(referrer == null || referrer.indexOf(window.location.host.toString()) == -1) bake_cookie_history("v_history", utm_params_url); } } }).fail(function(t){}); \$('.cc-btn').attr('aria-label', "Got it"); }); function rtfToMarkdown(e){let r=e.innerHTML;return r=r.replace(/ < p > /g,""),r=r.replace(/<\/p>/g,"\n\n"),r=r.replace(/ < br > /g,"\n"),r=r.replace(/&nbsp;/g," "),r=r.replace(/ < /g,"<"),r=r.replace(/&gt;/g,">"),r=r.replace(/&lt;/g,"<"),r} function capitalizeFirstLetter(e){return e.charAt(0).toUpperCase()+e.slice(1)}function getTOC(){headers=["h1","h2"],list_of_headers=[];for(let e=0;e<headers.length;e++)if(document.getElementsByTagName(headers[e]).length)for(let t=0;t<document.getElementsByTagName(headers[e]).length;t++)header_text=document.getElementsByTagName(headers[e])[t].innerHTML,header_id=document.getElementsByTagName(headers[e])[t].id,header_text&&header_id&&list_of_headers.push([capitalizeFirstLetter(header_text),header_id]);const e=document.getElementsByClassName("toc")[0];if(!(list_of_headers.length<=1))for(let t=0;t<list_of_headers.length;t++)e.innerHTML+=`<li><a href="#\${list_of_headers[t][1]}">\${list_of_headers[t][0]}</a></li>`} \$(document).ready(function(){if(false){ console.log("1");let markdowns=\$(".markdown-body");markdowns.toArray().forEach(((o,r)=>{let n=rtfToMarkdown(o);o.innerHTML=marked.parse(n)})),getTOC();}}); \$(document).ready(function() { \$('a').each(function() {var reg_exp = new RegExp('/' + window.location.host + '/'); if (!reg_exp.test(this.href)) {\$(this).attr('rel','nofollow');}}); }); var showeditor = true; var userCodeEditorAccess; window.showeditor = true; \$(document).ready(function () { userCodeEditorAccess = getCookie("usercodeeditoraccess"); userCodeEditorAccess = (userCodeEditorAccess == '') ? false : userCodeEditorAccess; if (!showeditor) { \$('.cms-body-row').css({ height: "auto" }) } \$('.download-testcases').click(function(e){ const testcases = window.ik.downloadTestcases(); if(userCodeEditorAccess){ download('testcase.txt', testcases); } else { \$('.modal-wrapper').css("display","flex"); } }); \$('.btn__get-full-access').click(function(e) { const testcases = window.ik.downloadTestcases(); e.preventDefault(); setHiddenFields(); var name_regex = new RegExp("^[a-zA-Z ]+\$"); var email_regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+\$/; \$( "#sb-fname" ).keypress(function() { \$('.fname-error').addClass('hide'); }); \$( "#sb-email" ).keypress(function() { \$('.email-error').addClass('hide'); }); \$( "#sb-fname, #sb-email" ).focus(function() { \$('.fname-error, .email-error').addClass('hide'); }); if( (\$("#sb-fname").val().length == 0) && (\$("#sb-email").val().length == 0)){ \$('.fname-error, .email-error').removeClass('hide'); } else if (!name_regex.test(\$("#sb-fname").val()) || \$("#sb-fname").val().length == 0){ \$('.fname-error').removeClass('hide'); }else if (!email_regex.test(\$("#sb-email").val()) || \$("#sb-email").val().length == 0){ \$('.email-error').removeClass('hide'); }else{ if(\$('.checkbox__enroll-me').is(":checked")){ showCalendly(); \$(".form__get-full-access").submit(); setCookie("usercodeeditoraccess",true); userCodeEditorAccess = true; \$('.download-testcases').attr('disabled','disabled'); }else{ \$(".form__get-full-access").submit(); setCookie("usercodeeditoraccess",true); userCodeEditorAccess = true; } download('testcase.txt', testcases); } }); }); var usertimezone; function geoip(json){ usertimezone = json.timezone; } \$(document).ready(function() { var ltz = (new Date()).toTimeString().match(new RegExp("[A-Z](?!.*[\(])","g")).join(''); \$('.webinar-slots-item').each(function(){ let localtime = UTLtoLocal(\$(this).find('.utc-date').val(), \$(this).find('.utc-date').data('timezone')); \$(this).find('.slot-radio-date').html(localtime +" "+ltz); \$(this).find('.utc-date').data('local',localtime); if(compareDates(localtime)){ \$(this).hide(); } }); function UTLtoLocal(utcdate, timezone) { let pdtdate = new Date(utcdate); // pdtdate.setHours(pdtdate.getHours() - 1); let theDate = new Date(Date.parse(pdtdate + timezone)); let localDate = theDate.toLocaleDateString('en-US', { weekday: 'short', month: 'long', day: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' }); return localDate; } function compareDates(eventdate){ let currentdate = new Date(); let edate = new Date(eventdate); if(currentdate.getTime() >= edate.getTime()){ return true; } } int_phone = window.intlTelInput(document.querySelector("#wcalendly_pnumber"), { initialCountry: "auto", geoIpLookup: function(callback) { \$.get('https://get.geojs.io/v1/ip/geo.js', function() {}, "jsonp").always(function(resp) { var countryCode = (resp && resp.country_code) ? resp.country_code : "us"; callback(countryCode); }); }, hiddenInput: "full", utilsScript: "//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.3/js/utils.js" }); \$('.btn-submit-wc-step1').click(function(e) { e.preventDefault(); let active_visit = read_cookie("v_latest"); var full_phone_number = int_phone.getNumber(intlTelInputUtils.numberFormat.E164); \$("input[name='phone_number[full]'").val(full_phone_number); \$('.wc_utm_source').val(active_visit['utm_source']); \$('.wc_utm_medium').val(active_visit['utm_medium']); \$('.wc_utm_campaign').val(active_visit['utm_campaign']); \$('.wc_utm_term').val(active_visit['utm_term']); \$('.wc_utm_content').val(active_visit['utm_content']); \$('.wc_fbclid').val(active_visit['gclid']); \$('.wc_gclid').val(active_visit['gclid']); \$('.wc_msclkid').val(active_visit['msclkid']); \$('.wc_timezone').val(usertimezone); \$('.wc_page_url').val(window.location.pathname); \$('.wc_user_id').val(visitor_id); \$('.wc_hostname').val(window.location.hostname); var name_regex = new RegExp("^[a-zA-Z ]+\$"); var email_regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+\$/; var phone_regex = /^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}\$/gm; \$( "#wcalendly-fname" ).keypress(function() { \$('.fname-error').addClass('hide'); }); \$( "#wcalendly-lname" ).keypress(function() { \$('.lname-error').addClass('hide'); }); \$( "#wcalendly_pnumber" ).keypress(function() { \$('.mobile-error').addClass('hide'); }); \$( "#wcalendly-email" ).keypress(function() { \$('.email-error').addClass('hide'); }); \$( "#wcalendly-fname, #wcalendly-lname, #wcalendly-email, #wcalendly_pnumber" ).focus(function() { \$('.fname-error, .lname-error, .email-error, .mobile-error').addClass('hide'); }); if( (\$("#wcalendly-fname").val().length == 0) && (\$("#wcalendly-lname").val().length == 0) && (\$("#wcalendly-email").val().length == 0) && (\$("#wcalendly_pnumber").val().length == 0)){ \$('.fname-error, .lname-error, .email-error, .mobile-error').removeClass('hide'); } else if (!name_regex.test(\$("#wcalendly-fname").val()) || \$("#wcalendly-fname").val().length == 0){ \$('.fname-error').removeClass('hide'); }else if (!name_regex.test(\$("#wcalendly-lname").val()) || \$("#wcalendly-lname").val().length == 0){ \$('.lname-error').removeClass('hide'); }else if (!email_regex.test(\$("#wcalendly-email").val()) || \$("#wcalendly-email").val().length == 0){ \$('.email-error').removeClass('hide'); }else if(!phone_regex.test(\$("#wcalendly_pnumber").val()) || \$("#wcalendly_pnumber").val().length == 0){ \$('.mobile-error').removeClass('hide'); }else{ \$('.wc_fname').val(\$("#wcalendly-fname").val()); \$('.wc_lname').val(\$("#wcalendly-lname").val()); \$('.wc_email').val(\$("#wcalendly-email").val()); \$('.wc_phone').val(full_phone_number); \$(".lead-form-details").hide(); \$(".lead-form-moredetails").show(); \$("#dlc-personal-details").submit(); } }); \$( "input[type=radio]" ).on( "click", function() { \$('.slots-error').addClass('hide'); \$('.wc_webinar_starttime').val(\$( this ).data('starttime')); \$('.wc_webinar_endtime').val(\$( this ).data('endtime')); \$(".slot-booked2").text(\$(this).data('local')); }); \$('.btn-bookthis-slot').click(function(e) { e.preventDefault(); let n = \$( "input:checked" ).length; if( n == 0){ \$('.slots-error').removeClass('hide'); }else{ \$('.wc_slot').val(\$( "input:checked" ).val()); \$('.slots-error').addClass('hide'); \$(".lead-form-slots").hide(); \$(".lead-form-details").show(); \$("#dlc-webinar-slots").submit(); } }); }); \$(document.body).append(\$("#problem-data")); \$(document).ready(function() { \$('.program-rt').wrapInner('<div class="markdown-body" style="text-align:left;margin-bottom: 30px"></div>'); \$('code').addClass("nohighlight"); }); ```