ראיון בgoogle meet של חצי שעה
שאלה הלוגית ניתנה בע"פ .
שאלות מתוך הראיון
נתון פונקציה שמקבלת מחרוזת שמכילה תווים ופעולות חשבוניות כגון: "b-a +b-(a+b)"
הפונקציה תחזיר את התוצאה של המחרוזת
תשובות
הוסף תשובה
|
לצפיה בתשובות
פברואר 2023
ניתן לעשות לולאה שחותכת את המחרוזת בספליט, ולהגדיר לה את סדר פעולות החשבון ב case או סתם ב if אחד אחרי השני.
להתנות שאם str.split(i)== '*' || '(' || '%' אז להתחיל משם את התרגיל.. :)
מרץ 2023
התשובה הנכונה והיעילה ביותר היא
לעבור על המחרוזת למצוא עם המתודה indexOf את הכפל או החילוק הראשון,
לקחת את המספרים משני צידי האופרטור, לפתור את התרגיל ואת התוצאה לשים במקום כל התרגיל, להמשיך ככה עד הסוף עד שנגמר האופרטורים כפל וחילוק,
ואז לפי הסדר לפתור את התרגילים של פלוס ומינוס, עד שנשאר רק מספרים במחרוזת וזה התוצאה!
You are given an array segments consisting of N integers denoting the lengths of several segments. Your task is to find among them four segments from which a rectangle can be constructed. What is the minimum absolute difference between the side lengths of the constructed rectangle?
Write a function:
int solution(int[] segments);
that, given an array segments, returns the minimum absolute difference between the side lengths of the constructed rectangle or −1 if no rectangle can be constructed.
Assume that:
N is an integer within the range [1..30];
each element of array segments is an integer within the range [1..1,000].
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
In a directed graph, each node is assigned an uppercase letter. We define a path's value as the number of most frequently-occurring letter along that path. For example, if a path in the graph goes through "ABACA", the value of the path is 3, since there are 3 occurrences of 'A' on the path.
Given a graph with n nodes and m directed edges, return the largest value path of the graph. If the largest value is infinite, then return null.
The graph is represented with a string and an edge list. The i-th character represents the uppercase letter of the i-th node. Each tuple in the edge list (i, j) means there is a directed edge from the i-th node to the j-th node. Self-edges are possible, as well as multi-edges.
ברשותך שני פתילים. ידוע לך שמן הרגע שהדלקת את קצהו של אחד הפתילים, הוא יבער במשך שעה אחת בדיוק. קצב הבעירה אינו אחיד (כלומר- חצי פתיל לא בהכרח יבער במשך חצי שעה). מדוד שלושת רבעי השעה בעזרת שני הפתילים.
תשובות
הוסף תשובה
|
לצפיה בתשובות
אוקטובר 2022
מדליקים את הפתילה הראשונה משתי הצדדים ואת הפתילה השניה רק מצד אחד. כשהפתילה הראשונה מתכבה מדליקים גם את הצד השני של הפתילה השניה.